StubWrapper.java revision 608:7e06bf1dcb09
1/*
2 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package com.sun.corba.se.spi.presentation.rmi ;
27
28import java.rmi.RemoteException ;
29
30import org.omg.CORBA.portable.Delegate ;
31import org.omg.CORBA.ORB ;
32import org.omg.CORBA.Request ;
33import org.omg.CORBA.Context ;
34import org.omg.CORBA.NamedValue ;
35import org.omg.CORBA.NVList ;
36import org.omg.CORBA.ContextList ;
37import org.omg.CORBA.ExceptionList ;
38import org.omg.CORBA.Policy ;
39import org.omg.CORBA.DomainManager ;
40import org.omg.CORBA.SetOverrideType ;
41
42import org.omg.CORBA.portable.OutputStream ;
43
44/** Wrapper that can take any stub (object x such that StubAdapter.isStub(x))
45 * and treat it as a DynamicStub.
46 */
47public class StubWrapper implements DynamicStub
48{
49    private org.omg.CORBA.Object object ;
50
51    public StubWrapper( org.omg.CORBA.Object object )
52    {
53        if (!(StubAdapter.isStub(object)))
54            throw new IllegalStateException() ;
55
56        this.object = object ;
57    }
58
59    public void setDelegate( Delegate delegate )
60    {
61        StubAdapter.setDelegate( object, delegate ) ;
62    }
63
64    public Delegate getDelegate()
65    {
66        return StubAdapter.getDelegate( object ) ;
67    }
68
69    public ORB getORB()
70    {
71        return StubAdapter.getORB( object ) ;
72    }
73
74    public String[] getTypeIds()
75    {
76        return StubAdapter.getTypeIds( object ) ;
77    }
78
79    public void connect( ORB orb ) throws RemoteException
80    {
81        StubAdapter.connect( object, (com.sun.corba.se.spi.orb.ORB)orb ) ;
82    }
83
84    public boolean isLocal()
85    {
86        return StubAdapter.isLocal( object ) ;
87    }
88
89    public OutputStream request( String operation, boolean responseExpected )
90    {
91        return StubAdapter.request( object, operation, responseExpected ) ;
92    }
93
94    public boolean _is_a(String repositoryIdentifier)
95    {
96        return object._is_a( repositoryIdentifier ) ;
97    }
98
99    public boolean _is_equivalent(org.omg.CORBA.Object other)
100    {
101        return object._is_equivalent( other ) ;
102    }
103
104    public boolean _non_existent()
105    {
106        return object._non_existent() ;
107    }
108
109    public int _hash(int maximum)
110    {
111        return object._hash( maximum ) ;
112    }
113
114    public org.omg.CORBA.Object _duplicate()
115    {
116        return object._duplicate() ;
117    }
118
119    public void _release()
120    {
121        object._release() ;
122    }
123
124    public org.omg.CORBA.Object _get_interface_def()
125    {
126        return object._get_interface_def() ;
127    }
128
129    public Request _request(String operation)
130    {
131        return object._request( operation ) ;
132    }
133
134    public Request _create_request( Context ctx, String operation, NVList arg_list,
135        NamedValue result)
136    {
137        return object._create_request( ctx, operation, arg_list, result ) ;
138    }
139
140    public Request _create_request( Context ctx, String operation, NVList arg_list,
141        NamedValue result, ExceptionList exclist, ContextList ctxlist)
142    {
143        return object._create_request( ctx, operation, arg_list, result,
144            exclist, ctxlist ) ;
145    }
146
147    public Policy _get_policy(int policy_type)
148    {
149        return object._get_policy( policy_type ) ;
150    }
151
152    public DomainManager[] _get_domain_managers()
153    {
154        return object._get_domain_managers() ;
155    }
156
157    public org.omg.CORBA.Object _set_policy_override( Policy[] policies,
158        SetOverrideType set_add)
159    {
160        return object._set_policy_override( policies, set_add ) ;
161    }
162}
163