1 26 27 package org.objectweb.openccm.Deployment; 28 29 30 import java.io.IOException; 31 import java.net.URL; 32 33 import org.objectweb.ccm.descriptor.componentassembly.beans.*; 34 import org.objectweb.ccm.descriptor.componentassembly.ccm.deployer.root.*; 36 import org.objectweb.ccm.descriptor.*; 37 import org.omg.Components.Deployment.Assembly; 38 import org.omg.CosNaming.NamingContextExtHelper; 39 40 42 51 public class AssemblyImpl extends org.omg.Components.Deployment.AssemblyPOA 52 implements AssemblyConfigurator{ 53 54 55 56 62 63 private URL xmlFilePath; 65 66 private org.objectweb.util.cmdline.api.Console console; 68 69 private java.util.zip.ZipFile zipFile; 70 71 private java.io.File tmpZipFile; 72 73 AssemblyBase etat ; 76 82 public 83 AssemblyImpl(URL xmlFilePath) 84 { 85 this.xmlFilePath=xmlFilePath; 86 etat=new AssemblyBase(this); 87 } 88 89 90 public ComponentassemblyDeployerHandler 91 configure(ComponentassemblyDeployerHandler context) 92 { 93 try{ 94 95 96 context.connectNamingcontext(NamingContextExtHelper.narrow( 97 org.objectweb.openccm.corba.TheNameService 98 .getNamingContext() 99 .getNamingContext())); 100 101 try{ 102 org.objectweb.openccm.OpenCCM_DCI.DCIManager 103 DCI= 104 org.objectweb.openccm. 105 OpenCCM_DCI.DCIManagerHelper. 106 narrow(org.objectweb.openccm.corba 107 .TheORB.resolve_initial_reference("DCIManager")); 108 109 context.connectHomefinder(DCI.provide_home_finder()); 110 context.connectHomeregistration(DCI.provide_home_registration()); 111 context.connectDciinfo(DCI.provide_dci_information()); 112 zipFile=new java.util.zip.ZipFile(xmlFilePath.getPath()); 113 context.connectZipEntryRetriever(new ZipEntryRetriever(zipFile)); 114 115 } 116 catch(Exception e){ 117 e.printStackTrace(); 118 System.err.println 119 ("CCM_deploy >> DCIManager not start, HomeFinder functionnalities disable !"); 120 System.err.println 121 ("CCM_deploy >> To start DCIManager execute dci_start <dci_name> command"); 122 } 123 } 124 catch(Exception e){ 125 System.err.println("Problem occured during setting of the deployTable"); 126 } 127 return context; 128 } 129 130 public Assembly getAssembly(){ 131 org.omg.CORBA.Object ref = 132 this._this_object(org.objectweb.openccm.corba.TheORB.getORB()); 133 134 return org.omg.Components.Deployment.AssemblyHelper.narrow(ref); 135 } 136 137 public void removeAssembly(){ 138 139 } 140 141 public ComponentassemblyBean getComponentassemblyTree() 142 { 143 try{ 144 org.omg.CORBA.ORB orb 146 = org.objectweb.openccm.corba.TheORB.getORB(); 147 149 org.objectweb.openccm.Components.Runtime.init (orb); 151 153 java.io.InputStreamReader reader ; 154 155 java.net.URL url=xmlFilePath; tmpZipFile =java.io.File.createTempFile(System.currentTimeMillis()+"","aar"); 157 java.io.FileOutputStream fos= new java.io.FileOutputStream(tmpZipFile); 158 159 160 java.io.InputStream bis=url.openStream(); 161 162 byte [] byteArray= new byte[32000]; 163 int readed=bis.read(byteArray,0,32000); 164 165 System.err.print("Downloading "+xmlFilePath+" ["); 166 while(readed>0) 167 { 168 fos.write(byteArray,0,readed); 169 readed=bis.read(byteArray,0,32000); 170 System.err.print("*"); 171 } 172 System.err.println("]"); 173 fos.flush(); 174 fos.close(); 175 176 zipFile= 177 new java.util.zip.ZipFile(tmpZipFile); 178 179 180 181 for(java.util.Enumeration enum=zipFile.entries();enum.hasMoreElements();) 182 { 183 184 java.util.zip.ZipEntry ze=(java.util.zip.ZipEntry)enum.nextElement(); 185 if(ze.getName().endsWith(".cad")) 187 { 188 reader=new java.io.InputStreamReader 189 (zipFile.getInputStream(ze)); 190 191 return org.objectweb.ccm.descriptor 192 .componentassembly.beans.ComponentassemblyBeanImpl 193 .unmarshalBean(reader,true); 194 } 195 } 196 } 197 catch(Exception e){ 198 e.printStackTrace(); 199 } 200 return null; 201 } 202 203 public void 204 deleteTemporaryFile() 205 { 206 try{ 207 zipFile.close(); 208 tmpZipFile.delete(); 209 } 210 catch(Exception e) 211 { } 213 214 } 215 216 217 218 219 public void 220 build() 221 throws org.omg.Components.CreateFailure 222 { 223 etat.build(); 224 } 225 226 227 public void 228 tear_down() 229 throws org.omg.Components.RemoveFailure 230 { 231 etat.tear_down(); 232 } 233 234 235 236 public org.omg.Components.Deployment.AssemblyState 237 get_state() 238 { 239 return etat.get_state(); 240 } 241 242 public void registerAssembly(){ 243 etat.registerAssembly(); 244 } 245 246 public void 247 unregisterAssembly() 248 { 249 try{ 250 251 etat.unregisterAssembly(); 252 } 253 catch(Exception e){} 254 255 } 256 } 257
| Popular Tags
|