001: /*
002: * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.corba.se.spi.ior.iiop;
027:
028: import org.omg.CORBA_2_3.portable.InputStream;
029:
030: import com.sun.corba.se.spi.ior.Identifiable;
031: import com.sun.corba.se.spi.ior.IdentifiableFactory;
032: import com.sun.corba.se.spi.ior.EncapsulationFactoryBase;
033: import com.sun.corba.se.spi.ior.ObjectId;
034: import com.sun.corba.se.spi.ior.ObjectKeyTemplate;
035:
036: import com.sun.corba.se.spi.ior.iiop.IIOPAddress;
037: import com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate;
038: import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
039:
040: import com.sun.corba.se.spi.orb.ORB;
041:
042: import com.sun.corba.se.impl.encoding.MarshalInputStream;
043:
044: import com.sun.corba.se.impl.ior.iiop.IIOPAddressImpl;
045: import com.sun.corba.se.impl.ior.iiop.CodeSetsComponentImpl;
046: import com.sun.corba.se.impl.ior.iiop.AlternateIIOPAddressComponentImpl;
047: import com.sun.corba.se.impl.ior.iiop.JavaCodebaseComponentImpl;
048: import com.sun.corba.se.impl.ior.iiop.MaxStreamFormatVersionComponentImpl;
049: import com.sun.corba.se.impl.ior.iiop.JavaSerializationComponent;
050: import com.sun.corba.se.impl.ior.iiop.ORBTypeComponentImpl;
051: import com.sun.corba.se.impl.ior.iiop.IIOPProfileImpl;
052: import com.sun.corba.se.impl.ior.iiop.IIOPProfileTemplateImpl;
053: import com.sun.corba.se.impl.ior.iiop.RequestPartitioningComponentImpl;
054: import com.sun.corba.se.impl.orbutil.ORBConstants;
055: import com.sun.corba.se.impl.orbutil.ORBConstants;
056:
057: import org.omg.IOP.TAG_ALTERNATE_IIOP_ADDRESS;
058: import org.omg.IOP.TAG_CODE_SETS;
059: import org.omg.IOP.TAG_JAVA_CODEBASE;
060: import org.omg.IOP.TAG_RMI_CUSTOM_MAX_STREAM_FORMAT;
061: import org.omg.IOP.TAG_ORB_TYPE;
062: import org.omg.IOP.TAG_INTERNET_IOP;
063:
064: /** This class provides all of the factories for the IIOP profiles and
065: * components. This includes direct construction of profiles and templates,
066: * as well as constructing factories that can be registered with an
067: * IdentifiableFactoryFinder.
068: */
069: public abstract class IIOPFactories {
070: private IIOPFactories() {
071: }
072:
073: public static IdentifiableFactory makeRequestPartitioningComponentFactory() {
074: return new EncapsulationFactoryBase(
075: ORBConstants.TAG_REQUEST_PARTITIONING_ID) {
076: public Identifiable readContents(InputStream in) {
077: int threadPoolToUse = in.read_ulong();
078: Identifiable comp = new RequestPartitioningComponentImpl(
079: threadPoolToUse);
080: return comp;
081: }
082: };
083: }
084:
085: public static RequestPartitioningComponent makeRequestPartitioningComponent(
086: int threadPoolToUse) {
087: return new RequestPartitioningComponentImpl(threadPoolToUse);
088: }
089:
090: public static IdentifiableFactory makeAlternateIIOPAddressComponentFactory() {
091: return new EncapsulationFactoryBase(
092: TAG_ALTERNATE_IIOP_ADDRESS.value) {
093: public Identifiable readContents(InputStream in) {
094: IIOPAddress addr = new IIOPAddressImpl(in);
095: Identifiable comp = new AlternateIIOPAddressComponentImpl(
096: addr);
097: return comp;
098: }
099: };
100: }
101:
102: public static AlternateIIOPAddressComponent makeAlternateIIOPAddressComponent(
103: IIOPAddress addr) {
104: return new AlternateIIOPAddressComponentImpl(addr);
105: }
106:
107: public static IdentifiableFactory makeCodeSetsComponentFactory() {
108: return new EncapsulationFactoryBase(TAG_CODE_SETS.value) {
109: public Identifiable readContents(InputStream in) {
110: return new CodeSetsComponentImpl(in);
111: }
112: };
113: }
114:
115: public static CodeSetsComponent makeCodeSetsComponent(ORB orb) {
116: return new CodeSetsComponentImpl(orb);
117: }
118:
119: public static IdentifiableFactory makeJavaCodebaseComponentFactory() {
120: return new EncapsulationFactoryBase(TAG_JAVA_CODEBASE.value) {
121: public Identifiable readContents(InputStream in) {
122: String url = in.read_string();
123: Identifiable comp = new JavaCodebaseComponentImpl(url);
124: return comp;
125: }
126: };
127: }
128:
129: public static JavaCodebaseComponent makeJavaCodebaseComponent(
130: String codebase) {
131: return new JavaCodebaseComponentImpl(codebase);
132: }
133:
134: public static IdentifiableFactory makeORBTypeComponentFactory() {
135: return new EncapsulationFactoryBase(TAG_ORB_TYPE.value) {
136: public Identifiable readContents(InputStream in) {
137: int type = in.read_ulong();
138: Identifiable comp = new ORBTypeComponentImpl(type);
139: return comp;
140: }
141: };
142: }
143:
144: public static ORBTypeComponent makeORBTypeComponent(int type) {
145: return new ORBTypeComponentImpl(type);
146: }
147:
148: public static IdentifiableFactory makeMaxStreamFormatVersionComponentFactory() {
149: return new EncapsulationFactoryBase(
150: TAG_RMI_CUSTOM_MAX_STREAM_FORMAT.value) {
151: public Identifiable readContents(InputStream in) {
152: byte version = in.read_octet();
153: Identifiable comp = new MaxStreamFormatVersionComponentImpl(
154: version);
155: return comp;
156: }
157: };
158: }
159:
160: public static MaxStreamFormatVersionComponent makeMaxStreamFormatVersionComponent() {
161: return new MaxStreamFormatVersionComponentImpl();
162: }
163:
164: public static IdentifiableFactory makeJavaSerializationComponentFactory() {
165: return new EncapsulationFactoryBase(
166: ORBConstants.TAG_JAVA_SERIALIZATION_ID) {
167: public Identifiable readContents(InputStream in) {
168: byte version = in.read_octet();
169: Identifiable cmp = new JavaSerializationComponent(
170: version);
171: return cmp;
172: }
173: };
174: }
175:
176: public static JavaSerializationComponent makeJavaSerializationComponent() {
177: return JavaSerializationComponent.singleton();
178: }
179:
180: public static IdentifiableFactory makeIIOPProfileFactory() {
181: return new EncapsulationFactoryBase(TAG_INTERNET_IOP.value) {
182: public Identifiable readContents(InputStream in) {
183: Identifiable result = new IIOPProfileImpl(in);
184: return result;
185: }
186: };
187: }
188:
189: public static IIOPProfile makeIIOPProfile(ORB orb,
190: ObjectKeyTemplate oktemp, ObjectId oid,
191: IIOPProfileTemplate ptemp) {
192: return new IIOPProfileImpl(orb, oktemp, oid, ptemp);
193: }
194:
195: public static IIOPProfile makeIIOPProfile(ORB orb,
196: org.omg.IOP.TaggedProfile profile) {
197: return new IIOPProfileImpl(orb, profile);
198: }
199:
200: public static IdentifiableFactory makeIIOPProfileTemplateFactory() {
201: return new EncapsulationFactoryBase(TAG_INTERNET_IOP.value) {
202: public Identifiable readContents(InputStream in) {
203: Identifiable result = new IIOPProfileTemplateImpl(in);
204: return result;
205: }
206: };
207: }
208:
209: public static IIOPProfileTemplate makeIIOPProfileTemplate(ORB orb,
210: GIOPVersion version, IIOPAddress primary) {
211: return new IIOPProfileTemplateImpl(orb, version, primary);
212: }
213:
214: public static IIOPAddress makeIIOPAddress(ORB orb, String host,
215: int port) {
216: return new IIOPAddressImpl(orb, host, port);
217: }
218:
219: public static IIOPAddress makeIIOPAddress(InputStream is) {
220: return new IIOPAddressImpl(is);
221: }
222: }
|