01: // $Id: ChannelFactory.java,v 1.9 2006/09/01 14:40:27 belaban Exp $
02:
03: package org.jgroups;
04:
05: import org.w3c.dom.Element;
06:
07: import java.io.File;
08: import java.net.URL;
09:
10: /**
11: A channel factory takes care of creation of channel implementations. Subclasses will create
12: different implementations.
13: */
14: public interface ChannelFactory {
15:
16: /**
17: * Initializes the factory.
18: * @param properties
19: * @throws ChannelException
20: */
21: void setMultiplexerConfig(Object properties) throws Exception;
22:
23: /**
24: * Initializes the factory from a file. Example: conf/stacks.xml
25: * @param properties
26: * @throws ChannelException
27: */
28: void setMultiplexerConfig(File properties) throws Exception;
29:
30: void setMultiplexerConfig(Element properties) throws Exception;
31:
32: void setMultiplexerConfig(URL properties) throws Exception;
33:
34: void setMultiplexerConfig(String properties) throws Exception;
35:
36: /**
37: * Creates an implementation of Channel using a guven stack name and registering under a given identity.
38: * The latter is used for multiplexing requests to and from a block on top of a channel.
39: * @param stack_name The name of the stack to be used. All stacks are defined in the configuration
40: * with which the factory is configured (see {@link #setMultiplexerConfig(Object)} for example.
41: * @param id The identifier used for multiplexing and demultiplexing (dispatching requests to one of possibly
42: * multiple receivers). Note that id needs to be a string since it will be shipped with each message. Try to pick
43: * a short string, because this is shipped with every message (overhead). todo: possibly change to short ?
44: * @param register_for_state_transfer If set to true, after all registered listeners called connect() on the returned Channel,
45: * the state for all registered listeners will be fetched and set in all listeners
46: * @param substate_id The ID of the substate to be retrieved. Set this to null if the entire state should be retrieved. If
47: * register_for_state_transfer is false, substate_id will be ignored
48: * @return An implementation of Channel which keeps track of the id, so that it can be attached to each message
49: * and be properly dispatched at the receiver. This will be a {@link org.jgroups.mux.MuxChannel}.
50: * @throws ChannelException
51: */
52: Channel createMultiplexerChannel(String stack_name, String id,
53: boolean register_for_state_transfer, String substate_id)
54: throws Exception;
55:
56: Channel createMultiplexerChannel(String stack_name, String id)
57: throws Exception;
58:
59: Channel createChannel(Object props) throws ChannelException;
60:
61: /** Create a new channel with the properties defined in the factory */
62: Channel createChannel() throws ChannelException;
63: }
|