1. /*
  2. * @(#)TaggedComponentFactories.java 1.8 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.internal.ior ;
  8. import org.omg.CORBA_2_3.portable.InputStream ;
  9. import com.sun.corba.se.internal.core.MarshalInputStream ;
  10. import com.sun.corba.se.internal.ior.CodeSetsComponent ;
  11. import com.sun.corba.se.internal.ior.TaggedComponentFactoryFinder ;
  12. import com.sun.corba.se.internal.ior.IdEncapsulation ;
  13. import com.sun.corba.se.internal.ior.IdEncapsulationFactory ;
  14. import com.sun.corba.se.internal.ior.IIOPAddressImpl ;
  15. import com.sun.corba.se.internal.ior.AlternateIIOPAddressComponent ;
  16. import org.omg.IOP.TAG_ALTERNATE_IIOP_ADDRESS ;
  17. import org.omg.IOP.TAG_CODE_SETS ;
  18. import org.omg.IOP.TAG_JAVA_CODEBASE ;
  19. import org.omg.IOP.TAG_ORB_TYPE ;
  20. import org.omg.IOP.TAG_POLICIES ;
  21. abstract class ComponentFactoryBase implements IdEncapsulationFactory {
  22. public final IdEncapsulation create( int id, InputStream in )
  23. {
  24. InputStream is = IdEncapsulationBase.getEncapsulationStream( in ) ;
  25. return readContents( is ) ;
  26. }
  27. abstract IdEncapsulation readContents( InputStream is ) ;
  28. }
  29. public class TaggedComponentFactories {
  30. private TaggedComponentFactories() {}
  31. // This must be called during ORB initialization
  32. public static void registerFactories()
  33. {
  34. TaggedComponentFactoryFinder finder =
  35. TaggedComponentFactoryFinder.getFinder() ;
  36. IdEncapsulationFactory factory ;
  37. // register AlternateIIOPAddressComponent factory
  38. factory = new ComponentFactoryBase() {
  39. public IdEncapsulation readContents( InputStream in )
  40. {
  41. // ignore the ID here
  42. IIOPAddress addr = new IIOPAddressImpl( in ) ;
  43. return new AlternateIIOPAddressComponent(
  44. addr ) ;
  45. }
  46. } ;
  47. finder.registerFactory( TAG_ALTERNATE_IIOP_ADDRESS.value,
  48. factory ) ;
  49. // register CodeSetsComponent factory
  50. factory = new ComponentFactoryBase() {
  51. public IdEncapsulation readContents( InputStream in )
  52. {
  53. // ignore the ID here
  54. CodeSetsComponent csc = new CodeSetsComponent() ;
  55. csc.csci.read( (MarshalInputStream)in ) ;
  56. return csc ;
  57. }
  58. } ;
  59. finder.registerFactory( TAG_CODE_SETS.value,
  60. factory ) ;
  61. // register JavaCodeBaseComponent factory
  62. factory = new ComponentFactoryBase() {
  63. public IdEncapsulation readContents( InputStream in )
  64. {
  65. // ignore the ID here
  66. String url = in.read_string() ;
  67. return new JavaCodebaseComponent( url ) ;
  68. }
  69. } ;
  70. finder.registerFactory( TAG_JAVA_CODEBASE.value,
  71. factory ) ;
  72. // register ORBTypeComponent factory
  73. factory = new ComponentFactoryBase() {
  74. public IdEncapsulation readContents( InputStream in )
  75. {
  76. // ignore the ID here
  77. int type = in.read_ulong() ;
  78. return new ORBTypeComponent( type ) ;
  79. }
  80. } ;
  81. finder.registerFactory( TAG_ORB_TYPE.value,
  82. factory ) ;
  83. // register PoliciesComponent factory
  84. /* Leave this out for now until we take a good
  85. * look at the entire policy picture.
  86. factory = new ComponentFactoryBase() {
  87. IdEncapsulation readContents( InputStream in )
  88. {
  89. }
  90. } ;
  91. finder.registerFactory( TAG_POLICIES.value,
  92. factory ) ;
  93. */
  94. }
  95. }