1 28 29 30 package org.objectweb.ccm.runtime; 31 32 import org.objectweb.corba.runtime.*; 33 34 37 public class ServicesSetImpl 38 extends org.omg.CORBA.LocalObject 39 implements ServicesSet 40 { 41 static final private String _class_name = "ServicesSetImpl"; 43 private ServiceImpl[] _services; 44 private CORBAServiceRef[] _degen_services; 45 private ORBService _orb_service; 46 47 public 49 ServicesSetImpl(ServiceImpl[] services, 50 CORBAServiceRef[] dservices, 51 ORBService orbs) 52 { 53 _services = services; 55 _degen_services = dservices; 56 _orb_service = orbs; 57 } 58 59 63 private ServiceImpl 64 findServiceById(String sid) 65 { 66 ServiceImpl[] services = _services; 67 for (int i=0;i<services.length;i++) { 68 if (services[i].service_id().equals(sid)) { 69 return services[i]; 70 } 71 } 72 73 return null; 74 } 75 76 private PolicyImpl[] 77 asPolicies(org.coach.ECM.CCDPolicyRef[] prefs) 78 { 79 ServiceImpl service = null; 81 PolicyImpl[] pols = new PolicyImpl[prefs.length]; 82 for (int i=0;i<prefs.length;i++) { 83 service = findServiceById(prefs[i].service_id); 85 86 if (service==null) { 88 final String opname = "asPolicies"; 89 final String msg = "FAILED (service not found: "+prefs[i].service_id+")"; 90 TheLogger.error(_class_name, opname, msg); 91 return null; 92 } 93 94 pols[i] = (PolicyImpl)service.create_policy(prefs[i].policyref, prefs[i].policyvalue); 96 } 97 98 return pols; 99 } 100 101 105 final public Service 106 find_service(String sid) 107 { 108 return findServiceById(sid); 109 } 110 111 final public org.omg.CORBA.Object 112 find_degenerated_service(String regname) 113 { 114 org.omg.CORBA.Object ref = _orb_service.resolve_initial_references(regname); 116 117 CORBAServiceRef[] dservices = _degen_services; 119 boolean isds = false; 120 for (int i=0;i<dservices.length;i++) { 121 if (dservices[i].orb_registration_name.equals(regname)) { 122 isds = true; 123 break; 124 } 125 } 126 127 if (isds) { 128 return ref; 130 } 131 132 final String opname = "find_degenerated_service"; 133 final String msg = "regname is not a degenerated service: "+regname; 134 TheLogger.debug(_class_name, opname, msg); 135 136 return null; 137 } 138 139 final public Policy[] 140 get_policies(String uuid, String sname) 141 { 142 org.omg.CORBA.Object ref = null; 144 org.coach.ECM.ExtComponentInstallation extci = null; 145 146 ref = _orb_service.resolve_initial_references("ExtComponentInstallation"); 147 extci = org.coach.ECM.ExtComponentInstallationHelper.narrow(ref); 148 149 org.coach.ECM.ComponentArchive carch = extci.get_component_archive(uuid); 151 152 org.coach.ECM.CCDPolicyRef[] prefs = carch.get_policies_for_target(sname); 154 155 return asPolicies(prefs); 157 } 158 } | Popular Tags |