KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > orb > etf > wiop > WIOPFactories


1 package org.jacorb.test.orb.etf.wiop;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2003 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import java.io.*;
24 import java.net.*;
25
26 import org.apache.avalon.framework.configuration.*;
27
28 import org.omg.ETF.*;
29 import org.omg.IOP.*;
30 import org.omg.RTCORBA.ProtocolProperties;
31
32 import org.jacorb.orb.iiop.*;
33 import org.apache.avalon.framework.configuration.*;
34
35 /**
36  * WIOP is wrapper around an IIOP transport. To the ORB, it looks like
37  * a wholly different transport, but the actual implementation just
38  * delegates everything to the standard IIOP classes.
39  *
40  * @author <a HREF="mailto:spiegel@gnu.org">Andre Spiegel</a>
41  * @version $Id: WIOPFactories.java,v 1.5 2004/07/29 09:30:20 simon.mcqueen Exp $
42  */

43 public class WIOPFactories
44     extends _FactoriesLocalBase
45     implements Configurable
46 {
47     public static boolean transportInUse = false;
48     private final int tag = 7;
49     org.jacorb.config.Configuration configuration;
50     org.jacorb.orb.ORB orb;
51
52     public void configure(Configuration configuration)
53         throws ConfigurationException
54     {
55         this.configuration = (org.jacorb.config.Configuration)configuration;
56         this.orb = this.configuration.getORB();
57     }
58
59     public Connection create_connection (ProtocolProperties props)
60     {
61         ClientIIOPConnection delegate = new ClientIIOPConnection();
62         try
63         {
64             delegate.configure(configuration);
65         }
66         catch( ConfigurationException ce )
67         {
68             throw new org.omg.CORBA.INTERNAL JavaDoc("ConfigurationException: " + ce.getMessage());
69         }
70
71         return new WIOPConnection (delegate,
72                                    tag);
73     }
74
75     public Listener create_listener (ProtocolProperties props,
76                                      int stacksize,
77                                      short base_priority)
78     {
79         IIOPListener delegate = new IIOPListener(orb)
80         {
81             protected Connection createServerConnection (Socket socket,
82                                                          boolean is_ssl)
83                 throws IOException
84             {
85                 return new WIOPConnection
86                     (super.createServerConnection(socket, is_ssl), tag);
87             }
88         };
89         try
90         {
91             delegate.configure(configuration);
92         }
93         catch( ConfigurationException ce )
94         {
95             throw new org.omg.CORBA.INTERNAL JavaDoc("ConfigurationException: " + ce.getMessage());
96         }
97
98         return new WIOPListener (delegate, tag);
99     }
100
101     public Profile demarshal_profile (TaggedProfileHolder tagged_profile,
102                                       TaggedComponentSeqHolder components)
103     {
104         if (tagged_profile.value.tag != this.tag)
105         {
106             throw new org.omg.CORBA.BAD_PARAM JavaDoc
107                 ("wrong profile for WIOP transport, tag: "
108                  + tagged_profile.value.tag);
109         }
110         else
111         {
112             IIOPProfile result
113                 = new IIOPProfile (tagged_profile.value.profile_data);
114             components.value = result.getComponents().asArray();
115             return new WIOPProfile (result, this.tag);
116         }
117     }
118
119     public int profile_tag()
120     {
121         return tag;
122     }
123
124     public Profile decode_corbaloc(String JavaDoc corbaloc)
125     {
126         throw new org.omg.CORBA.NO_IMPLEMENT JavaDoc();
127     }
128
129 }
130
Popular Tags