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:
60: public class SimpleDelegate
61: extends Delegate
62: implements IorProvider
63: {
64:
67: protected final ORB orb;
68:
69:
72: protected IOR ior;
73:
74: public SimpleDelegate(ORB an_orb, IOR an_ior)
75: {
76: orb = an_orb;
77: ior = an_ior;
78: }
79:
80:
87: public void setIor(IOR an_ior)
88: {
89: this.ior = an_ior;
90: }
91:
92:
95: public IOR getIor()
96: {
97: return ior;
98: }
99:
100:
103: public Request create_request(org.omg.CORBA.Object target, Context context,
104: String operation, NVList parameters,
105: NamedValue returns
106: )
107: {
108: if (orb instanceof OrbFunctional)
109: {
110: ((OrbFunctional) orb).ensureRunning();
111: }
112: gnuRequest g = new gnuRequest();
113: g.setORB(orb);
114: g.setOperation(operation);
115: g.setIor(ior);
116: g.m_target = target;
117: g.ctx(context);
118: g.set_args(parameters);
119: if (returns != null)
120: g.set_result(returns);
121: return g;
122: }
123:
124:
127: public Request create_request(org.omg.CORBA.Object target, Context context,
128: String operation, NVList parameters,
129: NamedValue returns, ExceptionList exceptions,
130: ContextList ctx_list
131: )
132: {
133: if (orb instanceof OrbFunctional)
134: {
135: ((OrbFunctional) orb).ensureRunning();
136: }
137: gnuRequest g = new gnuRequest();
138: g.setORB(orb);
139: g.setOperation(operation);
140: g.setIor(ior);
141: g.m_target = target;
142: g.ctx(context);
143: g.set_args(parameters);
144: g.set_exceptions(exceptions);
145: g.set_context_list(ctx_list);
146: if (returns != null)
147: g.set_result(returns);
148: return g;
149: }
150:
151:
156: public org.omg.CORBA.Object duplicate(org.omg.CORBA.Object target)
157: {
158: throw new NO_IMPLEMENT();
159: }
160:
161:
164: public boolean equals(org.omg.CORBA.Object self, org.omg.CORBA.Object other)
165: {
166: return self == other;
167: }
168:
169:
174: public org.omg.CORBA.Object get_interface_def(org.omg.CORBA.Object target)
175: {
176: throw new NO_IMPLEMENT();
177: }
178:
179:
182: public int hash(org.omg.CORBA.Object target, int maximum)
183: {
184: return target == null ? 0 : target.hashCode() % maximum;
185: }
186:
187:
190: public int hashCode(org.omg.CORBA.Object target)
191: {
192: return target == null ? 0 : target.hashCode();
193: }
194:
195:
206: public boolean is_a(org.omg.CORBA.Object target, String repositoryIdentifer)
207: {
208: if (!(target instanceof ObjectImpl))
209: throw new NO_IMPLEMENT("Supported only for org.omg.CORBA.portable.ObjectImpl");
210:
211: ObjectImpl imp = (ObjectImpl) target;
212: String[] ids = imp._ids();
213:
214: for (int i = 0; i < ids.length; i++)
215: {
216: if (ids [ i ].equals(repositoryIdentifer))
217: return true;
218: }
219: return false;
220: }
221:
222:
226: public boolean is_equivalent(org.omg.CORBA.Object target,
227: org.omg.CORBA.Object other)
228: {
229: if (target == other)
230: return true;
231: if ((target instanceof ObjectImpl) && other instanceof ObjectImpl)
232: {
233: try
234: {
235: org.omg.CORBA.portable.Delegate a = ((ObjectImpl) target)._get_delegate();
236: org.omg.CORBA.portable.Delegate b = ((ObjectImpl) other)._get_delegate();
237: if (a == b)
238: {
239: return true;
240: }
241: else
242: {
243:
244: if (a instanceof IorProvider && b instanceof IorProvider)
245: {
246: IOR ia = ((IorProvider) a).getIor();
247: IOR ib = ((IorProvider) b).getIor();
248:
249: if (ia != null && ib != null)
250: return (ia.equals(ib));
251: else
252: return ia == ib;
253: }
254: }
255: if (a != null && b != null)
256: {
257: return a.equals(b);
258: }
259: }
260: catch (Exception ex)
261: {
262:
263: return false;
264: }
265: }
266: return false;
267: }
268:
269:
272: public boolean is_local(org.omg.CORBA.Object self)
273: {
274: return true;
275: }
276:
277:
280: public boolean non_existent(org.omg.CORBA.Object target)
281: {
282: return target == null;
283: }
284:
285:
290: public ORB orb(org.omg.CORBA.Object target)
291: {
292: return orb;
293: }
294:
295:
298: public void release(org.omg.CORBA.Object target)
299: {
300: }
301:
302:
305: public Request request(org.omg.CORBA.Object target, String operation)
306: {
307: if (orb instanceof OrbFunctional)
308: {
309: ((OrbFunctional) orb).ensureRunning();
310: }
311: gnuRequest g = new gnuRequest();
312: g.setORB(orb);
313: g.setOperation(operation);
314: g.setIor(ior);
315: g.m_target = target;
316: return g;
317: }
318: }