ALMA Computing Group

HelloDemoImpl.java

Go to the documentation of this file.
00001 /*
00002  * ALMA - Atacama Large Millimiter Array (c) European Southern Observatory,
00003  * 2002 Copyright by ESO (in the framework of the ALMA collaboration), All
00004  * rights reserved
00005  * 
00006  * This library is free software; you can redistribute it and/or modify it
00007  * under the terms of the GNU Lesser General Public License as published by the
00008  * Free Software Foundation; either version 2.1 of the License, or (at your
00009  * option) any later version.
00010  * 
00011  * This library is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00014  * for more details.
00015  * 
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this library; if not, write to the Free Software Foundation,
00018  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00019  */
00020 package alma.demo.HelloDemoImpl;
00021 import java.util.logging.Logger;
00022 
00023 import org.omg.CORBA.DoubleHolder;
00024 import org.omg.CORBA.IntHolder;
00025 
00026 import alma.ACS.ComponentStates;
00027 import alma.acs.component.ComponentLifecycle;
00028 import alma.acs.container.ContainerServices;
00029 import alma.demo.HelloDemoOperations;
00030 
00040 public class HelloDemoImpl implements ComponentLifecycle, HelloDemoOperations
00041 {
00042         private ContainerServices m_containerServices;
00043         private Logger m_logger;
00044 
00046         // Implementation of ComponentLifecycle
00048         
00049         public void initialize(ContainerServices containerServices) {
00050                 m_containerServices = containerServices;
00051                 m_logger = m_containerServices.getLogger();
00052                 m_logger.info("initialize() called...");
00053         }
00054     
00055         public void execute() {
00056                 m_logger.info("execute() called...");
00057         }
00058     
00059         public void cleanUp() {
00060                 m_logger.info("cleanUp() called..., nothing to clean up.");
00061         }
00062     
00063         public void aboutToAbort() {
00064                 cleanUp();
00065                 m_logger.info("managed to abort...");
00066         System.out.println("HelloDemo component managed to abort... you should know this even if the logger did not flush correctly!");
00067         }
00068         
00070         // Implementation of ACSComponent
00072         
00073         public ComponentStates componentState() {
00074                 return m_containerServices.getComponentStateManager().getCurrentState();
00075         }
00076         public String name() {
00077                 return m_containerServices.getName();
00078         }
00079         
00081         // Implementation of HelloDemoOperations
00083         
00084         public String sayHello() {
00085                 m_logger.info("sayHello called...");
00086                 return "hello";
00087         }
00088         
00089         public String sayHelloWithParameters(String inString,
00090                         DoubleHolder inoutDouble, IntHolder outInt) {
00091                 m_logger.info("sayHello called with arguments inString=" + inString
00092                                 + "; inoutDouble=" + inoutDouble.value
00093                                 + ". Will return 'hello'...");
00094                 outInt.value = (int) Math.round(Math.E * 10000000);
00095                 return "hello";
00096         }
00097 }