KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > iiop > orb > ORBImpl


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.iiop.orb;
31
32 import com.caucho.vfs.*;
33 import com.caucho.iiop.*;
34
35 import org.omg.CORBA.*;
36
37 import java.applet.Applet JavaDoc;
38 import java.lang.reflect.Proxy JavaDoc;
39 import java.util.Properties JavaDoc;
40 import java.util.logging.Logger JavaDoc;
41 import javax.rmi.PortableRemoteObject JavaDoc;
42 import java.io.IOException JavaDoc;
43
44 public class ORBImpl extends org.omg.CORBA.ORB JavaDoc
45 {
46   public static final Logger JavaDoc log
47     = Logger.getLogger(ORBImpl.class.getName());
48   
49   private String JavaDoc _host;
50   private int _port;
51
52   private Path _path;
53
54   private final StubDelegateImpl _stubDelegate;
55
56   public ORBImpl()
57   {
58     _stubDelegate = new StubDelegateImpl(this);
59   }
60
61   StubDelegateImpl getStubDelegate()
62   {
63     return _stubDelegate;
64   }
65
66   WriteStream openWriter()
67   {
68     try {
69       ReadWritePair pair = _path.openReadWrite();
70
71       return pair.getWriteStream();
72     } catch (IOException JavaDoc e) {
73       throw new RuntimeException JavaDoc(e);
74     }
75   }
76
77   ReadWritePair openReadWrite()
78   {
79     try {
80       return _path.openReadWrite();
81     } catch (IOException JavaDoc e) {
82       throw new RuntimeException JavaDoc(e);
83     }
84   }
85
86   public TypeCode create_alias_tc(String JavaDoc id, String JavaDoc name, TypeCode original)
87   {
88     throw new UnsupportedOperationException JavaDoc();
89   }
90
91   public Any create_any()
92   {
93     throw new UnsupportedOperationException JavaDoc();
94   }
95
96   public TypeCode create_array_tc(int length, TypeCode element_type)
97   {
98     throw new UnsupportedOperationException JavaDoc();
99   }
100
101   public ContextList create_context_list()
102   {
103     throw new UnsupportedOperationException JavaDoc();
104   }
105
106   public TypeCode create_enum_tc(String JavaDoc id, String JavaDoc name, String JavaDoc []members)
107   {
108     throw new UnsupportedOperationException JavaDoc();
109   }
110
111   public Environment create_environment()
112   {
113     throw new UnsupportedOperationException JavaDoc();
114   }
115
116   public ExceptionList create_exception_list()
117   {
118     throw new UnsupportedOperationException JavaDoc();
119   }
120
121   public TypeCode create_exception_tc(String JavaDoc id,
122                       String JavaDoc name,
123                       StructMember []members)
124   {
125     throw new UnsupportedOperationException JavaDoc();
126   }
127
128   public TypeCode create_interface_tc(String JavaDoc id,
129                       String JavaDoc name)
130   {
131     throw new UnsupportedOperationException JavaDoc();
132   }
133
134   public NVList create_list(int count)
135   {
136     throw new UnsupportedOperationException JavaDoc();
137   }
138
139   public NamedValue create_named_value(String JavaDoc s, Any any, int flags)
140   {
141     throw new UnsupportedOperationException JavaDoc();
142   }
143
144   public TypeCode create_native_tc(String JavaDoc id, String JavaDoc name)
145   {
146     throw new UnsupportedOperationException JavaDoc();
147   }
148
149   public org.omg.CORBA.portable.OutputStream JavaDoc create_output_stream()
150   {
151     throw new UnsupportedOperationException JavaDoc();
152   }
153
154   @Deprecated JavaDoc
155   public TypeCode create_recursive_sequence_tc(int bound, int offset)
156   {
157     throw new UnsupportedOperationException JavaDoc();
158   }
159
160   public TypeCode create_sequence_tc(int bound, TypeCode element_type)
161   {
162     throw new UnsupportedOperationException JavaDoc();
163   }
164
165   public TypeCode create_string_tc(int bound)
166   {
167     throw new UnsupportedOperationException JavaDoc();
168   }
169
170   public TypeCode create_struct_tc(String JavaDoc id,
171                    String JavaDoc name,
172                    StructMember []members)
173   {
174     throw new UnsupportedOperationException JavaDoc();
175   }
176
177   public TypeCode create_union_tc(String JavaDoc id,
178                   String JavaDoc name,
179                   TypeCode discriminator_type,
180                   UnionMember []members)
181   {
182     throw new UnsupportedOperationException JavaDoc();
183   }
184
185   public TypeCode create_wstring_tc(int bound)
186   {
187     throw new UnsupportedOperationException JavaDoc();
188   }
189
190   public Context get_default_context()
191   {
192     throw new UnsupportedOperationException JavaDoc();
193   }
194
195   public Request get_next_response()
196   {
197     throw new UnsupportedOperationException JavaDoc();
198   }
199
200   public TypeCode get_primitive_tc(org.omg.CORBA.TCKind JavaDoc tcKind)
201   {
202     throw new UnsupportedOperationException JavaDoc();
203   }
204
205   public String JavaDoc []list_initial_services()
206   {
207     return new String JavaDoc[0];
208   }
209
210   @Override JavaDoc
211   public String JavaDoc object_to_string(org.omg.CORBA.Object JavaDoc obj)
212   {
213     throw new UnsupportedOperationException JavaDoc();
214   }
215
216   public boolean poll_next_response()
217   {
218     throw new UnsupportedOperationException JavaDoc();
219   }
220
221   public org.omg.CORBA.Object JavaDoc resolve_initial_references(String JavaDoc object_name)
222   {
223     try {
224       Thread JavaDoc thread = Thread.currentThread();
225       ClassLoader JavaDoc loader = thread.getContextClassLoader();
226
227       Iiop10Writer writer = new Iiop10Writer();
228
229       ReadWritePair pair = openReadWrite();
230
231       MessageWriter out = new StreamMessageWriter(pair.getWriteStream());
232
233       IiopReader in = new IiopReader(pair.getReadStream());
234       in.setOrb(this);
235     
236       writer.init(out, new IiopReader(pair.getReadStream()));
237
238       byte []oid = new byte[] { 'I', 'N', 'I', 'T' };
239
240       writer.startRequest(oid, 0, oid.length, "get", 1);
241
242       writer.writeString(object_name);
243
244       in = writer._call();
245       in.setOrb(this);
246
247       org.omg.CORBA.Object JavaDoc value = in.read_Object();
248
249       in.close();
250       
251       return value;
252     } catch (Exception JavaDoc e) {
253       throw new RuntimeException JavaDoc(e);
254     }
255   }
256
257   public void send_multiple_requests_deferred(Request []req)
258   {
259     throw new UnsupportedOperationException JavaDoc();
260   }
261
262   public void send_multiple_requests_oneway(Request []req)
263   {
264     throw new UnsupportedOperationException JavaDoc();
265   }
266
267   public void set_parameters(Applet JavaDoc app, Properties JavaDoc props)
268   {
269     throw new UnsupportedOperationException JavaDoc();
270   }
271
272   public void set_parameters(String JavaDoc []args, Properties JavaDoc props)
273   {
274     if (props != null) {
275       java.lang.Object JavaDoc port = props.get("org.omg.CORBA.ORBInitialPort");
276       java.lang.Object JavaDoc host = props.get("org.omg.CORBA.ORBInitialHost");
277
278       if (host != null)
279     _host = String.valueOf(host);
280
281       if (port == null) {
282       }
283       else if (port instanceof Number JavaDoc)
284     _port = ((Number JavaDoc) port).intValue();
285       else
286     _port = Integer.parseInt(String.valueOf(port));
287
288       _path = Vfs.lookup("tcp://" + _host + ":" + port);
289     }
290   }
291
292   public org.omg.CORBA.Object JavaDoc string_to_object(String JavaDoc str)
293   {
294     throw new UnsupportedOperationException JavaDoc();
295   }
296
297   public String JavaDoc toString()
298   {
299     if (_host != null)
300       return "ORBImpl[" + _host + ", " + _port + "]";
301     else
302       return "ORBImpl[]";
303   }
304 }
305
Popular Tags