39 |
package org.omg.PortableServer; |
package org.omg.PortableServer; |
40 |
|
|
41 |
import org.omg.CORBA.BAD_PARAM; |
import org.omg.CORBA.BAD_PARAM; |
42 |
|
import org.omg.CORBA.TypeCode; |
43 |
|
import org.omg.CORBA.ORB; |
44 |
|
import org.omg.CORBA.Any; |
45 |
|
import org.omg.CORBA.portable.InputStream; |
46 |
|
import org.omg.CORBA.MARSHAL; |
47 |
|
import org.omg.CORBA.portable.OutputStream; |
48 |
|
|
49 |
/** |
/** |
50 |
* The helper operations for the CORBA object {@link POA}. |
* The helper operations for the CORBA object {@link POA}. |
54 |
public abstract class POAHelper |
public abstract class POAHelper |
55 |
{ |
{ |
56 |
/** |
/** |
57 |
* Cast the passed object into the POA. As POA is a local |
* Cast the passed object into the POA. As POA is a local object, the method |
58 |
* object, the method just uses java type cast. |
* just uses java type cast. |
59 |
* |
* |
60 |
* @param obj the object to narrow. |
* @param obj the object to narrow. |
61 |
* @return narrowed instance. |
* @return narrowed instance. |
72 |
throw new BAD_PARAM(obj.getClass().getName() + " is not a POA"); |
throw new BAD_PARAM(obj.getClass().getName() + " is not a POA"); |
73 |
} |
} |
74 |
} |
} |
75 |
|
|
76 |
|
/** |
77 |
|
* Get the type code of the {@link POA}. |
78 |
|
*/ |
79 |
|
public static TypeCode type() |
80 |
|
{ |
81 |
|
return ORB.init().create_interface_tc(id(), "POA"); |
82 |
|
} |
83 |
|
|
84 |
|
/** |
85 |
|
* Insert the POA into the given Any. |
86 |
|
* |
87 |
|
* @param any the Any to insert into. |
88 |
|
* |
89 |
|
* @param that the POA to insert. |
90 |
|
*/ |
91 |
|
public static void insert(Any any, POA that) |
92 |
|
{ |
93 |
|
any.insert_Object(that); |
94 |
|
} |
95 |
|
|
96 |
|
/** |
97 |
|
* Extract the POA from given Any. |
98 |
|
* |
99 |
|
* @throws BAD_OPERATION if the passed Any does not contain POA. |
100 |
|
*/ |
101 |
|
public static POA extract(Any any) |
102 |
|
{ |
103 |
|
return narrow(any.extract_Object()); |
104 |
|
} |
105 |
|
|
106 |
|
/** |
107 |
|
* Get the POA repository id. |
108 |
|
* |
109 |
|
* @return "IDL:omg.org/PortableServer/POA:2.3", always. |
110 |
|
*/ |
111 |
|
public static String id() |
112 |
|
{ |
113 |
|
return "IDL:omg.org/PortableServer/POA:2.3"; |
114 |
|
} |
115 |
|
|
116 |
|
/** |
117 |
|
* This should read POA from the CDR input stream, but, following the specs, |
118 |
|
* it doesnot. The jdk 1.5 API specification defines that POA cannot be |
119 |
|
* exported. |
120 |
|
* |
121 |
|
* @param input a org.omg.CORBA.portable stream to read from. |
122 |
|
* |
123 |
|
* @specenote Sun throws the same exception. |
124 |
|
* |
125 |
|
* @throws MARSHAL, always. |
126 |
|
*/ |
127 |
|
public static POA read(InputStream input) |
128 |
|
{ |
129 |
|
throw new MARSHAL("Not applicable"); |
130 |
|
} |
131 |
|
|
132 |
|
/** |
133 |
|
* This should read POA from the CDR input stream, but, following the specs, |
134 |
|
* it doesnot. The jdk 1.5 API specification defines that POA cannot be |
135 |
|
* exported. |
136 |
|
* |
137 |
|
* @param input a org.omg.CORBA.portable stream to read from. |
138 |
|
* |
139 |
|
* @specenote Sun throws the same exception. |
140 |
|
* |
141 |
|
* @throws MARSHAL, always. |
142 |
|
*/ |
143 |
|
public static void write(OutputStream output, POA value) |
144 |
|
{ |
145 |
|
throw new MARSHAL("Not applicable"); |
146 |
|
} |
147 |
} |
} |