1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51:
52: import ;
53: import ;
54: import ;
55: import ;
56: import ;
57: import ;
58: import ;
59: import ;
60: import ;
61: import ;
62: import ;
63: import ;
64:
65: import ;
66: import ;
67:
68:
73: public class ORB_1_4
74: extends OrbFunctional
75: {
76:
79: public final gnuPOA rootPOA;
80:
81:
84: public gnuPoaCurrent currents = new gnuPoaCurrent();
85:
86:
89: public gnuIcCurrent ic_current = new gnuIcCurrent(this);
90:
91:
94: public gnuDynAnyFactory factory = new gnuDynAnyFactory(this);
95:
96:
100: public ORB_1_4()
101: {
102: super();
103: try
104: {
105: rootPOA = new gnuPOA(null, "RootPOA", null, StandardPolicies.rootPoa(), this);
106: }
107: catch (InvalidPolicy ex)
108: {
109:
110: InternalError ierr = new InternalError();
111: ierr.initCause(ex);
112: throw ierr;
113: }
114: initial_references.put("RootPOA", rootPOA);
115: initial_references.put("RootPOAManager", rootPOA.the_POAManager());
116: initial_references.put("POACurrent", currents);
117: initial_references.put("DynAnyFactory", factory);
118: initial_references.put("PICurrent", ic_current);
119: }
120:
121:
125: public String object_to_string(org.omg.CORBA.Object forObject)
126: {
127: try
128: {
129: return super.object_to_string(forObject);
130: }
131: catch (Exception ex)
132: {
133: try
134: {
135: AOM.Obj exists = rootPOA.findObject(forObject);
136: if (exists == null)
137: throw new OBJECT_NOT_EXIST(forObject == null ? "null"
138: : forObject.toString());
139: else if (exists.poa instanceof gnuPOA)
140: ((gnuPOA) exists.poa).connect_to_orb(exists.key, forObject);
141: else
142: exists.poa.create_reference_with_id(exists.key,
143: ((ObjectImpl) exists.object)._ids()[0]);
144: }
145: catch (Exception bex)
146: {
147: BAD_PARAM bad = new BAD_PARAM("Unable to activate " + forObject);
148: bad.initCause(bex);
149: throw bad;
150: }
151:
152: return super.object_to_string(forObject);
153: }
154: }
155:
156:
159: public void destroy()
160: {
161:
162: rootPOA.destroy(true, false);
163:
164: super.destroy();
165: }
166:
167:
175: protected void registerInterceptors(Properties properties, String[] args)
176: {
177: Registrator registrator = new Registrator(this, properties, args);
178:
179: policyFactories = registrator.m_policyFactories;
180:
181: registrator.pre_init();
182: initial_references.putAll(registrator.getRegisteredReferences());
183: registrator.post_init();
184:
185: if (registrator.hasIorInterceptors())
186: iIor = new IORInterceptors(registrator);
187:
188: if (registrator.hasServerRequestInterceptors())
189: iServer = new ServerRequestInterceptors(registrator);
190:
191: if (registrator.hasClientRequestInterceptors())
192: iClient = new ClientRequestInterceptors(registrator);
193:
194: policyFactories = registrator.m_policyFactories;
195: }
196:
197:
200: protected IOR createIOR(cObject ref)
201: throws BAD_OPERATION
202: {
203: IOR ior = super.createIOR(ref);
204: if (iIor != null)
205: {
206: AOM.Obj obj = rootPOA.findIorKey(ior.key);
207:
208: gnuPOA poa;
209:
210:
211: if (obj == null)
212: poa = rootPOA;
213: else
214: poa = obj.poa;
215:
216: gnuIorInfo info = new gnuIorInfo(this, poa, ior);
217:
218:
219: iIor.establish_components(info);
220: iIor.components_established(info);
221: }
222: return ior;
223: }
224:
225:
228: public Policy create_policy(int type, Any value)
229: throws PolicyError
230: {
231: Integer policy = new Integer(type);
232:
233: PolicyFactory forge = (PolicyFactory) policyFactories.get(policy);
234: if (forge == null)
235: throw new PolicyError("No factory registered for policy " + type,
236: (short) type);
237: else
238: return forge.create_policy(type, value);
239: }
240:
241:
244: protected void set_parameters(Applet app, Properties props)
245: {
246: super.set_parameters(app, props);
247: registerInterceptors(props, new String[0]);
248: }
249:
250:
253: protected void set_parameters(String[] para, Properties props)
254: {
255: super.set_parameters(para, props);
256: registerInterceptors(props, para);
257: }
258:
259:
266: public void set_delegate(java.lang.Object wrapper)
267: {
268: if (wrapper instanceof org.omg.CORBA.Object)
269: {
270: org.omg.CORBA.Object object = (org.omg.CORBA.Object) wrapper;
271: if (connected_objects.getKey(object) == null)
272: connect(object);
273: }
274: else if (wrapper instanceof Servant)
275: {
276: Servant s = (Servant) wrapper;
277: if (rootPOA.findServant(s) == null)
278: try
279: {
280: rootPOA.servant_to_reference(s);
281: if (rootPOA.the_POAManager().get_state().value() == State._HOLDING)
282: rootPOA.the_POAManager().activate();
283: }
284: catch (Exception e)
285: {
286: BAD_OPERATION bad = new BAD_OPERATION("Unable to connect "
287: + wrapper + " to " + this);
288: throw bad;
289: }
290: }
291: }
292:
293: }