ALMA Computing Group

HelloDemoClient.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.client; 00021 00022 import java.util.logging.Level; 00023 import java.util.logging.Logger; 00024 00025 import alma.JavaContainerError.wrappers.AcsJContainerServicesEx; 00026 import alma.acs.component.client.ComponentClient; 00027 import alma.demo.HelloDemo; 00028 00035 public class HelloDemoClient extends ComponentClient 00036 { 00037 private HelloDemo m_helloComp; 00038 00045 public HelloDemoClient(Logger logger, String managerLoc, String clientName) 00046 throws Exception { 00047 super(logger, managerLoc, clientName); 00048 } 00049 00054 public void doSomeStuff() throws AcsJContainerServicesEx { 00055 m_helloComp = alma.demo.HelloDemoHelper.narrow(getContainerServices().getComponent("HELLODEMO1")); 00056 00057 String helloRet = m_helloComp.sayHello(); 00058 m_logger.info("got string from component's sayHello method: " 00059 + helloRet); 00060 } 00061 00066 public static void main(String[] args) { 00067 String managerLoc = System.getProperty("ACS.manager"); 00068 if (managerLoc == null) { 00069 System.out 00070 .println("Java property 'ACS.manager' must be set to the corbaloc of the ACS manager!"); 00071 System.exit(-1); 00072 } 00073 String clientName = "HelloDemoClient"; 00074 HelloDemoClient hlc = null; 00075 try { 00076 hlc = new HelloDemoClient(null, managerLoc, clientName); 00077 hlc.doSomeStuff(); 00078 } 00079 catch (Exception e) { 00080 try { 00081 Logger logger = hlc.getContainerServices().getLogger(); 00082 logger.log(Level.SEVERE, "Client application failure", e); 00083 } catch (Exception e2) { 00084 e.printStackTrace(System.err); 00085 } 00086 } 00087 finally { 00088 if (hlc != null) { 00089 try { 00090 hlc.tearDown(); 00091 } 00092 catch (Exception e3) { 00093 // bad luck 00094 e3.printStackTrace(); 00095 } 00096 } 00097 } 00098 } 00099 }