Import GNU Classpath (20121202).
[official-gcc.git] / libjava / classpath / org / omg / CORBA / portable / Delegate.java
blob798a1c5e8fee3b1a99a01351a18ef9d3f7b0d9f8
1 /* Delegate.java --
2 Copyright (C) 2005, 2006 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package org.omg.CORBA.portable;
41 import gnu.java.lang.CPStringBuilder;
43 import org.omg.CORBA.BAD_PARAM;
44 import org.omg.CORBA.Context;
45 import org.omg.CORBA.ContextList;
46 import org.omg.CORBA.DomainManager;
47 import org.omg.CORBA.ExceptionList;
48 import org.omg.CORBA.NO_IMPLEMENT;
49 import org.omg.CORBA.NVList;
50 import org.omg.CORBA.NamedValue;
51 import org.omg.CORBA.ORB;
52 import org.omg.CORBA.Policy;
53 import org.omg.CORBA.Request;
54 import org.omg.CORBA.SetOverrideType;
56 /**
57 * Specifies a vendor specific implementation of the
58 * {@link org.omg.CORBA.Object} methods. The calls to these
59 * methods are forwarded to the object delegate that can be
60 * replaced, if needed. The first parameter is the actual
61 * CORBA object to that the operation must be applied.
63 * Some methods in this class are not abstract, but no implemented,
64 * thowing the {@link NO_IMPLEMENT}. This, however, does not mean that
65 * they are not implemented in the derived classes as well.
67 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
69 public abstract class Delegate
71 /**
72 * Explains the reason of throwing the NO_IMPLEMENT.
74 private static final String WHY =
75 "Following 1.4 API, this Delegate method must not be implemented. Override.";
77 /**
78 * Create a request to invoke the method of this object.
80 * @param target the CORBA object, to that this operation must be applied.
81 * @param context a list of additional properties.
82 * @param operation the name of method to be invoked.
83 * @param parameters the method parameters.
84 * @param returns the container for tge method returned value.
86 * @return the created reaquest.
88 public abstract Request create_request(org.omg.CORBA.Object target,
89 Context context, String operation,
90 NVList parameters, NamedValue returns
93 /**
94 * Create a request to invoke the method of this object, specifying
95 * context list and the list of the expected exception.
97 * @param target the CORBA object, to that this operation must be applied.
98 * @param context a list of additional properties.
99 * @param operation the name of method to be invoked.
100 * @param parameters the method parameters.
101 * @param returns the container for tge method returned value.
102 * @param exceptions the list of the possible exceptions that the method
103 * can throw.
104 * @param ctx_list the list of the context strings that need to be
105 * resolved and send as a context instance.
107 * @return the created reaquest.
109 public abstract Request create_request(org.omg.CORBA.Object target,
110 Context context, String operation,
111 NVList parameters, NamedValue returns,
112 ExceptionList exceptions,
113 ContextList ctx_list
117 * Duplicate the object reference. This does not make much sense for
118 * java platform and is just included for the sake of compliance with
119 * CORBA APIs.
121 * @param target the CORBA object, to that this operation must be applied.
123 * The method may return the object reference itself.
125 * @return as a rule, <code>this</code>.
127 public abstract org.omg.CORBA.Object duplicate(org.omg.CORBA.Object target);
130 * Retrieve the domain managers for this object.
132 * @param target the CORBA object, to that this operation must be applied.
134 * @return the domain managers.
136 * @throws NO_IMPLEMENT, always (following the 1.4 specification).
138 public DomainManager[] get_domain_managers(org.omg.CORBA.Object target)
140 throw new NO_IMPLEMENT(WHY);
145 * @param target the CORBA object, to that this operation must be applied.
147 * Get the <code>InterfaceDef</code> for this Object.
149 public abstract org.omg.CORBA.Object get_interface_def(org.omg.CORBA.Object target);
152 * Returns the {@link Policy}, applying to this object.
154 * @param target the CORBA object, to that this operation must be applied.
155 * @param a_policy_type a type of policy to be obtained.
156 * @return a corresponding Policy object.
158 * @throws NO_IMPLEMENT, always (following the 1.4 specification).
160 public Policy get_policy(org.omg.CORBA.Object target, int a_policy_type)
161 throws BAD_PARAM
163 throw new NO_IMPLEMENT(WHY);
167 * Get the hashcode this object reference. The same hashcode still
168 * does not means that the references are the same. From the other
169 * side, two different references may still refer to the same CORBA
170 * object. The returned value must not change during the object
171 * lifetime.
173 * @param target the CORBA object, to that this operation must be applied.
174 * @param maximum the maximal value to return.
176 * @return the hashcode.
178 public abstract int hash(org.omg.CORBA.Object target, int maximum);
181 * Check if this object can be referenced by the given repository id.
183 * @param target the CORBA object, to that this operation must be applied.
184 * @param repositoryIdentifer the repository id.
186 * @return true if the passed parameter is a repository id of this
187 * CORBA object.
189 public abstract boolean is_a(org.omg.CORBA.Object target,
190 String repositoryIdentifer
194 * Return true if the other object references are equivalent, so far as
195 * it is possible to determine this easily.
197 * @param target the CORBA object, to that this operation must be applied.
198 * @param other the other object reference.
200 * @return true if both references refer the same object, false
201 * if they probably can refer different objects.
204 public abstract boolean is_equivalent(org.omg.CORBA.Object target,
205 org.omg.CORBA.Object other
209 * Returns true if the object is local.
211 * @param self the object to check.
213 * @return false, always (following 1.4 specs). Override to get
214 * functionality.
216 public boolean is_local(org.omg.CORBA.Object self)
218 return false;
222 * Determines if the server object for this reference has already
223 * been destroyed.
225 * @param target the CORBA object, to that this operation must be applied.
227 * @return true if the object has been destroyed, false otherwise.
229 public abstract boolean non_existent(org.omg.CORBA.Object target);
232 * Compares two objects for equality. The default implementations
233 * delegated call to {@link java.lang.Object#equals(java.lang.Object)}.
235 * @param self this CORBA object.
236 * @param other the other CORBA object.
238 * @return true if the objects are equal.
240 public boolean equals(org.omg.CORBA.Object self, java.lang.Object other)
242 return self==other;
246 * Return the hashcode for this CORBA object. The default implementation
247 * delegates call to {@link #hash(org.omg.CORBA.Object, int)}, passing Integer.MAX_VALUE as an
248 * argument.
250 * @param target the object, for that the hash code must be computed.
252 * @return the hashcode.
254 public int hashCode(org.omg.CORBA.Object target)
256 return hash(target, Integer.MAX_VALUE);
260 * Invoke the operation.
262 * @param target the invocation target.
263 * @param output the stream, containing the written arguments.
265 * @return the stream, from where the input parameters could be read.
267 * @throws ApplicationException if the application throws an exception,
268 * defined as a part of its remote method definition.
270 * @throws RemarshalException if reading(remarshalling) fails.
272 * @throws NO_IMPLEMENT, always (following the 1.4 specification).
274 public InputStream invoke(org.omg.CORBA.Object target,
275 org.omg.CORBA.portable.OutputStream output
277 throws ApplicationException, RemarshalException
279 throw new NO_IMPLEMENT(WHY);
283 * Provides the reference to ORB.
285 * @param target the object reference.
287 * @return the associated ORB.
289 * @throws NO_IMPLEMENT, always (following the 1.4 specification).
291 public ORB orb(org.omg.CORBA.Object target)
293 throw new NO_IMPLEMENT(WHY);
297 * Free resoureces, occupied by this reference. The object implementation
298 * is not notified, and the other references to the same object are not
299 * affected.
301 * @param target the CORBA object, to that this operation must be applied.
303 public abstract void release(org.omg.CORBA.Object target);
306 * Release the reply stream back to ORB after finishing reading the data
307 * from it.
309 * @param target the CORBA object, to that this operation must be applied.
310 * @param input the stream, normally returned by {@link #invoke} or
311 * {@link ApplicationException#getInputStream()}, can be null.
313 * The default method returns without action.
315 public void releaseReply(org.omg.CORBA.Object target,
316 org.omg.CORBA.portable.InputStream input
322 * Create a request to invoke the method of this CORBA object.
324 * @param target the CORBA object, to that this operation must be applied.
325 * @param operation the name of the method to invoke.
327 * @return the request.
329 public abstract Request request(org.omg.CORBA.Object target, String operation);
332 * Create a request to invoke the method of this CORBA object.
334 * @param target the CORBA object, to that this operation must be applied.
335 * @param operation the name of the method to invoke.
336 * @param response_expected specifies if this is one way message or the
337 * response to the message is expected.
339 * @return the stream where the method arguments should be written.
341 public org.omg.CORBA.portable.OutputStream request(org.omg.CORBA.Object target,
342 String operation,
343 boolean response_expected
346 throw new NO_IMPLEMENT(WHY);
350 * This method is always called after invoking the operation on the
351 * local servant.
353 * The default method returns without action.
355 * @param self the object.
356 * @param servant the servant.
358 public void servant_postinvoke(org.omg.CORBA.Object self,
359 ServantObject servant
365 * Returns a servant that should be used for this request.
366 * The servant can also be casted to the expected type, calling the
367 * required method directly.
369 * @param self the object
370 * @param operation the operation
371 * @param expectedType the expected type of the servant.
373 * This implementation always returns null; override for different
374 * behavior.
376 * @return the servant or null if the servant is not an expected type
377 * of the method is not supported, for example, due security reasons.
379 @SuppressWarnings("rawtypes") // Needed for API compatibility
380 public ServantObject servant_preinvoke(org.omg.CORBA.Object self,
381 String operation, Class expectedType
384 return null;
388 * Returns a new object with the new policies either replacing or
389 * extending the current policies, depending on the second parameter.
391 * @param target the CORBA object, to that this operation must be applied.
392 * @param policies the policy additions or replacements.
393 * @param how either {@link SetOverrideType#SET_OVERRIDE} to override the
394 * current policies of {@link SetOverrideType#ADD_OVERRIDE} to replace
395 * them.
397 * @throws NO_IMPLEMENT, always (following the 1.4 specification).
399 * @return the new reference with the changed policies.
401 public org.omg.CORBA.Object set_policy_override(org.omg.CORBA.Object target,
402 Policy[] policies,
403 SetOverrideType how
406 throw new NO_IMPLEMENT(WHY);
410 * Return a string representation of the passed object.
412 * @param self the CORBA object, to that the string representation must be
413 * returned. By default, the call is delegated to
414 * {@link java.lang.Object#toString()}.
416 * @return the string representation.
418 public String toString(org.omg.CORBA.Object self)
420 if (self instanceof ObjectImpl)
422 ObjectImpl x = (ObjectImpl) self;
423 CPStringBuilder b = new CPStringBuilder(x.getClass().getName());
424 b.append(": [");
425 for (int i = 0; i < x._ids().length; i++)
427 b.append(x._ids() [ i ]);
428 b.append(" ");
430 b.append("]");
431 return b.toString();
433 else
434 return self.getClass().getName();