OSDN Git Service

* config/i386/i386.md (*sinxf2): Rename to *sinxf2_i387.
[pf3gnuchains/gcc-fork.git] / libjava / classpath / tools / gnu / classpath / tools / rmic / templates / Tie.jav
1 package #package;
2
3 #imports
4 import java.rmi.Remote;
5 import javax.rmi.PortableRemoteObject;
6 import javax.rmi.CORBA.Tie;
7
8 import org.omg.CORBA.BAD_OPERATION;
9 import org.omg.CORBA.ORB;
10 import org.omg.CORBA.SystemException;
11 import org.omg.CORBA.portable.OutputStream;
12 import org.omg.CORBA.portable.ResponseHandler;
13 import org.omg.CORBA.portable.UnknownException;
14 import org.omg.PortableServer.Servant;
15 import org.omg.PortableServer.POA;
16 import org.omg.PortableServer.POAPackage.WrongPolicy;
17 import org.omg.PortableServer.POAPackage.ObjectNotActive;
18 import org.omg.PortableServer.POAPackage.ServantNotActive;
19
20 import org.omg.CORBA_2_3.portable.InputStream;
21
22 /**
23  * This class accepts remote calls to the served GIOP object and delegates them
24  * to the enclosed implementing class. Being servant, it must be connected to
25  * the ORB Poa. 
26  * It is normally generated with grmic -poa
27  */
28 public class _#nameImpl_Tie extends Servant implements Tie
29 {
30   /**
31    * All decoded remote calls are forwarded to this target.
32    */
33   #implName target;
34   
35   /**
36    * The array of repository ids, supported by this GIOP Object
37    */ 
38   private static final String[] type_ids =
39     { 
40 #idList
41     };
42       
43   /**
44    * Get an array of all interfaces, supported by this 
45    * {@link Servant}.
46    * 
47    * @param poa unused
48    * @param objectId unused
49    * 
50    * @return the array of Ids.
51    */
52   public String[] _all_interfaces(POA poa,
53     byte[] objectId
54   )
55   {
56     return type_ids;
57   }
58   
59   
60   /**
61    * Set the invocation target, where all received calls are finally
62    * forwarded.
63    *
64    * @param a_target the forwarding target
65    *
66    * @throws ClassCastException if the target is not an instance of
67    * #implName
68    */ 
69   public void setTarget(Remote a_target)
70   {
71     this.target = (#implName) a_target;
72   }
73
74   /**
75    * Get the invocation target, where all received calls are finally
76    * forwarded.
77    *
78    * @return the target, an instance of
79    * #implName
80    */ 
81   public Remote getTarget()
82   {
83     return target;
84   }
85   
86   /**
87    * Return the actual GIOP object that would handle this request.
88    * 
89    * @return the GIOP object.
90    */
91   public org.omg.CORBA.Object thisObject()
92   {
93     return _this_object();
94   }
95   
96   /**
97    * Deactivate this {@link Servant}. The WrongPolicy, ObjectNotActive
98    * and ServantNotActive exceptions, if thrown during deactivation, are
99    * catched and silently ignored.
100    */
101   public void deactivate()
102   {
103     try
104       {
105         _poa().deactivate_object(_poa().servant_to_id(this));
106       }
107     catch (WrongPolicy exception)
108       {
109       }
110     catch (ObjectNotActive exception)
111       {
112       }
113     catch (ServantNotActive exception)
114       {
115       }
116   }
117
118   /**
119    * Get the {@link ORB} where this {@link Servant} is connected.
120    * 
121    * @return the ORB
122    */
123   public ORB orb()
124   {
125     return _orb();
126   }
127
128   /**
129    * Connect this servant to the given ORB. It is recommended to connect
130    * servant to the ORBs root or other POA rather than using this method.
131    */
132   public void orb(ORB orb)
133   {
134     try
135       {
136         ((org.omg.CORBA_2_3.ORB) orb).set_delegate(this);
137       }
138     catch (ClassCastException e)
139       {
140         throw new org.omg.CORBA.BAD_PARAM(
141           "POA Servant requires an instance of org.omg.CORBA_2_3.ORB"
142         );
143       }
144   }
145
146 /**
147  * This method is invoked by ORB in response to the remote call. It redirects
148  * the call to one of the methods in the target.
149  * 
150  * @param method the name of the method to call.
151  * @param parameter_stream the input stream, from where the parameters must be
152  * read. 
153  * @param reply the response hander, providing methods to return the result.
154  * 
155  * @return the output stream, created by the response handler
156  * 
157  * @throws SystemException if one occurs during method invocation.
158  */  
159   public OutputStream _invoke(String method, 
160     org.omg.CORBA.portable.InputStream parameter_stream,
161     ResponseHandler reply
162   ) throws SystemException
163   {
164     try
165       {
166         InputStream in =(InputStream) parameter_stream;
167         switch (method.charAt(#hashCharPos))
168           {
169 #tie_methods
170             default: break;
171           }
172           
173        throw new BAD_OPERATION("No such method: '"+method+"'");
174       }
175     catch (SystemException ex)
176       {
177         throw ex;
178       }
179     catch (Throwable ex)
180       {
181         throw new UnknownException(ex);
182       }
183   }
184 }