1 2 package SOFA.SOFAnode.Run.Deployment; 3 4 import java.net.InetAddress ; 5 import java.net.UnknownHostException ; 6 7 import org.omg.CosNaming.NameComponent ; 8 9 import SOFA.SOFAnode.Run.DeplDockRegistry.DeplDockRegistry; 10 import SOFA.SOFAnode.Run.DeplDockRegistry.DeplDockRegistryHelper; 11 12 16 public class ComponentAccess { 17 18 private SOFA.Component.ThreadIDRegistry thrReg; 19 private SOFA.Util.CORBAAccess ca; 20 21 22 public DeplDockRegistry ddr; 23 24 28 public ComponentAccess() throws ComponentAccessException { 29 if (System.getSecurityManager() == null) { 30 System.setSecurityManager(new java.rmi.RMISecurityManager ()); 31 } 32 33 String sofaNodeName = System.getProperty("sofa.nodename",""); 34 if (sofaNodeName.compareTo("")==0) { 35 try { 36 sofaNodeName = InetAddress.getLocalHost().getHostName(); 37 } catch (UnknownHostException e) { 38 throw new ComponentAccessException("Can't get host name. Set name to property \"sofa.nodename\"", e); 39 } 40 } 41 42 System.setProperty("sofa.nodename",sofaNodeName); 43 thrReg = new SOFA.Component.ThreadIDRegistryImpl(sofaNodeName); 44 45 ca = new SOFA.Util.CORBAAccess(); 46 NameComponent nc = new NameComponent ("DeplDockRegistry", ""); 47 NameComponent path[] = {nc}; 48 try { 49 ddr = DeplDockRegistryHelper.narrow(SOFA.Util.CORBAAccess.ncRef.resolve(path)); 50 } catch (Exception e) { 51 throw new ComponentAccessException("Can't get DeplDock registry.", e); 52 } 53 } 54 55 61 public SOFA.Connector.RoleBase correctRoleBase(SOFA.Connector.RoleBase rb) { 62 rb.setThrIDRegistry(thrReg); 63 return rb; 64 } 65 66 72 public SOFA.SOFAnode.Run.Deployment.DeplDock getDock(String name) throws ComponentAccessException { 73 byte[] serRef = null; 74 try { 75 serRef = ddr.lookup(name); 76 } catch (SOFA.SOFAnode.Run.DeplDockRegistry.NotFoundException e) { 77 throw new ComponentAccessException("No deployment dock with name \""+name+"\"."); 78 } 79 80 SOFA.Connector.Reference ddRef = SOFA.SOFAnode.Run.Deployment.DeplDockImpl.bytesToSofaReference(serRef); 81 82 SOFA.SOFAnode.Run.Deployment.DeplDock ddock = null; 83 try { 84 ddock = (SOFA.SOFAnode.Run.Deployment.DeplDock) SOFA.Connector.Boot.DeplDockConnector.createClt(ddRef); 85 } catch (SOFA.Connector.ConnectorException e) { 86 throw new ComponentAccessException("Can't create connector to deployment dock."); 87 } 88 return ddock; 89 } 90 91 92 } 93 | Popular Tags |