1 26 27 28 29 package org.objectweb.openccm.OpenCCM_DCI.cif; 30 31 import org.objectweb.openccm.OpenCCM_DCI.*; 32 34 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.root.*; 36 import org.objectweb.openccm.descriptor.componentassembly.beans.*; 37 38 public class AssemblyXMLSegImpl 39 extends org.objectweb.openccm.OpenCCM_DCI. 40 AssemblyManagerSessionComposition.AssemblySeg 41 { 42 43 private String xml; 45 46 private org.objectweb.util.cmdline.api.Console console; 48 49 private ComponentassemblyBean assemblyObject; 51 52 private java.util.Hashtable general; 54 55 private Assembly etat; 57 58 private AssemblyManager am; 60 61 public void setupXML(String xml){ 62 this.xml=xml; 63 general=new java.util.Hashtable (); 64 etat=new AssemblyImplInactive(); 65 } 66 67 public void 68 setupAssemblyManager(org.objectweb.openccm.OpenCCM_DCI.AssemblyManager am){ 69 this.am=am; 70 } 71 72 73 76 private class AssemblyImplInactive implements Assembly 77 { 78 79 public void setupDeployTable() 80 { 81 try{ 82 general.put("__home_finder__",get_context().get_connection_home_finder()); 83 general.put("__home_registration__",get_context().get_connection_home_registration()); 84 general.put("__name_service__",get_context().get_connection_naming_service()); 85 general.put("__dci_information__",get_context().get_connection_dci_information()); 86 general.put("__assembly_manager__",am); 87 general.put("__component_list__",new java.util.LinkedList ()); 88 } 90 catch(Exception e){ 91 System.err.println("Problem occured during setting of the deployTable"); 92 } 93 } 94 95 96 public void build() throws org.omg.Components.CreateFailure { 97 try{ 98 99 loadCADTree(); 101 102 setupDeployTable(); 103 104 105 108 109 ComponentassemblyDeployer cad= 110 ((ComponentassemblyDeployer) 111 ((ComponentassemblyDeployerHandler) 112 assemblyObject 113 .getExtensionManager().getExtensionByName("ccm.Deployer")) 114 .getInstance((ComponentassemblyBeanImpl)assemblyObject)); 115 116 118 119 120 for (java.util.ListIterator it =((java.util.LinkedList ) 121 general.get("__component_list__")).listIterator(0); 122 it.hasNext() ; ) 123 { 124 try { 125 ((org.omg.Components.CCMObject) 126 general.get((String )it.next())).configuration_complete(); 127 } 128 catch (java.lang.ClassCastException exception) { 129 130 } 131 catch (org.omg.Components.InvalidConfiguration exception) 132 { 133 exception.printStackTrace(); 134 return ; 136 } 137 } 138 } 139 catch(Exception e) 140 { 141 e.printStackTrace(); throw new org.omg.Components.CreateFailure(); 142 } 143 etat=(Assembly) new AssemblyImplActive(); 144 registerAssembly() ; 145 } 146 147 148 152 private void loadCADTree()throws org.omg.Components.CreateFailure 153 { 154 org.omg.CORBA.ORB orb 156 = org.objectweb.openccm.corba.TheORB.getORB(); 157 159 org.objectweb.openccm.Components.Runtime.init (orb); 161 163 164 java.io.StringReader reader= new java.io.StringReader (xml); 165 166 try { 167 assemblyObject 168 = org.objectweb.openccm.descriptor.componentassembly.beans.ComponentassemblyBeanImpl 169 .unmarshalBean(reader,true); 170 } catch (java.io.IOException ex) 171 { 172 ex.printStackTrace(); 173 console.error("Could not unmarshal the assembly file"); 174 throw new org.omg.Components.CreateFailure(); 175 } 176 } 178 179 182 public void tear_down() throws org.omg.Components.RemoveFailure 183 { 184 throw new org.omg.Components.RemoveFailure(); 185 } 186 187 190 public org.omg.Components.Deployment.AssemblyState get_state() 191 { 192 return org.omg.Components.Deployment.AssemblyState.INACTIVE; 193 194 } 195 } 196 197 201 private class AssemblyImplActive implements Assembly{ 202 206 public void build() throws org.omg.Components.CreateFailure 207 { 208 throw new org.omg.Components.CreateFailure(); 209 } 210 211 217 public void tear_down() throws org.omg.Components.RemoveFailure 218 { 219 try{ 220 221 ComponentassemblyDeployer cad= 222 ((ComponentassemblyDeployer) 223 ((ComponentassemblyDeployerHandler) 224 assemblyObject 225 .getExtensionManager().getExtensionByName("ccm.Deployer")) 226 .getInstance((ComponentassemblyBeanImpl)assemblyObject)); 227 228 cad.tearDown(); 229 230 etat=(Assembly)new AssemblyImplInactive(); 231 232 } 233 catch(Exception e){e.printStackTrace();} 234 235 } 236 237 240 public org.omg.Components.Deployment.AssemblyState get_state() 241 { 242 return org.omg.Components.Deployment.AssemblyState.INSERVICE; 243 } 244 } 245 246 250 private void 251 registerAssembly() 252 { 253 259 260 org.omg.Components.Deployment.Assembly assemblyRef= 261 ((org.objectweb.openccm.OpenCCM_DCI.AssemblyManagerCCM)get_context()) 262 .provide_assembly(); 263 264 org.objectweb.openccm.corba.NamingContext ns = 266 org.objectweb.openccm.corba.TheNameService.getNamingContext(); 267 268 ns.rebind(assemblyObject.getId(), assemblyRef); 270 System.out.println("Assembly {"+assemblyObject.getId()+"} is referenced"); 271 } 272 273 274 public void 275 build() 276 throws org.omg.Components.CreateFailure 277 { 278 etat.build(); 279 } 280 281 public void 282 tear_down() 283 throws org.omg.Components.RemoveFailure 284 { 285 etat.tear_down(); 286 } 287 288 289 public org.omg.Components.Deployment.AssemblyState 290 get_state() 291 { 292 return etat.get_state(); 293 } 294 295 296 } 297 | Popular Tags |