ALMA Computing Group

EventConsumerImpl.java

Go to the documentation of this file.
00001 /* 00002 * ALMA - Atacama Large Millimiter Array 00003 * (c) Associated Universities Inc., 2002 00004 * (c) European Southern Observatory, 2002 00005 * Copyright by ESO (in the framework of the ALMA collaboration), 00006 * All rights reserved 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00021 * MA 02111-1307 USA 00022 * 00023 * EventConsumerImpl.java 00024 * 00025 * Created on April 11, 2003, 2:21 PM 00026 */ 00027 00028 package alma.demo.EventConsumerImpl; 00029 00030 import alma.acs.component.ComponentImplBase; 00031 import alma.acs.component.ComponentLifecycleException; 00032 import alma.acs.container.ContainerServices; 00033 import alma.acs.nc.Consumer; 00034 import alma.demo.ConsumerCompOperations; 00035 00040 public class EventConsumerImpl extends ComponentImplBase implements ConsumerCompOperations 00041 { 00042 private Consumer m_consumer; 00043 00047 public void initialize(ContainerServices containerServices) 00048 throws ComponentLifecycleException 00049 { 00050 super.initialize(containerServices); 00051 00052 try 00053 { 00054 m_consumer = new Consumer(alma.FRIDGE.CHANNELNAME_FRIDGE.value, m_containerServices); 00055 //Subscribe to a domain and event type. 00056 m_consumer.addSubscription(alma.FRIDGE.temperatureDataBlockEvent.class, this); 00057 m_consumer.consumerReady(); 00058 m_logger.info("ConsumerComp is waiting for 'temperatureDataBlockEvent' events."); 00059 } 00060 catch (Exception e) 00061 { 00062 if (m_consumer != null) { 00063 m_consumer.disconnect(); 00064 } 00065 throw new ComponentLifecycleException("failed to connect as an event consumer to channel " + alma.FRIDGE.CHANNELNAME_FRIDGE.value); 00066 } 00067 } 00068 00069 00077 public void receive(alma.FRIDGE.temperatureDataBlockEvent joe) 00078 { 00079 m_logger.info("Received an event: the temp difference is: " + joe.absoluteDiff); 00080 } 00081 00082 00086 public void cleanUp() 00087 { 00088 m_consumer.disconnect(); 00089 } 00090 00091 }