/[classpath]/classpath/org/omg/CORBA/DynamicImplementation.java
ViewVC logotype

Diff of /classpath/org/omg/CORBA/DynamicImplementation.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.2 by gnu_andrew, Tue Aug 2 20:12:45 2005 UTC revision 1.1.2.3 by gnu_andrew, Wed Nov 2 00:44:09 2005 UTC
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package org.omg.CORBA;  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;  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   * This class was probably originally thinked as a base of all CORBA
# Line 51  import org.omg.CORBA.portable.ObjectImpl Line 56  import org.omg.CORBA.portable.ObjectImpl
56   *   *
57   * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)   * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
58   */   */
59  public abstract class DynamicImplementation  public class DynamicImplementation
60    extends ObjectImpl    extends ObjectImpl
61  {  {
62    /**    /**
63     * Invoke the method of the CORBA object.     * 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.     * @deprecated since 1.4.
67     *     *
68     * @param request the container for both passing and returing the     * @param request the container for both passing and returing the parameters,
69     * parameters, also contains the method name and thrown exceptions.     * also contains the method name and thrown exceptions.
70     */     */
71    public abstract void invoke(ServerRequest request);    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.     * Returns the array of the repository ids, supported by this object.

Legend:
Removed from v.1.1.2.2  
changed lines
  Added in v.1.1.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26