1 21 package org.jacorb.orb.portableInterceptor; 22 23 import org.omg.PortableInterceptor.*; 24 import org.omg.IOP.*; 25 import org.omg.CORBA.*; 26 import org.omg.ETF.Profile; 27 28 import org.jacorb.orb.ORB; 29 import org.jacorb.orb.MinorCodes; 30 import org.jacorb.orb.TaggedComponentList; 31 import org.jacorb.poa.POA; 32 33 import java.util.*; 34 35 43 44 public class IORInfoImpl extends org.omg.CORBA.LocalObject 45 implements IORInfoExt 46 { 47 50 private Map components = null; 51 52 private Map policy_overrides = null; 53 54 private ORB orb = null; 55 private POA poa = null; 56 private List _profiles = null; 57 58 public IORInfoImpl (ORB orb, POA poa, 59 Map components, Map policy_overrides, 60 List profiles) 61 { 62 this.orb = orb; 63 this.poa = poa; 64 this.components = components; 65 this.policy_overrides = policy_overrides; 66 this._profiles = profiles; 67 } 68 69 72 public void add_ior_component (TaggedComponent component) 73 { 74 for (Iterator i = components.values().iterator(); i.hasNext();) 75 { 76 TaggedComponentList l = (TaggedComponentList)i.next(); 77 l.addComponent (component); 78 } 79 } 80 81 84 public void add_ior_component_to_profile(TaggedComponent component, int id) 85 { 86 TaggedComponentList l = 87 (TaggedComponentList)components.get (new Integer (id)); 88 if (l == null) 89 { 90 throw new org.omg.CORBA.BAD_PARAM 91 ( 92 "unknown profile tag: " + id, 93 MinorCodes.NO_SUCH_PROFILE, 94 CompletionStatus.COMPLETED_MAYBE 95 ); 96 } 97 else 98 { 99 l.addComponent (component); 100 } 101 } 102 103 107 public Policy get_effective_policy(int type) 108 { 109 if (!orb.hasPolicyFactoryForType(type)) 110 { 111 throw new org.omg.CORBA.INV_POLICY 112 ( 113 "No PolicyFactory for type " + type + 114 " has been registered!", 115 MinorCodes.NO_SUCH_POLICY, 116 CompletionStatus.COMPLETED_MAYBE 117 ); 118 } 119 else 120 { 121 Policy policy = null; 122 if (policy_overrides != null) 123 { 124 policy = (Policy)policy_overrides.get (new Integer (type)); 125 } 126 return (policy != null) ? policy : poa.getPolicy(type); 127 } 128 } 129 130 137 public void add_profile(Profile profile) 138 { 139 if( _profiles != null ) 140 { 141 _profiles.add(profile); 142 } 143 144 } 145 146 153 public int get_number_of_profiles(int tag) 154 { 155 int retVal = 0; 156 for (int i=0; i < _profiles.size(); i++) 157 { 158 Profile p = (Profile) _profiles.get(i); 159 if ( p.tag() == tag ) 160 retVal++; 161 } 162 return retVal; 163 } 164 165 175 public org.omg.ETF.Profile get_profile(int tag, int position) 176 { 177 int cnt = position; 178 Profile retVal = null; 179 for (int i=0; i < _profiles.size(); i++) 180 { 181 Profile p = (Profile) _profiles.get(i); 182 if ( p.tag() == tag && cnt == 0) 183 { 184 retVal = p; 185 break; 186 } 187 else 188 { 189 cnt--; 190 } 191 } 192 if( retVal == null ) 193 throw new ArrayIndexOutOfBoundsException ("no profile with tag=" + tag + " at position" + position); 194 195 return retVal; 196 } 197 198 205 public org.omg.ETF.Profile get_profile(int tag) 206 { 207 Profile retVal = null; 208 for (int i=0; i < _profiles.size(); i++) 209 { 210 Profile p = (Profile) _profiles.get(i); 211 if ( p.tag() == tag ) 212 { 213 retVal = p; 214 break; 215 } 216 } 217 return retVal; 218 219 } 220 221 } 222 223 224 225 226 227 228 | Popular Tags |