1 28 29 30 package org.objectweb.ccm.runtime; 31 32 import org.objectweb.corba.runtime.*; 33 34 37 public class ContainerImpl 38 extends org.omg.CORBA.LocalObject 39 implements Servant, org.omg.Components.Deployment.ContainerOperations 40 { 41 static private String _class_name = "ContainerImpl"; 43 static final private String _type_id = org.omg.Components.Deployment.ContainerHelper.id(); 44 private ORBService _orb_service; 45 private String _ns_sref; 46 private String _extci_sref; 47 private java.util.ArrayList _home_refs; private org.omg.Components.ConfigValue[] _configuration; 49 private org.omg.Components.Deployment.ComponentServer _cs_ref; 50 51 public 53 ContainerImpl() 54 { 55 _orb_service = null; 57 _ns_sref = null; 58 _extci_sref = null; 59 _home_refs = new java.util.ArrayList (); 60 _configuration = new org.omg.Components.ConfigValue[0]; 61 _cs_ref = null; 62 } 63 64 68 static public Servant 69 create_servant() 70 { 71 return new ContainerImpl(); 72 } 73 74 78 82 final public void 83 system_configuration_complete(SystemConfiguration cfg) 84 { 85 ServantConfiguration scfg = (ServantConfiguration)cfg; 87 _orb_service = scfg.orb_service(); 88 89 org.omg.CORBA.Object obj = null; 91 obj = _orb_service.resolve_initial_references("NameService"); 93 94 if (obj==null) { 96 final String opname = "system_configuration_complete"; 98 final String msg = "FAILED (NS not found)"; 99 TheLogger.error(_class_name, opname, msg); 100 return ; 101 } 102 103 _ns_sref = _orb_service.object_to_string(obj); 104 105 obj = _orb_service.resolve_initial_references("ExtComponentInstallation"); 107 108 if (obj==null) { 110 final String opname = "system_configuration_complete"; 112 final String msg = "FAILED (ExtCI not found)"; 113 TheLogger.error(_class_name, opname, msg); 114 return ; 115 } 116 117 _extci_sref = _orb_service.object_to_string(obj); 118 119 125 } 126 127 final public void 128 destroy() 129 { 130 org.omg.Components.CCMHome[] refs = get_homes(); 132 for (int i=0;i<refs.length;i++) { 133 try { 134 refs[i].remove_home(); 136 137 } catch (org.omg.Components.RemoveFailure ex) { 139 final String opname = "destroy"; 141 TheLogger.debug(_class_name, opname, "IGNORE", ex); 142 return ; 143 } 144 } 145 146 _home_refs.clear(); 148 } 149 150 154 final public String 155 type_id() 156 { 157 return _type_id; 158 } 159 160 final public org.omg.PortableServer.Servant 161 as_native_servant() 162 { 163 return new org.omg.Components.Deployment.ContainerPOATie(this); 164 } 165 166 170 final public org.omg.Components.ConfigValue[] 171 configuration() 172 { 173 return _configuration; 174 } 175 176 final public org.omg.Components.Deployment.ComponentServer 177 get_component_server() 178 { 179 return _cs_ref; 180 } 181 182 final public org.omg.Components.CCMHome 183 install_home(String uuid, String entrypt, org.omg.Components.ConfigValue[] config) 184 throws org.omg.Components.Deployment.UnknownImplId, 185 org.omg.Components.Deployment.ImplEntryPointNotFound, 186 org.omg.Components.Deployment.InstallationFailure, 187 org.omg.Components.Deployment.InvalidConfiguration 188 { 189 191 ComponentRuntimeConfiguration cfg = new ComponentRuntimeConfiguration(); 193 194 org.coach.ECM.DegeneratedServiceRef[] dsrefs = new org.coach.ECM.DegeneratedServiceRef[2]; 196 dsrefs[0] = new org.coach.ECM.DegeneratedServiceRef(); 197 dsrefs[0].orb_registration_name = "NameService"; 198 dsrefs[0].initial_reference = _ns_sref; 199 dsrefs[1] = new org.coach.ECM.DegeneratedServiceRef(); 200 dsrefs[1].orb_registration_name = "ExtComponentInstallation"; 201 dsrefs[1].initial_reference = _extci_sref; 202 cfg.dservice_refs = dsrefs; 203 204 cfg.orb_service = _orb_service; 205 cfg.implementation_uuid = uuid; 206 207 org.omg.Components.CCMHome href = ComponentRuntime.loadHome(cfg); 209 210 _home_refs.add(href); 212 213 return href; 214 } 215 216 final public void 217 remove_home(org.omg.Components.CCMHome href) 218 throws org.omg.Components.RemoveFailure 219 { 220 org.omg.Components.CCMHome[] refs = get_homes(); 222 int i=0; 223 for (;i<refs.length;i++) { 224 if (href._is_equivalent(refs[i])) { 225 _home_refs.remove(i); 226 227 href.remove_home(); 229 230 break; 232 } 233 } 234 235 if (i==refs.length) { 237 throw new org.omg.Components.RemoveFailure(); 238 } 239 } 240 241 final public org.omg.Components.CCMHome[] 242 get_homes() 243 { 244 return (org.omg.Components.CCMHome[])_home_refs.toArray(new org.omg.Components.CCMHome[0]); 245 } 246 247 final public void 248 remove() 249 throws org.omg.Components.RemoveFailure 250 { 251 destroy(); 253 } 254 } 255 | Popular Tags |