| 1 |
775 |
jeremybenn |
/* DynamicImplementation.java --
|
| 2 |
|
|
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
| 3 |
|
|
|
| 4 |
|
|
This file is part of GNU Classpath.
|
| 5 |
|
|
|
| 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.
|
| 10 |
|
|
|
| 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.
|
| 15 |
|
|
|
| 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.
|
| 20 |
|
|
|
| 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.
|
| 25 |
|
|
|
| 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. */
|
| 37 |
|
|
|
| 38 |
|
|
|
| 39 |
|
|
package org.omg.CORBA;
|
| 40 |
|
|
|
| 41 |
|
|
import gnu.CORBA.Unexpected;
|
| 42 |
|
|
import gnu.CORBA.gnuAny;
|
| 43 |
|
|
import gnu.CORBA.gnuNVList;
|
| 44 |
|
|
|
| 45 |
|
|
import org.omg.CORBA.portable.ObjectImpl;
|
| 46 |
|
|
import org.omg.CORBA.portable.OutputStream;
|
| 47 |
|
|
|
| 48 |
|
|
/**
|
| 49 |
|
|
* This class was probably originally thinked as a base of all CORBA
|
| 50 |
|
|
* object implementations. However the code, generated by IDL to
|
| 51 |
|
|
* java compilers almost never use it, preferring to derive the
|
| 52 |
|
|
* object implementation bases directly from the {@link ObjectImpl}.
|
| 53 |
|
|
* The class has become deprecated since the 1.4 release.
|
| 54 |
|
|
*
|
| 55 |
|
|
* @deprecated since 1.4.
|
| 56 |
|
|
*
|
| 57 |
|
|
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
|
| 58 |
|
|
*/
|
| 59 |
|
|
public class DynamicImplementation
|
| 60 |
|
|
extends ObjectImpl
|
| 61 |
|
|
{
|
| 62 |
|
|
/**
|
| 63 |
|
|
* Invoke the method of the CORBA object. After converting the parameters,
|
| 64 |
|
|
* this method delegates call to the {@link ObjectImpl#_invoke}.
|
| 65 |
|
|
*
|
| 66 |
|
|
* @deprecated since 1.4.
|
| 67 |
|
|
*
|
| 68 |
|
|
* @param request the container for both passing and returing the parameters,
|
| 69 |
|
|
* also contains the method name and thrown exceptions.
|
| 70 |
|
|
*/
|
| 71 |
|
|
public void invoke(ServerRequest request)
|
| 72 |
|
|
{
|
| 73 |
|
|
Request r = _request(request.operation());
|
| 74 |
|
|
|
| 75 |
|
|
// Copy the parameters.
|
| 76 |
|
|
NVList args = new gnuNVList();
|
| 77 |
|
|
request.arguments(args);
|
| 78 |
|
|
NamedValue v;
|
| 79 |
|
|
int i = 0;
|
| 80 |
|
|
|
| 81 |
|
|
try
|
| 82 |
|
|
{
|
| 83 |
|
|
// Set the arguments.
|
| 84 |
|
|
for (i = 0; i < args.count(); i++)
|
| 85 |
|
|
{
|
| 86 |
|
|
v = args.item(i);
|
| 87 |
|
|
Any n;
|
| 88 |
|
|
OutputStream out;
|
| 89 |
|
|
|
| 90 |
|
|
switch (v.flags())
|
| 91 |
|
|
{
|
| 92 |
|
|
case ARG_IN.value:
|
| 93 |
|
|
out = v.value().create_output_stream();
|
| 94 |
|
|
v.value().write_value(out);
|
| 95 |
|
|
n = r.add_named_in_arg(v.name());
|
| 96 |
|
|
n.read_value(out.create_input_stream(), v.value().type());
|
| 97 |
|
|
break;
|
| 98 |
|
|
case ARG_INOUT.value:
|
| 99 |
|
|
out = v.value().create_output_stream();
|
| 100 |
|
|
v.value().write_value(out);
|
| 101 |
|
|
n = r.add_named_inout_arg(v.name());
|
| 102 |
|
|
n.read_value(out.create_input_stream(), v.value().type());
|
| 103 |
|
|
break;
|
| 104 |
|
|
case ARG_OUT.value:
|
| 105 |
|
|
r.add_named_out_arg(v.name());
|
| 106 |
|
|
break;
|
| 107 |
|
|
|
| 108 |
|
|
default:
|
| 109 |
|
|
throw new InternalError("Invalid flags " + v.flags());
|
| 110 |
|
|
}
|
| 111 |
|
|
}
|
| 112 |
|
|
}
|
| 113 |
|
|
catch (Bounds b)
|
| 114 |
|
|
{
|
| 115 |
|
|
throw new Unexpected(args.count() + "[" + i + "]", b);
|
| 116 |
|
|
}
|
| 117 |
|
|
|
| 118 |
|
|
// Set context.
|
| 119 |
|
|
r.ctx(request.ctx());
|
| 120 |
|
|
|
| 121 |
|
|
// Set the return type (expects that the ServerRequest will initialise
|
| 122 |
|
|
// the passed Any.
|
| 123 |
|
|
|
| 124 |
|
|
gnuAny g = new gnuAny();
|
| 125 |
|
|
request.result(g);
|
| 126 |
|
|
r.set_return_type(g.type());
|
| 127 |
|
|
|
| 128 |
|
|
// Invoke the method.
|
| 129 |
|
|
r.invoke();
|
| 130 |
|
|
|
| 131 |
|
|
// Transfer the returned values.
|
| 132 |
|
|
NVList r_args = r.arguments();
|
| 133 |
|
|
|
| 134 |
|
|
try
|
| 135 |
|
|
{
|
| 136 |
|
|
// API states that the ServerRequest.arguments must be called only
|
| 137 |
|
|
// once. Hence we assume we can just modify the previously returned
|
| 138 |
|
|
// value <code>args</code>, and the ServerRequest will preserve the
|
| 139 |
|
|
// reference.
|
| 140 |
|
|
for (i = 0; i < args.count(); i++)
|
| 141 |
|
|
{
|
| 142 |
|
|
v = args.item(i);
|
| 143 |
|
|
|
| 144 |
|
|
if (v.flags() == ARG_OUT.value || v.flags() == ARG_INOUT.value)
|
| 145 |
|
|
{
|
| 146 |
|
|
OutputStream out = r_args.item(i).value().create_output_stream();
|
| 147 |
|
|
r_args.item(i).value().write_value(out);
|
| 148 |
|
|
v.value().read_value(out.create_input_stream(),
|
| 149 |
|
|
v.value().type());
|
| 150 |
|
|
}
|
| 151 |
|
|
}
|
| 152 |
|
|
}
|
| 153 |
|
|
catch (Bounds b)
|
| 154 |
|
|
{
|
| 155 |
|
|
throw new Unexpected(args.count() + "[" + i + "]", b);
|
| 156 |
|
|
}
|
| 157 |
|
|
|
| 158 |
|
|
// Set the returned result (if any).
|
| 159 |
|
|
NamedValue returns = r.result();
|
| 160 |
|
|
if (returns != null)
|
| 161 |
|
|
request.set_result(returns.value());
|
| 162 |
|
|
}
|
| 163 |
|
|
|
| 164 |
|
|
/**
|
| 165 |
|
|
* Returns the array of the repository ids, supported by this object.
|
| 166 |
|
|
* In this implementation, the method must be overrridden to return
|
| 167 |
|
|
* a sendible object-specific information. The default method returns
|
| 168 |
|
|
* an empty array.
|
| 169 |
|
|
*
|
| 170 |
|
|
* @deprecated since 1.4.
|
| 171 |
|
|
*
|
| 172 |
|
|
* @return the empty array, always.
|
| 173 |
|
|
*/
|
| 174 |
|
|
public String[] _ids()
|
| 175 |
|
|
{
|
| 176 |
|
|
return new String[ 0 ];
|
| 177 |
|
|
}
|
| 178 |
|
|
}
|