OSDN Git Service

Merged gcj-eclipse branch to trunk.
[pf3gnuchains/gcc-fork.git] / libjava / classpath / tools / gnu / classpath / tools / rmic / templates / ImplTie.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
16 import org.omg.CORBA_2_3.portable.ObjectImpl;
17 import org.omg.CORBA_2_3.portable.InputStream;
18
19 // This Tie type is obsolete. Use the POA - based tie (key -poa).
20
21 /**
22  * This class accepts remote calls to the served GIOP object and delegates them
23  * to the enclosed implementing class. Being derived from the ObjectImpl,
24  * it directly implements the GIOP Object.
25  *
26  * It is normally generated with grmic -impl
27  */
28 public class _#nameImpl_Tie extends ObjectImpl 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 (repository ids),
45    * supported by this Object.
46    *
47    * @return the array of Ids.
48    */
49   public String[] _ids() 
50   { 
51     return type_ids;
52   }  
53
54   /**
55    * Set the invocation target, where all received calls are finally
56    * forwarded.
57    *
58    * @param a_target the forwarding target
59    *
60    * @throws ClassCastException if the target is not an instance of
61    * #implName
62    */ 
63   public void setTarget(Remote a_target)
64   {
65     this.target = (#implName) a_target;
66   }
67
68   /**
69    * Get the invocation target, where all received calls are finally
70    * forwarded.
71    *
72    * @return the target, an instance of
73    * #implName
74    */ 
75   public Remote getTarget()
76   {
77     return target;
78   }
79   
80   /**
81    * Return the actual GIOP object that would handle this request.
82    * 
83    * @return <code>this</code>, always.
84    */
85   public org.omg.CORBA.Object thisObject()
86   {
87     return this;
88   }
89   
90   /**
91    * Deactivates this object, disconnecting it from the orb.
92    */
93   public void deactivate()
94   {
95      _orb().disconnect(this);
96      _set_delegate(null);
97      target = null;
98   }
99
100   /**
101    * Get the {@link ORB} where this {@link Servant} is connected.
102    * 
103    * @return the ORB
104    */
105   public ORB orb()
106   {
107     return _orb();
108   }
109
110   /**
111    * Connect this servant to the given ORB. 
112    */
113   public void orb(ORB orb)
114   {
115     orb.connect(this);
116   }
117
118 /**
119  * This method is invoked by ORB in response to the remote call. It redirects
120  * the call to one of the methods in the target.
121  * 
122  * @param method the name of the method to call.
123  * @param parameter_stream the input stream, from where the parameters must be
124  * read. 
125  * @param reply the response hander, providing methods to return the result.
126  * 
127  * @return the output stream, created by the response handler
128  * 
129  * @throws SystemException if one occurs during method invocation.
130  */  
131   public OutputStream _invoke(String method, 
132     org.omg.CORBA.portable.InputStream parameter_stream,
133     ResponseHandler reply)
134   {
135     try
136       {
137         InputStream in =(InputStream) parameter_stream;
138           
139 #tie_methods          
140           
141        throw new BAD_OPERATION("No such method: '"+method+"'");
142       }
143     catch (SystemException ex)
144       {
145         throw ex;
146       }
147     catch (Throwable ex)
148       {
149         throw new UnknownException(ex);
150       }
151   }
152 }