diff options
author | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2005-10-15 18:21:54 +0000 |
---|---|---|
committer | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2005-10-15 18:21:54 +0000 |
commit | 6d2c440512a7a2e7d0be9d478394ec365bde1547 (patch) | |
tree | 7349536ab55f2b79e1b59193e8e768e8b6c8a8b4 | |
parent | 63686f36e6c7a0c4fe3f14cc309cb632f7124870 (diff) | |
download | classpath-6d2c440512a7a2e7d0be9d478394ec365bde1547.tar.gz |
2005-10-15 Audrius Meskauskas <AudriusA@Bioinformatics.org>
* org/omg/CORBA/DynamicImplementation.java: Made concrete.
(invoke): Implemented.
gnu/CORBA/Simple_delegate.java (request): Implemented.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | gnu/CORBA/Simple_delegate.java | 15 | ||||
-rw-r--r-- | org/omg/CORBA/DynamicImplementation.java | 111 |
3 files changed, 121 insertions, 11 deletions
@@ -1,3 +1,9 @@ +2005-10-15 Audrius Meskauskas <AudriusA@Bioinformatics.org> + + * org/omg/CORBA/DynamicImplementation.java: Made concrete. + (invoke): Implemented. + gnu/CORBA/Simple_delegate.java (request): Implemented. + 2005-10-14 Lillian Angel <langel@redhat.com> * javax/swing/plaf/basic/BasicTreeUI.java diff --git a/gnu/CORBA/Simple_delegate.java b/gnu/CORBA/Simple_delegate.java index 509ec89d2..29ec9f50d 100644 --- a/gnu/CORBA/Simple_delegate.java +++ b/gnu/CORBA/Simple_delegate.java @@ -266,12 +266,19 @@ public class Simple_delegate } /** - * This should never be called this type delegate. - * - * @throws InternalError, always. + * This method assumes that the target is local and connected to the ORB. */ public Request request(org.omg.CORBA.Object target, String operation) { - throw new InternalError(); + if (orb instanceof Functional_ORB) + { + ((Functional_ORB) orb).ensureRunning(); + } + gnuRequest g = new gnuRequest(); + g.setORB(orb); + g.setOperation(operation); + g.setIor(ior); + g.m_target = target; + return g; } }
\ No newline at end of file diff --git a/org/omg/CORBA/DynamicImplementation.java b/org/omg/CORBA/DynamicImplementation.java index 3bcf93d42..3b1b44319 100644 --- a/org/omg/CORBA/DynamicImplementation.java +++ b/org/omg/CORBA/DynamicImplementation.java @@ -38,7 +38,12 @@ exception statement from your version. */ package org.omg.CORBA; +import gnu.CORBA.Unexpected; +import gnu.CORBA.gnuAny; +import gnu.CORBA.gnuNVList; + import org.omg.CORBA.portable.ObjectImpl; +import org.omg.CORBA.portable.OutputStream; /** * This class was probably originally thinked as a base of all CORBA @@ -51,18 +56,110 @@ import org.omg.CORBA.portable.ObjectImpl; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public abstract class DynamicImplementation +public class DynamicImplementation extends ObjectImpl { /** - * Invoke the method of the CORBA object. - * + * Invoke the method of the CORBA object. After converting the parameters, + * this method delegates call to the {@link ObjectImpl#invoke}. + * * @deprecated since 1.4. - * - * @param request the container for both passing and returing the - * parameters, also contains the method name and thrown exceptions. + * + * @param request the container for both passing and returing the parameters, + * also contains the method name and thrown exceptions. */ - public abstract void invoke(ServerRequest request); + public void invoke(ServerRequest request) + { + Request r = _request(request.operation()); + + // Copy the parameters. + NVList args = new gnuNVList(); + request.arguments(args); + NamedValue v; + int i = 0; + + try + { + // Set the arguments. + for (i = 0; i < args.count(); i++) + { + v = args.item(i); + Any n; + OutputStream out; + + switch (v.flags()) + { + case ARG_IN.value: + out = v.value().create_output_stream(); + v.value().write_value(out); + n = r.add_named_in_arg(v.name()); + n.read_value(out.create_input_stream(), v.value().type()); + break; + case ARG_INOUT.value: + out = v.value().create_output_stream(); + v.value().write_value(out); + n = r.add_named_inout_arg(v.name()); + n.read_value(out.create_input_stream(), v.value().type()); + break; + case ARG_OUT.value: + r.add_named_out_arg(v.name()); + break; + + default: + throw new InternalError("Invalid flags " + v.flags()); + } + } + } + catch (Bounds b) + { + throw new Unexpected(args.count() + "[" + i + "]", b); + } + + // Set context. + r.ctx(request.ctx()); + + // Set the return type (expects that the ServerRequest will initialise + // the passed Any. + + gnuAny g = new gnuAny(); + request.result(g); + r.set_return_type(g.type()); + + // Invoke the method. + r.invoke(); + + // Transfer the returned values. + NVList r_args = r.arguments(); + + try + { + // API states that the ServerRequest.arguments must be called only + // once. Hence we assume we can just modify the previously returned + // value <code>args</code>, and the ServerRequest will preserve the + // reference. + for (i = 0; i < args.count(); i++) + { + v = args.item(i); + + if (v.flags() == ARG_OUT.value || v.flags() == ARG_INOUT.value) + { + OutputStream out = r_args.item(i).value().create_output_stream(); + r_args.item(i).value().write_value(out); + v.value().read_value(out.create_input_stream(), + v.value().type()); + } + } + } + catch (Bounds b) + { + throw new Unexpected(args.count() + "[" + i + "]", b); + } + + // Set the returned result (if any). + NamedValue returns = r.result(); + if (returns != null) + request.set_result(returns.value()); + } /** * Returns the array of the repository ids, supported by this object. |