1 7 8 package com.sun.corba.se.spi.ior ; 9 10 import java.io.Serializable ; 11 12 import org.omg.CORBA_2_3.portable.InputStream ; 13 14 import org.omg.CORBA.BAD_PARAM ; 15 import org.omg.CORBA.portable.ValueFactory ; 16 17 import org.omg.PortableInterceptor.ObjectReferenceTemplate ; 18 import org.omg.PortableInterceptor.ObjectReferenceFactory ; 19 20 import com.sun.corba.se.impl.ior.ObjectIdImpl ; 21 import com.sun.corba.se.impl.ior.ObjectKeyImpl ; 22 import com.sun.corba.se.impl.ior.IORImpl ; 23 import com.sun.corba.se.impl.ior.IORTemplateImpl ; 24 import com.sun.corba.se.impl.ior.IORTemplateListImpl ; 25 import com.sun.corba.se.impl.ior.ObjectReferenceProducerBase ; 26 import com.sun.corba.se.impl.ior.ObjectReferenceFactoryImpl ; 27 import com.sun.corba.se.impl.ior.ObjectReferenceTemplateImpl ; 28 import com.sun.corba.se.impl.ior.ObjectKeyFactoryImpl ; 29 30 import com.sun.corba.se.impl.orbutil.ORBUtility ; 31 32 import com.sun.corba.se.spi.orb.ORB ; 33 34 44 public class IORFactories { 45 private IORFactories() {} 46 47 49 public static ObjectId makeObjectId( byte[] id ) 50 { 51 return new ObjectIdImpl( id ) ; 52 } 53 54 57 public static ObjectKey makeObjectKey( ObjectKeyTemplate oktemp, ObjectId oid ) 58 { 59 return new ObjectKeyImpl( oktemp, oid ) ; 60 } 61 62 64 public static IOR makeIOR( ORB orb, String typeid ) 65 { 66 return new IORImpl( orb, typeid ) ; 67 } 68 69 71 public static IOR makeIOR( ORB orb ) 72 { 73 return new IORImpl( orb ) ; 74 } 75 76 78 public static IOR makeIOR( InputStream is ) 79 { 80 return new IORImpl( is ) ; 81 } 82 83 86 public static IORTemplate makeIORTemplate( ObjectKeyTemplate oktemp ) 87 { 88 return new IORTemplateImpl( oktemp ) ; 89 } 90 91 93 public static IORTemplate makeIORTemplate( InputStream is ) 94 { 95 return new IORTemplateImpl( is ) ; 96 } 97 98 public static IORTemplateList makeIORTemplateList() 99 { 100 return new IORTemplateListImpl() ; 101 } 102 103 public static IORTemplateList makeIORTemplateList( InputStream is ) 104 { 105 return new IORTemplateListImpl( is ) ; 106 } 107 108 public static IORFactory getIORFactory( ObjectReferenceTemplate ort ) 109 { 110 if (ort instanceof ObjectReferenceTemplateImpl) { 111 ObjectReferenceTemplateImpl orti = 112 (ObjectReferenceTemplateImpl)ort ; 113 return orti.getIORFactory() ; 114 } 115 116 throw new BAD_PARAM () ; 117 } 118 119 public static IORTemplateList getIORTemplateList( ObjectReferenceFactory orf ) 120 { 121 if (orf instanceof ObjectReferenceProducerBase) { 122 ObjectReferenceProducerBase base = 123 (ObjectReferenceProducerBase)orf ; 124 return base.getIORTemplateList() ; 125 } 126 127 throw new BAD_PARAM () ; 128 } 129 130 public static ObjectReferenceTemplate makeObjectReferenceTemplate( ORB orb, 131 IORTemplate iortemp ) 132 { 133 return new ObjectReferenceTemplateImpl( orb, iortemp ) ; 134 } 135 136 public static ObjectReferenceFactory makeObjectReferenceFactory( ORB orb, 137 IORTemplateList iortemps ) 138 { 139 return new ObjectReferenceFactoryImpl( orb, iortemps ) ; 140 } 141 142 public static ObjectKeyFactory makeObjectKeyFactory( ORB orb ) 143 { 144 return new ObjectKeyFactoryImpl( orb ) ; 145 } 146 147 public static IOR getIOR( org.omg.CORBA.Object obj ) 148 { 149 return ORBUtility.getIOR( obj ) ; 150 } 151 152 public static org.omg.CORBA.Object makeObjectReference( IOR ior ) 153 { 154 return ORBUtility.makeObjectReference( ior ) ; 155 } 156 157 161 public static void registerValueFactories( ORB orb ) 162 { 163 ValueFactory vf = new ValueFactory () { 166 public Serializable read_value( InputStream is ) 167 { 168 return new ObjectReferenceTemplateImpl( is ) ; 169 } 170 } ; 171 172 orb.register_value_factory( ObjectReferenceTemplateImpl.repositoryId, vf ) ; 173 174 vf = new ValueFactory () { 177 public Serializable read_value( InputStream is ) 178 { 179 return new ObjectReferenceFactoryImpl( is ) ; 180 } 181 } ; 182 183 orb.register_value_factory( ObjectReferenceFactoryImpl.repositoryId, vf ) ; 184 } 185 } 186 | Popular Tags |