ALMA Computing Group

LampCallbackClient.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.ACSErr.ACSException; 00027 import alma.acs.component.client.ComponentClient; 00028 import alma.demo.LampCallback; 00029 import alma.demo.LampUnavailable; 00030 00031 00038 public class LampCallbackClient extends ComponentClient 00039 { 00040 private LampCallback m_lampCallback; 00041 00048 public LampCallbackClient(Logger logger, String managerLoc, String clientName) 00049 throws Exception 00050 { 00051 super(logger, managerLoc, clientName); 00052 00053 m_lampCallback = alma.demo.LampCallbackHelper.narrow( 00054 getContainerServices().getComponent("LAMPCALLBACK1")); 00055 00056 } 00057 00058 public void doSomeStuff() throws LampUnavailable 00059 { 00060 monitorLampBrightness(); 00061 00062 try 00063 { 00064 m_lampCallback.acsExceptionMethodVoid(); 00065 m_logger.warning("no ex was thrown!"); 00066 } 00067 catch (ACSException e) 00068 { 00069 m_logger.info("received exception from acsExceptionMethodVoid(): "); 00070 00071 e.printStackTrace(); 00072 } 00073 00074 try 00075 { 00076 double d = m_lampCallback.acsExceptionMethodDouble(); 00077 00078 m_logger.warning("no ex was thrown, double=" + d); 00079 } 00080 catch (ACSException e) 00081 { 00082 m_logger.info("received exception from acsExceptionMethodDouble(): "); 00083 00084 e.printStackTrace(); 00085 } 00086 00087 00088 } 00089 00090 public void monitorLampBrightness() throws LampUnavailable 00091 { 00092 // if (m_comp == null) 00093 // { 00094 // try 00095 // { 00096 // setUp(); 00097 // } 00098 // catch (Exception e) 00099 // { 00100 // e.getStackTrace(); 00101 // } 00102 // 00103 // } 00104 String actualBrightness = ""; 00105 00106 actualBrightness = m_lampCallback.monitorLampBrightness() + ""; 00107 00108 // String expectedBrightness = 0.0 + ""; 00109 System.out.println("monitored brightness " + actualBrightness); 00110 } 00111 00112 00116 public static void main(String[] args) 00117 { 00118 String managerLoc = System.getProperty("ACS.manager"); 00119 if (managerLoc == null) 00120 { 00121 System.out.println("Java property 'ACS.manager' must be set to the corbaloc of the ACS manager!"); 00122 System.exit(-1); 00123 } 00124 00125 String clientName = "LampCallbackClient"; 00126 LampCallbackClient lcbcl = null; 00127 try 00128 { 00129 lcbcl = new LampCallbackClient(null, managerLoc, clientName); 00130 00131 lcbcl.doSomeStuff(); 00132 } 00133 catch (Exception e) 00134 { 00135 e.printStackTrace(System.err); 00136 } 00137 finally 00138 { 00139 if (lcbcl != null) 00140 { 00141 try 00142 { 00143 lcbcl.tearDown(); 00144 } 00145 catch (Exception e1) 00146 { 00147 // bad luck 00148 } 00149 } 00150 } 00151 } 00152 }