ALMA Computing Group

LampComponentClient1.java

Go to the documentation of this file.
00001 /* 00002 * ALMA - Atacama Large Millimiter Array 00003 * (c) European Southern Observatory, 2002 00004 * Copyright by ESO (in the framework of the ALMA collaboration), 00005 * All rights reserved 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00020 * MA 02111-1307 USA 00021 */ 00022 package alma.demo.client; 00023 00024 import java.util.logging.Logger; 00025 00026 import alma.ACS.RWdouble; 00027 import alma.acs.component.client.ComponentClient; 00028 import alma.acs.container.ContainerServices; 00029 import alma.acsexmplLamp.Lamp; 00030 import alma.acsexmplLamp.LampHelper; 00031 00037 public class LampComponentClient1 extends ComponentClient 00038 { 00039 private Lamp m_lamp; 00040 00041 private Logger m_logger; 00042 00043 00044 public LampComponentClient1(String managerLoc, String clientName) 00045 throws Exception 00046 { 00047 super(null, managerLoc, clientName); 00048 00049 // same service interface that a component would get from the container... 00050 ContainerServices csrv = getContainerServices(); 00051 00052 // get a logger 00053 m_logger = csrv.getLogger(); 00054 00055 String lampCurl = "LAMP1"; 00056 00057 // or if we don't know the curl (=instance name)... 00058 // String[] lampCurls = csrv.findComponents(null, "IDL:alma.acsexmplLamp.Lamp:1.0"); 00059 // if (lampCurls.length > 0) 00060 // { 00061 // lampCurl = lampCurls[0]; 00062 // } 00063 // else 00064 // { 00065 // throw new Exception("no Lamp component available"); 00066 // } 00067 00068 // get (CORBA) reference to Lamp component 00069 org.omg.CORBA.Object lampObj = csrv.getComponent(lampCurl); 00070 00071 // use CORBA helper class for the type cast 00072 m_lamp = LampHelper.narrow(lampObj); 00073 } 00074 00075 00079 public void doSomeStuff() 00080 { 00081 m_logger.info("will now use the lamp component..."); 00082 00083 RWdouble propBrightness = m_lamp.brightness(); 00084 00085 propBrightness.set_sync(22.345); 00086 00087 m_logger.info("lamp component calls done..."); 00088 } 00089 00090 00091 00092 00093 public static void main(String[] args) 00094 { 00095 // 00096 String managerLoc = System.getProperty("ACS.manager"); 00097 if (managerLoc == null) 00098 { 00099 System.out.println("Java property 'ACS.manager' " + 00100 " must be set to the corbaloc of the ACS manager!"); 00101 System.exit(-1); 00102 } 00103 00104 String clientName = "LampComponentClient1"; 00105 00106 try 00107 { 00108 LampComponentClient1 lcc = new LampComponentClient1(managerLoc, clientName); 00109 00110 lcc.doSomeStuff(); 00111 00112 lcc.tearDown(); 00113 } 00114 catch (Exception e) 00115 { 00116 e.printStackTrace(System.err); 00117 } 00118 } 00119 } 00120