1 28 29 30 package org.objectweb.ccm.runtime; 31 32 import org.objectweb.corba.runtime.*; 33 34 37 public class ComponentArchiveImpl 38 extends ArchiveServantBase 39 implements Servant, org.coach.ECM.ComponentArchiveOperations 40 { 41 static final private String _class_name = "ComponentArchiveImpl"; 43 44 static final private String _type_id = org.coach.ECM.ComponentArchiveHelper.id(); 46 47 private ORBService _orb_service; 49 private String _uuid; 50 private String _archive_location; 51 private String _dtd_location; 52 53 private ExtComponentInstallationImpl _extci; 55 private String _code_location; 56 private String _code_entrypoint; 57 private String _csd_location; 58 private String _ccd_location; 59 private String _home_repid; 60 private String _component_repid; 61 private org.coach.ECM.ValuetypeFactoryDependency[] _valuefactories; 62 private java.util.HashMap _sname2policies; 63 64 public 65 ComponentArchiveImpl(ExtComponentInstallationImpl extci, 66 ORBService orbs, 67 String dtdloc, 68 String uuid, 69 String loc) 70 { 71 super(uuid, loc); 72 73 _orb_service = orbs; 75 _uuid = uuid; 76 _archive_location = loc; 77 _dtd_location = dtdloc; 78 79 _extci = extci; 81 _code_location = null; 82 _code_entrypoint = null; 83 _csd_location = null; 84 _ccd_location = null; 85 _home_repid = null; 86 _component_repid = null; 87 _valuefactories = new org.coach.ECM.ValuetypeFactoryDependency[0]; 88 _sname2policies = new java.util.HashMap (); 89 } 90 91 95 final protected ORBService 96 getORBService() 97 { 98 return _orb_service; 99 } 100 101 105 private void 106 initializeInternalFields() 107 { 108 final String opname = "initializeInternalFields"; 109 java.util.zip.ZipFile zip = openZip(); 111 112 java.util.Enumeration entries = zip.entries(); 114 java.util.zip.ZipEntry entry = null; 115 java.util.zip.ZipEntry csdentry = null; 116 while (entries.hasMoreElements()) { 117 entry = (java.util.zip.ZipEntry )entries.nextElement(); 118 if (entry.getName().endsWith(".csd")) { 119 csdentry = entry; 120 } 121 } 122 123 if (csdentry==null) { 125 final String msg = "FAILED (no CSD found in "+_uuid+")"; 127 TheLogger.error(_class_name, opname, msg); 128 return ; 129 } 130 131 String csdfname = extractFile(zip, csdentry); 133 _csd_location = csdfname; 134 135 CSDParser csdparser = CSDParser.parse(_csd_location, _dtd_location, _uuid); 137 138 _code_entrypoint = csdparser.code_entrypoint; 140 141 _valuefactories = (org.coach.ECM.ValuetypeFactoryDependency[])csdparser.valuetype_factories.toArray(new org.coach.ECM.ValuetypeFactoryDependency[0]); 143 144 entries = zip.entries(); 146 java.util.zip.ZipEntry ccdentry = null; 147 java.util.zip.ZipEntry codelocentry = null; 148 String ccdname = csdparser.descriptor_location; 149 String codeloc = csdparser.code_location; 150 while (entries.hasMoreElements()) { 151 entry = (java.util.zip.ZipEntry )entries.nextElement(); 152 if (entry.getName().equals(ccdname)) { 153 ccdentry = entry; 154 } 155 else if (entry.getName().equals(codeloc)) { 156 codelocentry = entry; 157 } 158 } 159 160 if (codelocentry==null) { 162 final String msg = "FAILED (no code library found in "+_uuid+")"; 164 TheLogger.error(_class_name, opname, msg); 165 return ; 166 } 167 168 String codelocfname = extractFile(zip, codelocentry); 170 _code_location = codelocfname; 171 172 if (ccdentry==null) { 174 final String msg = "FAILED (CCD file not found in "+_uuid+")"; 176 TheLogger.error(_class_name, opname, msg); 177 return ; 178 } 179 180 String ccdfname = extractFile(zip, ccdentry); 182 _ccd_location = ccdfname; 183 184 CCDParser ccdparser = CCDParser.parse(_ccd_location, _dtd_location, _extci); 186 _home_repid = ccdparser.home_repid; 187 _component_repid = ccdparser.component_repid; 188 _sname2policies = ccdparser.sname2policies; 189 190 195 try { 197 zip.close(); 198 } catch(java.io.IOException ex) { 199 TheLogger.error(_class_name, opname, "IGNORE", ex); 202 } 203 } 204 205 private void 206 updatePolicyList(java.util.ArrayList list, org.coach.ECM.CCDPolicyRef[] pols) 207 { 208 for (int i=0;i<pols.length;i++) { 210 org.coach.ECM.CCDPolicyRef pol = null; 212 String sid = pols[i].service_id; 213 boolean found = false; 214 for (int j=0;j<list.size();j++) { 215 pol = (org.coach.ECM.CCDPolicyRef)list.get(j); 216 if (sid.equals(pol.service_id)) { 217 found = true; 218 break; 219 } 220 221 } 222 223 if (!found) { 224 list.add(pols[i]); 226 } 227 } 228 } 229 230 234 final public void 235 system_configuration_complete(SystemConfiguration cfg) 236 { 237 initializeInternalFields(); 239 } 240 241 final public void 242 destroy() 243 { 244 } 246 247 251 final public String 252 type_id() 253 { 254 return _type_id; 255 } 256 257 final public org.omg.PortableServer.Servant 258 as_native_servant() 259 { 260 return new org.coach.ECM.ComponentArchivePOATie(this); 261 } 262 263 267 273 277 final public String 278 csd_location() 279 { 280 return _csd_location; 281 } 282 283 final public String 284 ccd_location() 285 { 286 return _ccd_location; 287 } 288 289 final public String 290 code_location() 291 { 292 return _code_location; 293 } 294 295 final public String 296 code_entrypoint() 297 { 298 return _code_entrypoint; 299 } 300 301 final public String 302 home_repid() 303 { 304 return _home_repid; 305 } 306 307 final public String 308 component_repid() 309 { 310 return _component_repid; 311 } 312 313 final public org.coach.ECM.ValuetypeFactoryDependency[] 314 get_valuetype_factories() 315 { 316 return _valuefactories; 317 } 318 319 final public org.coach.ECM.CCDPolicyRef[] 320 get_policies_for_target(String sname) 321 { 322 final String opname = "get_policies_for_target"; 323 String msg = "scoped name: "+sname; 324 TheLogger.debug(_class_name, opname, msg); 325 326 335 339 java.util.ArrayList res = new java.util.ArrayList (); 340 java.util.ArrayList starres = new java.util.ArrayList (); 341 342 org.coach.ECM.CCDPolicyRef[] prefs = null; 343 int idx = sname.lastIndexOf(':'); 344 String name = sname.substring(idx+1, sname.length()); 346 String pname = sname.substring(0, idx-1); 348 349 prefs = (org.coach.ECM.CCDPolicyRef[])_sname2policies.get(sname); 353 if (prefs!=null) { 354 res.addAll(java.util.Arrays.asList(prefs)); 355 } 356 357 String starname = pname+"::*"; 359 360 363 prefs = (org.coach.ECM.CCDPolicyRef[])_sname2policies.get(starname); 364 if (prefs!=null) { 365 starres.addAll(java.util.Arrays.asList(prefs)); 366 } 367 368 if (name.charAt(0)=='_') { 371 if (name.startsWith("_get_")) { 372 String attrname = pname+"::"+name.substring(5, name.length()); 374 375 378 prefs = (org.coach.ECM.CCDPolicyRef[])_sname2policies.get(attrname); 379 if (prefs!=null) { 380 updatePolicyList(res, prefs); 381 } 382 383 String attrstarname = pname+"::_get_*"; 385 386 389 prefs = (org.coach.ECM.CCDPolicyRef[])_sname2policies.get(attrstarname); 390 if (prefs!=null) { 391 updatePolicyList(starres, prefs); 392 } 393 } 394 else if (name.startsWith("_set_")) { 395 String attrname = pname+"::"+name.substring(5, name.length()); 397 398 401 prefs = (org.coach.ECM.CCDPolicyRef[])_sname2policies.get(attrname); 402 if (prefs!=null) { 403 updatePolicyList(res, prefs); 404 } 405 406 String attrstarname = pname+"::_set_*"; 408 409 412 prefs = (org.coach.ECM.CCDPolicyRef[])_sname2policies.get(attrstarname); 413 if (prefs!=null) { 414 updatePolicyList(starres, prefs); 415 } 416 } 417 } 418 419 org.coach.ECM.CCDPolicyRef[] starprefs = (org.coach.ECM.CCDPolicyRef[])starres.toArray(new org.coach.ECM.CCDPolicyRef[0]); 421 updatePolicyList(res, starprefs); 422 423 prefs = (org.coach.ECM.CCDPolicyRef[])res.toArray(new org.coach.ECM.CCDPolicyRef[0]); 424 425 if (prefs.length==0) { 426 TheLogger.debug(_class_name, opname, "no policy found"); 427 } else { 428 msg = "#"+prefs.length+" policies found"; 429 TheLogger.debug(_class_name, opname, msg); 430 for (int i=0;i<prefs.length;i++) { 431 msg = "#"+i+": "+prefs[i].service_id+" / "+prefs[i].policyref; 432 TheLogger.debug(_class_name, opname, msg); 433 } 434 } 435 436 return prefs; 437 } 438 439 final public String 440 exec_xpath_request_in_csd(String req) 441 { 442 final String opname = "exec_xpath_request_in_csd"; 443 final String msg = "FAILED (not implemented, rethrown)"; 444 TheLogger.debug(_class_name, opname, msg); 445 446 throw new org.omg.CORBA.NO_IMPLEMENT (); 447 } 448 449 final public String 450 exec_xpath_request_in_ccd(String req) 451 { 452 final String opname = "exec_xpath_request_in_ccd"; 453 final String msg = "FAILED (not implemented, rethrown)"; 454 TheLogger.debug(_class_name, opname, msg); 455 456 throw new org.omg.CORBA.NO_IMPLEMENT (); 457 } 458 } 459 | Popular Tags |