KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > JChannelFactory


1 // $Id: JChannelFactory.java,v 1.3 2004/09/22 10:34:16 belaban Exp $
2

3 package org.jgroups;
4
5 import org.w3c.dom.Element JavaDoc;
6
7 import java.io.File JavaDoc;
8
9 import java.net.URL JavaDoc;
10
11 import org.jgroups.conf.ConfiguratorFactory;
12 import org.jgroups.conf.ProtocolStackConfigurator;
13
14 /**
15  * JChannelFactory creates pure Java implementations of the <code>Channel</code>
16  * interface.
17  */

18 public class JChannelFactory implements ChannelFactory {
19     private ProtocolStackConfigurator _configuration;
20
21     /**
22      * Constructs a <code>JChannelFactory</code> instance that contains no
23      * protocol stack configuration.
24      *
25      * @deprecated This constructor should only be used in conjunction with the
26      * deprecated <code>getChannel(Object)</code> method of this
27      * class.
28      */

29     public JChannelFactory() {
30     }
31
32     /**
33      * Constructs a <code>JChannelFactory</code> instance that utilizes the
34      * specified file for protocl stack configuration.
35      *
36      * @param properties a file containing a JGroups XML protocol stack
37      * configuration.
38      *
39      * @throws ChannelException if problems occur during the interpretation of
40      * the protocol stack configuration.
41      */

42     public JChannelFactory(File JavaDoc properties) throws ChannelException {
43         _configuration=ConfiguratorFactory.getStackConfigurator(properties);
44     }
45
46     /**
47      * Constructs a <code>JChannelFactory</code> instance that utilizes the
48      * specified file for protocl stack configuration.
49      *
50      * @param properties a XML element containing a JGroups XML protocol stack
51      * configuration.
52      *
53      * @throws ChannelException if problems occur during the interpretation of
54      * the protocol stack configuration.
55      */

56     public JChannelFactory(Element JavaDoc properties) throws ChannelException {
57         _configuration =ConfiguratorFactory.getStackConfigurator(properties);
58     }
59
60     /**
61      * Constructs a <code>JChannelFactory</code> instance that utilizes the
62      * specified file for protocl stack configuration.
63      *
64      * @param properties a URL pointing to a JGroups XML protocol stack
65      * configuration.
66      *
67      * @throws ChannelException if problems occur during the interpretation of
68      * the protocol stack configuration.
69      */

70     public JChannelFactory(URL JavaDoc properties) throws ChannelException {
71         _configuration=ConfiguratorFactory.getStackConfigurator(properties);
72     }
73
74     /**
75      * Constructs a <code>JChannel</code> instance with the protocol stack
76      * configuration based upon the specified properties parameter.
77      *
78      * @param properties an old style property string, a string representing a
79      * system resource containing a JGroups XML configuration,
80      * a string representing a URL pointing to a JGroups XML
81      * XML configuration, or a string representing a file name
82      * that contains a JGroups XML configuration.
83      *
84      * @throws ChannelException if problems occur during the interpretation of
85      * the protocol stack configuration.
86      */

87     public JChannelFactory(String JavaDoc properties) throws ChannelException {
88         _configuration=ConfiguratorFactory.getStackConfigurator(properties);
89     }
90
91     /**
92      * Creates a <code>JChannel</code> implementation of the
93      * <code>Channel</code> interface.
94      *
95      * @param properties the protocol stack configuration information; a
96      * <code>null</code> value means use the default protocol
97      * stack configuration.
98      *
99      * @throws ChannelException if the creation of the channel failed.
100      *
101      * @deprecated <code>JChannel</code>'s conversion to type-specific
102      * construction, and the subsequent deprecation of its
103      * <code>JChannel(Object)</code> constructor, necessitate the
104      * deprecation of this factory method as well. Type-specific
105      * protocol stack configuration should be specfied during
106      * construction of an instance of this factory.
107      */

108     public Channel createChannel(Object JavaDoc properties) throws ChannelException {
109         return new JChannel(properties);
110     }
111
112     /**
113      * Creates a <code>JChannel</code> implementation of the
114      * <code>Channel<code> interface using the protocol stack configuration
115      * information specfied during construction of an instance of this factory.
116      *
117      * @throws ChannelException if the creation of the channel failed.
118      */

119      public Channel createChannel() throws ChannelException {
120          return new JChannel(_configuration);
121      }
122 }
123
Popular Tags