PresentationManager.java revision 608:7e06bf1dcb09
1219820Sjeff/*
2219820Sjeff * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
3219820Sjeff * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4219820Sjeff *
5219820Sjeff * This code is free software; you can redistribute it and/or modify it
6219820Sjeff * under the terms of the GNU General Public License version 2 only, as
7219820Sjeff * published by the Free Software Foundation.  Oracle designates this
8219820Sjeff * particular file as subject to the "Classpath" exception as provided
9219820Sjeff * by Oracle in the LICENSE file that accompanied this code.
10219820Sjeff *
11219820Sjeff * This code is distributed in the hope that it will be useful, but WITHOUT
12219820Sjeff * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13219820Sjeff * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14219820Sjeff * version 2 for more details (a copy is included in the LICENSE file that
15219820Sjeff * accompanied this code).
16219820Sjeff *
17219820Sjeff * You should have received a copy of the GNU General Public License version
18219820Sjeff * 2 along with this work; if not, write to the Free Software Foundation,
19219820Sjeff * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20219820Sjeff *
21219820Sjeff * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22219820Sjeff * or visit www.oracle.com if you need additional information or have any
23219820Sjeff * questions.
24219820Sjeff */
25219820Sjeff
26219820Sjeffpackage com.sun.corba.se.spi.presentation.rmi ;
27219820Sjeff
28219820Sjeffimport java.util.Map ;
29219820Sjeff
30219820Sjeffimport java.lang.reflect.Method ;
31219820Sjeffimport java.lang.reflect.InvocationHandler ;
32219820Sjeff
33219820Sjeffimport javax.rmi.CORBA.Tie ;
34219820Sjeff
35219820Sjeffimport com.sun.corba.se.spi.orb.ORB ;
36219820Sjeffimport com.sun.corba.se.spi.orbutil.proxy.InvocationHandlerFactory ;
37219820Sjeff
38219820Sjeff
39219820Sjeff/** Provides access to RMI-IIOP stubs and ties.
40219820Sjeff * Any style of stub and tie generation may be used.
41219820Sjeff * This includes compiler generated stubs and runtime generated stubs
42219820Sjeff * as well as compiled and reflective ties.  There is normally
43219820Sjeff * only one instance of this interface per VM.  The instance
44219820Sjeff * is obtained from the static method
45219820Sjeff * com.sun.corba.se.spi.orb.ORB.getPresentationManager.
46219820Sjeff * <p>
47219820Sjeff * Note that
48219820Sjeff * the getClassData and getDynamicMethodMarshaller methods
49219820Sjeff * maintain caches to avoid redundant computation.
50219820Sjeff */
51219820Sjeffpublic interface PresentationManager
52219820Sjeff{
53219820Sjeff    /** Creates StubFactory and Tie instances.
54219820Sjeff     */
55219820Sjeff    public interface StubFactoryFactory
56219820Sjeff    {
57219820Sjeff        /** Return the standard name of a stub (according to the RMI-IIOP specification
58219820Sjeff         * and rmic).  This is needed so that the name of a stub is known for
59219820Sjeff         * standalone clients of the app server.
60219820Sjeff         */
61219820Sjeff        String getStubName( String className ) ;
62219820Sjeff
63219820Sjeff        /** Create a stub factory for stubs for the interface whose type is given by
64219820Sjeff         * className.  className may identify either an IDL interface or an RMI-IIOP
65219820Sjeff         * interface.
66219820Sjeff         * @param className The name of the remote interface as a Java class name.
67219820Sjeff         * @param isIDLStub True if className identifies an IDL stub, else false.
68219820Sjeff         * @param remoteCodeBase The CodeBase to use for loading Stub classes, if
69219820Sjeff         * necessary (may be null or unused).
70219820Sjeff         * @param expectedClass The expected stub type (may be null or unused).
71219820Sjeff         * @param classLoader The classLoader to use (may be null).
72219820Sjeff         */
73219820Sjeff        PresentationManager.StubFactory createStubFactory( String className,
74219820Sjeff            boolean isIDLStub, String remoteCodeBase, Class expectedClass,
75219820Sjeff            ClassLoader classLoader);
76219820Sjeff
77219820Sjeff        /** Return a Tie for the given class.
78219820Sjeff         */
79219820Sjeff        Tie getTie( Class cls ) ;
80219820Sjeff
81219820Sjeff        /** Return whether or not this StubFactoryFactory creates StubFactory
82219820Sjeff         * instances that create dynamic stubs and ties.  At the top level,
83219820Sjeff         * true indicates that rmic -iiop is not needed for generating stubs
84219820Sjeff         * or ties.
85219820Sjeff         */
86219820Sjeff        boolean createsDynamicStubs() ;
87219820Sjeff    }
88219820Sjeff
89219820Sjeff    /** Creates the actual stub needed for RMI-IIOP remote
90219820Sjeff     * references.
91219820Sjeff     */
92219820Sjeff    public interface StubFactory
93219820Sjeff    {
94219820Sjeff        /** Create a new dynamic stub.  It has the type that was
95219820Sjeff         * used to create this factory.
96219820Sjeff         */
97219820Sjeff        org.omg.CORBA.Object makeStub() ;
98219820Sjeff
99219820Sjeff        /** Return the repository ID information for all Stubs
100219820Sjeff         * created by this stub factory.
101219820Sjeff         */
102219820Sjeff        String[] getTypeIds() ;
103219820Sjeff    }
104219820Sjeff
105219820Sjeff    public interface ClassData
106219820Sjeff    {
107219820Sjeff        /** Get the class used to create this ClassData instance
108219820Sjeff         */
109219820Sjeff        Class getMyClass() ;
110219820Sjeff
111219820Sjeff        /** Get the IDLNameTranslator for the class used to create
112219820Sjeff         * this ClassData instance.
113219820Sjeff         */
114219820Sjeff        IDLNameTranslator getIDLNameTranslator() ;
115219820Sjeff
116219820Sjeff        /** Return the array of repository IDs for all of the remote
117219820Sjeff         * interfaces implemented by this class.
118219820Sjeff         */
119219820Sjeff        String[] getTypeIds() ;
120219820Sjeff
121219820Sjeff        /** Get the InvocationHandlerFactory that is used to create
122219820Sjeff         * an InvocationHandler for dynamic stubs of the type of the
123219820Sjeff         * ClassData.
124219820Sjeff         */
125219820Sjeff        InvocationHandlerFactory getInvocationHandlerFactory() ;
126219820Sjeff
127219820Sjeff        /** Get the dictionary for this ClassData instance.
128219820Sjeff         * This is used to hold class-specific information for a Class
129219820Sjeff         * in the class data.  This avoids the need to create other
130219820Sjeff         * caches for accessing the information.
131219820Sjeff         */
132219820Sjeff        Map getDictionary() ;
133219820Sjeff    }
134219820Sjeff
135219820Sjeff    /** Get the ClassData for a particular class.
136219820Sjeff     * This class may be an implementation class, in which
137219820Sjeff     * case the IDLNameTranslator handles all Remote interfaces implemented by
138219820Sjeff     * the class.  If the class implements more than one remote interface, and not
139219820Sjeff     * all of the remote interfaces are related by inheritance, then the type
140219820Sjeff     * IDs have the implementation class as element 0.
141219820Sjeff     */
142219820Sjeff    ClassData getClassData( Class cls ) ;
143219820Sjeff
144219820Sjeff    /** Given a particular method, return a DynamicMethodMarshaller
145219820Sjeff     * for that method.  This is used for dynamic stubs and ties.
146219820Sjeff     */
147219820Sjeff    DynamicMethodMarshaller getDynamicMethodMarshaller( Method method ) ;
148219820Sjeff
149219820Sjeff    /** Return the registered StubFactoryFactory.
150219820Sjeff     */
151219820Sjeff    StubFactoryFactory getStubFactoryFactory( boolean isDynamic ) ;
152219820Sjeff
153219820Sjeff    /** Register the StubFactoryFactory.  Note that
154219820Sjeff     * a static StubFactoryFactory is always required for IDL.  The
155219820Sjeff     * dynamic stubFactoryFactory is optional.
156219820Sjeff     */
157219820Sjeff    void setStubFactoryFactory( boolean isDynamic, StubFactoryFactory sff ) ;
158219820Sjeff
159219820Sjeff    /** Equivalent to getStubFactoryFactory( true ).getTie( null ).
160219820Sjeff     * Provided for compatibility with earlier versions of PresentationManager
161219820Sjeff     * as used in the app server.  The class argument is ignored in
162219820Sjeff     * the dynamic case, so this is safe.
163219820Sjeff     */
164219820Sjeff    Tie getTie() ;
165219820Sjeff
166219820Sjeff    /** Returns the value of the com.sun.CORBA.ORBUseDynamicStub
167219820Sjeff     * property.
168219820Sjeff     */
169219820Sjeff    boolean useDynamicStubs() ;
170219820Sjeff}
171219820Sjeff