1. /*
  2. * @(#)PresentationManager.java 1.9 04/06/21
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.spi.presentation.rmi ;
  8. import java.util.Map ;
  9. import java.lang.reflect.Method ;
  10. import java.lang.reflect.InvocationHandler ;
  11. import javax.rmi.CORBA.Tie ;
  12. import com.sun.corba.se.spi.orb.ORB ;
  13. import com.sun.corba.se.spi.orbutil.proxy.InvocationHandlerFactory ;
  14. /** Provides access to RMI-IIOP stubs and ties.
  15. * Any style of stub and tie generation may be used.
  16. * This includes compiler generated stubs and runtime generated stubs
  17. * as well as compiled and reflective ties. There is normally
  18. * only one instance of this interface per VM. The instance
  19. * is obtained from the static method
  20. * com.sun.corba.se.spi.orb.ORB.getPresentationManager.
  21. * <p>
  22. * Note that
  23. * the getClassData and getDynamicMethodMarshaller methods
  24. * maintain caches to avoid redundant computation.
  25. */
  26. public interface PresentationManager
  27. {
  28. /** Creates StubFactory and Tie instances.
  29. */
  30. public interface StubFactoryFactory
  31. {
  32. /** Return the standard name of a stub (according to the RMI-IIOP specification
  33. * and rmic). This is needed so that the name of a stub is known for
  34. * standalone clients of the app server.
  35. */
  36. String getStubName( String className ) ;
  37. /** Create a stub factory for stubs for the interface whose type is given by
  38. * className. className may identify either an IDL interface or an RMI-IIOP
  39. * interface.
  40. * @param className The name of the remote interface as a Java class name.
  41. * @param isIDLStub True if className identifies an IDL stub, else false.
  42. * @param remoteCodeBase The CodeBase to use for loading Stub classes, if
  43. * necessary (may be null or unused).
  44. * @param expectedClass The expected stub type (may be null or unused).
  45. * @param classLoader The classLoader to use (may be null).
  46. */
  47. PresentationManager.StubFactory createStubFactory( String className,
  48. boolean isIDLStub, String remoteCodeBase, Class expectedClass,
  49. ClassLoader classLoader);
  50. /** Return a Tie for the given class.
  51. */
  52. Tie getTie( Class cls ) ;
  53. /** Return whether or not this StubFactoryFactory creates StubFactory
  54. * instances that create dynamic stubs and ties. At the top level,
  55. * true indicates that rmic -iiop is not needed for generating stubs
  56. * or ties.
  57. */
  58. boolean createsDynamicStubs() ;
  59. }
  60. /** Creates the actual stub needed for RMI-IIOP remote
  61. * references.
  62. */
  63. public interface StubFactory
  64. {
  65. /** Create a new dynamic stub. It has the type that was
  66. * used to create this factory.
  67. */
  68. org.omg.CORBA.Object makeStub() ;
  69. /** Return the repository ID information for all Stubs
  70. * created by this stub factory.
  71. */
  72. String[] getTypeIds() ;
  73. }
  74. public interface ClassData
  75. {
  76. /** Get the class used to create this ClassData instance
  77. */
  78. Class getMyClass() ;
  79. /** Get the IDLNameTranslator for the class used to create
  80. * this ClassData instance.
  81. */
  82. IDLNameTranslator getIDLNameTranslator() ;
  83. /** Return the array of repository IDs for all of the remote
  84. * interfaces implemented by this class.
  85. */
  86. String[] getTypeIds() ;
  87. /** Get the InvocationHandlerFactory that is used to create
  88. * an InvocationHandler for dynamic stubs of the type of the
  89. * ClassData.
  90. */
  91. InvocationHandlerFactory getInvocationHandlerFactory() ;
  92. /** Get the dictionary for this ClassData instance.
  93. * This is used to hold class-specific information for a Class
  94. * in the class data. This avoids the need to create other
  95. * caches for accessing the information.
  96. */
  97. Map getDictionary() ;
  98. }
  99. /** Get the ClassData for a particular class.
  100. * This class may be an implementation class, in which
  101. * case the IDLNameTranslator handles all Remote interfaces implemented by
  102. * the class. If the class implements more than one remote interface, and not
  103. * all of the remote interfaces are related by inheritance, then the type
  104. * IDs have the implementation class as element 0.
  105. */
  106. ClassData getClassData( Class cls ) ;
  107. /** Given a particular method, return a DynamicMethodMarshaller
  108. * for that method. This is used for dynamic stubs and ties.
  109. */
  110. DynamicMethodMarshaller getDynamicMethodMarshaller( Method method ) ;
  111. /** Return the registered StubFactoryFactory.
  112. */
  113. StubFactoryFactory getStubFactoryFactory( boolean isDynamic ) ;
  114. /** Register the StubFactoryFactory. Note that
  115. * a static StubFactoryFactory is always required for IDL. The
  116. * dynamic stubFactoryFactory is optional.
  117. */
  118. void setStubFactoryFactory( boolean isDynamic, StubFactoryFactory sff ) ;
  119. /** Equivalent to getStubFactoryFactory( true ).getTie( null ).
  120. * Provided for compatibility with earlier versions of PresentationManager
  121. * as used in the app server. The class argument is ignored in
  122. * the dynamic case, so this is safe.
  123. */
  124. Tie getTie() ;
  125. /** Returns the value of the com.sun.CORBA.ORBUseDynamicStub
  126. * property.
  127. */
  128. boolean useDynamicStubs() ;
  129. }