KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.omg.CORBA.*;
33
34 import java.util.logging.Logger JavaDoc;
35 import java.io.*;
36
37 import com.caucho.iiop.*;
38 import com.caucho.vfs.*;
39
40 public class StubDelegateImpl extends org.omg.CORBA.portable.Delegate JavaDoc
41 {
42   public static final Logger JavaDoc log
43     = Logger.getLogger(StubDelegateImpl.class.getName());
44   
45   private ORBImpl _orb;
46
47   StubDelegateImpl(ORBImpl orb)
48   {
49     _orb = orb;
50   }
51
52   @Override JavaDoc
53   public org.omg.CORBA.portable.OutputStream JavaDoc
54     request(org.omg.CORBA.Object JavaDoc self,
55         String JavaDoc op,
56         boolean isResponseExpected)
57   {
58     try {
59       Iiop10Writer writer = new Iiop10Writer();
60
61       ReadWritePair pair = _orb.openReadWrite();
62
63       MessageWriter out = new StreamMessageWriter(pair.getWriteStream());
64     
65       writer.init(out, new IiopReader(pair.getReadStream()));
66
67       byte []oid = ((StubImpl) self).getOid();
68
69       writer.startRequest(oid, 0, oid.length, op, 1);
70
71       return writer;
72     } catch (IOException e) {
73       throw new RuntimeException JavaDoc(e);
74     }
75   }
76
77   @Override JavaDoc
78   public org.omg.CORBA.portable.InputStream JavaDoc
79     invoke(org.omg.CORBA.Object JavaDoc self,
80        org.omg.CORBA.portable.OutputStream JavaDoc os)
81   {
82     try {
83       IiopWriter writer = (IiopWriter) os;
84
85       IiopReader reader = writer._call();
86
87       return reader;
88     } catch (IOException e) {
89       throw new RuntimeException JavaDoc(e);
90     }
91   }
92
93   @Override JavaDoc
94   public Request create_request(org.omg.CORBA.Object JavaDoc obj,
95                 Context ctx,
96                 String JavaDoc op,
97                 NVList argList,
98                 NamedValue result)
99   {
100     throw new UnsupportedOperationException JavaDoc();
101   }
102
103   @Override JavaDoc
104   public Request create_request(org.omg.CORBA.Object JavaDoc obj,
105                 Context ctx,
106                 String JavaDoc op,
107                 NVList argList,
108                 NamedValue result,
109                 ExceptionList excList,
110                 ContextList ctxList)
111   {
112     throw new UnsupportedOperationException JavaDoc();
113   }
114
115   @Override JavaDoc
116   public org.omg.CORBA.Object JavaDoc duplicate(org.omg.CORBA.Object JavaDoc obj)
117   {
118     return obj;
119   }
120
121   @Override JavaDoc
122   public org.omg.CORBA.Object JavaDoc get_interface_def(org.omg.CORBA.Object JavaDoc self)
123   {
124     throw new UnsupportedOperationException JavaDoc();
125   }
126
127   @Override JavaDoc
128   public int hash(org.omg.CORBA.Object JavaDoc obj, int max)
129   {
130     throw new UnsupportedOperationException JavaDoc();
131   }
132
133   @Override JavaDoc
134   public boolean is_a(org.omg.CORBA.Object JavaDoc obj, String JavaDoc repId)
135   {
136     System.out.println("IS-A: " + obj + " " + repId);
137     Thread.dumpStack();
138
139     return true;
140   }
141
142   @Override JavaDoc
143   public boolean is_equivalent(org.omg.CORBA.Object JavaDoc obj,
144                    org.omg.CORBA.Object JavaDoc other)
145   {
146     return obj == other;
147   }
148
149   @Override JavaDoc
150   public boolean non_existent(org.omg.CORBA.Object JavaDoc obj)
151   {
152     throw new UnsupportedOperationException JavaDoc();
153   }
154
155   @Override JavaDoc
156   public ORB orb(org.omg.CORBA.Object JavaDoc obj)
157   {
158     return _orb;
159   }
160
161   @Override JavaDoc
162   public void release(org.omg.CORBA.Object JavaDoc obj)
163   {
164     throw new UnsupportedOperationException JavaDoc();
165   }
166
167   @Override JavaDoc
168   public Request request(org.omg.CORBA.Object JavaDoc obj, String JavaDoc op)
169   {
170     throw new UnsupportedOperationException JavaDoc();
171   }
172
173   public String JavaDoc toString()
174   {
175     return "StubDelegateImpl[]";
176   }
177 }
178
Popular Tags