KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > orb > etf > FactoriesBase


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

21 package org.jacorb.orb.etf;
22
23 import org.apache.avalon.framework.configuration.*;
24
25 import org.omg.ETF.*;
26 import org.omg.IOP.*;
27 import org.omg.RTCORBA.ProtocolProperties;
28
29 /**
30  * @author Andre Spiegel
31  * @version $Id: FactoriesBase.java,v 1.1 2004/08/25 09:31:41 simon.mcqueen Exp $
32  */

33 public abstract class FactoriesBase
34     extends org.omg.ETF._FactoriesLocalBase
35     implements Configurable
36 {
37     protected org.jacorb.config.Configuration configuration;
38     
39     protected static Class JavaDoc connectionClz;
40     
41     protected static Class JavaDoc listenerClz;
42     
43     protected static Class JavaDoc profileClz;
44
45     public void configure(Configuration configuration)
46         throws ConfigurationException
47     {
48         this.configuration = (org.jacorb.config.Configuration)configuration;
49     }
50     
51     /**
52     * ETF defined operation to create a connection.
53     */

54     public Connection create_connection(ProtocolProperties props)
55     {
56         Connection connection = null;
57         try
58         {
59             connection = (Connection)connectionClz.newInstance();
60         }
61         catch (Exception JavaDoc ie)
62         {
63             throw new org.omg.CORBA.INTERNAL JavaDoc("Cannot instantiate ETF::Connection class: " + ie.getMessage());
64         }
65         try
66         {
67             if (connection instanceof Configurable)
68             {
69                 ((Configurable)connection).configure(configuration);
70             }
71         }
72         catch( ConfigurationException ce )
73         {
74             throw new org.omg.CORBA.INTERNAL JavaDoc("ConfigurationException: " + ce.getMessage());
75         }
76         return connection;
77     }
78     
79     /**
80     * ETF defined operation to create a connection.
81     */

82     public Listener create_listener(ProtocolProperties props,
83                                     int stacksize,
84                                     short base_priority)
85     {
86         Listener listener = null;
87         try
88         {
89             listener = (Listener)listenerClz.newInstance();
90         }
91         catch (Exception JavaDoc ie)
92         {
93             throw new org.omg.CORBA.INTERNAL JavaDoc("Cannot instantiate ETF::Listener class: " + ie.getMessage());
94         }
95         try
96         {
97             if (listener instanceof Configurable)
98             {
99                 ((Configurable)listener).configure(configuration);
100             }
101         }
102         catch( ConfigurationException ce )
103         {
104             throw new org.omg.CORBA.INTERNAL JavaDoc("ConfigurationException: " + ce.getMessage());
105         }
106         return listener;
107     }
108     
109     public Profile demarshal_profile(TaggedProfileHolder tagged_profile,
110                                       TaggedComponentSeqHolder components)
111     {
112         ProfileBase profile = null;
113         try
114         {
115             profile = (ProfileBase)profileClz.newInstance();
116         }
117         catch (Exception JavaDoc ie)
118         {
119             throw new org.omg.CORBA.INTERNAL JavaDoc("Cannot instantiate ETF::Profile class: " + ie.getMessage());
120         }
121         
122         profile.demarshal(tagged_profile, components);
123         
124         try
125         {
126             if (profile instanceof Configurable)
127             {
128                 ((Configurable)profile).configure(configuration);
129             }
130         }
131         catch( ConfigurationException ce )
132         {
133             throw new org.omg.CORBA.INTERNAL JavaDoc("ConfigurationException: " + ce.getMessage());
134         }
135         
136         return profile;
137     }
138     
139     public abstract Profile decode_corbaloc (String JavaDoc corbaloc);
140 }
141
Popular Tags