Class JChannelFactory
- java.lang.Object
-
- org.jgroups.JChannelFactory
-
- All Implemented Interfaces:
ChannelFactory
public class JChannelFactory extends java.lang.Object implements ChannelFactory
JChannelFactory creates pure Java implementations of theChannelinterface. SeeJChannelfor a discussion of channel properties.
-
-
Constructor Summary
Constructors Constructor Description JChannelFactory()Constructs aJChannelFactoryinstance that contains no protocol stack configuration.JChannelFactory(java.io.File properties)Constructs aJChannelFactoryinstance that utilizes the specified file for protocl stack configuration.JChannelFactory(java.lang.String properties)Constructs aJChannelinstance with the protocol stack configuration based upon the specified properties parameter.JChannelFactory(java.net.URL properties)Constructs aJChannelFactoryinstance that utilizes the specified file for protocl stack configuration.JChannelFactory(org.w3c.dom.Element properties)Constructs aJChannelFactoryinstance that utilizes the specified file for protocl stack configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclearConfigurations()Removes all configurationsvoidcreate()ChannelcreateChannel()Creates aJChannelimplementation of theChannelinterface using the protocol stack configuration information specfied during construction of an instance of this factory.ChannelcreateChannel(java.lang.Object properties)Deprecated.JChannel's conversion to type-specific construction, and the subsequent deprecation of itsJChannel(Object)constructor, necessitate the deprecation of this factory method as well.ChannelcreateChannel(java.lang.String stack_name)ChannelcreateMultiplexerChannel(java.lang.String stack_name, java.lang.String id)Creates an implementation of the Channel using a given stack name and registering it under a given identity.ChannelcreateMultiplexerChannel(java.lang.String stack_name, java.lang.String id, boolean register_for_state_transfer, java.lang.String substate_id)Creates an implementation of the Channel using a given stack name and registering it under a given identity.voiddestroy()java.lang.StringdumpChannels()java.lang.StringdumpConfiguration()java.lang.StringgetConfig(java.lang.String stack_name)Returns the stack configuration as a string (to be fed into new JChannel()).java.lang.StringgetDomain()java.lang.StringgetMultiplexerConfig()javax.management.MBeanServergetServer()booleanhasMuxChannel(java.lang.String stack_name, java.lang.String id)Returns true if this factory has already registered MuxChannel with given stack_name and an id, false otherwise.booleanisExposeChannels()booleanisExposeProtocols()booleanremoveConfig(java.lang.String stack_name)voidsetDomain(java.lang.String domain)voidsetExposeChannels(boolean expose_channels)voidsetExposeProtocols(boolean expose_protocols)voidsetMultiplexerConfig(java.io.File file)Initializes the factory from a file.voidsetMultiplexerConfig(java.io.File file, boolean replace)voidsetMultiplexerConfig(java.lang.Object properties)Initializes the factory.voidsetMultiplexerConfig(java.lang.Object properties, boolean replace)voidsetMultiplexerConfig(java.lang.String properties)voidsetMultiplexerConfig(java.lang.String properties, boolean replace)voidsetMultiplexerConfig(java.net.URL url)voidsetMultiplexerConfig(java.net.URL url, boolean replace)voidsetMultiplexerConfig(org.w3c.dom.Element properties)voidsetMultiplexerConfig(org.w3c.dom.Element properties, boolean replace)voidsetServer(javax.management.MBeanServer server)voidstart()voidstop()
-
-
-
Constructor Detail
-
JChannelFactory
public JChannelFactory()
Constructs aJChannelFactoryinstance that contains no protocol stack configuration.
-
JChannelFactory
public JChannelFactory(java.io.File properties) throws ChannelExceptionConstructs aJChannelFactoryinstance that utilizes the specified file for protocl stack configuration.- Parameters:
properties- a file containing a JGroups XML protocol stack configuration.- Throws:
ChannelException- if problems occur during the interpretation of the protocol stack configuration.
-
JChannelFactory
public JChannelFactory(org.w3c.dom.Element properties) throws ChannelExceptionConstructs aJChannelFactoryinstance that utilizes the specified file for protocl stack configuration.- Parameters:
properties- a XML element containing a JGroups XML protocol stack configuration.- Throws:
ChannelException- if problems occur during the interpretation of the protocol stack configuration.
-
JChannelFactory
public JChannelFactory(java.net.URL properties) throws ChannelExceptionConstructs aJChannelFactoryinstance that utilizes the specified file for protocl stack configuration.- Parameters:
properties- a URL pointing to a JGroups XML protocol stack configuration.- Throws:
ChannelException- if problems occur during the interpretation of the protocol stack configuration.
-
JChannelFactory
public JChannelFactory(java.lang.String properties) throws ChannelExceptionConstructs aJChannelinstance with the protocol stack configuration based upon the specified properties parameter.- Parameters:
properties- an old style property string, a string representing a system resource containing a JGroups XML configuration, a string representing a URL pointing to a JGroups XML XML configuration, or a string representing a file name that contains a JGroups XML configuration.- Throws:
ChannelException- if problems occur during the interpretation of the protocol stack configuration.
-
-
Method Detail
-
setMultiplexerConfig
public void setMultiplexerConfig(java.lang.Object properties) throws java.lang.ExceptionDescription copied from interface:ChannelFactoryInitializes the factory.- Specified by:
setMultiplexerConfigin interfaceChannelFactory- Throws:
ChannelExceptionjava.lang.Exception
-
setMultiplexerConfig
public void setMultiplexerConfig(java.lang.Object properties, boolean replace) throws java.lang.Exception- Throws:
java.lang.Exception
-
setMultiplexerConfig
public void setMultiplexerConfig(java.io.File file) throws java.lang.ExceptionDescription copied from interface:ChannelFactoryInitializes the factory from a file. Example: conf/stacks.xml- Specified by:
setMultiplexerConfigin interfaceChannelFactory- Throws:
ChannelExceptionjava.lang.Exception
-
setMultiplexerConfig
public void setMultiplexerConfig(java.io.File file, boolean replace) throws java.lang.Exception- Throws:
java.lang.Exception
-
setMultiplexerConfig
public void setMultiplexerConfig(org.w3c.dom.Element properties) throws java.lang.Exception- Specified by:
setMultiplexerConfigin interfaceChannelFactory- Throws:
java.lang.Exception
-
setMultiplexerConfig
public void setMultiplexerConfig(org.w3c.dom.Element properties, boolean replace) throws java.lang.Exception- Throws:
java.lang.Exception
-
setMultiplexerConfig
public void setMultiplexerConfig(java.net.URL url) throws java.lang.Exception- Specified by:
setMultiplexerConfigin interfaceChannelFactory- Throws:
java.lang.Exception
-
setMultiplexerConfig
public void setMultiplexerConfig(java.net.URL url, boolean replace) throws java.lang.Exception- Throws:
java.lang.Exception
-
setMultiplexerConfig
public void setMultiplexerConfig(java.lang.String properties) throws java.lang.Exception- Specified by:
setMultiplexerConfigin interfaceChannelFactory- Throws:
java.lang.Exception
-
setMultiplexerConfig
public void setMultiplexerConfig(java.lang.String properties, boolean replace) throws java.lang.Exception- Throws:
java.lang.Exception
-
getConfig
public java.lang.String getConfig(java.lang.String stack_name) throws java.lang.ExceptionReturns the stack configuration as a string (to be fed into new JChannel()). Throws an exception if the stack_name is not found. One of the setMultiplexerConfig() methods had to be called beforehand- Returns:
- The protocol stack config as a plain string
- Throws:
java.lang.Exception
-
getMultiplexerConfig
public java.lang.String getMultiplexerConfig()
- Returns:
- Returns all configurations
-
clearConfigurations
public void clearConfigurations()
Removes all configurations
-
removeConfig
public boolean removeConfig(java.lang.String stack_name)
-
getServer
public javax.management.MBeanServer getServer()
-
setServer
public void setServer(javax.management.MBeanServer server)
-
getDomain
public java.lang.String getDomain()
-
setDomain
public void setDomain(java.lang.String domain)
-
isExposeChannels
public boolean isExposeChannels()
-
setExposeChannels
public void setExposeChannels(boolean expose_channels)
-
isExposeProtocols
public boolean isExposeProtocols()
-
setExposeProtocols
public void setExposeProtocols(boolean expose_protocols)
-
createChannel
public Channel createChannel(java.lang.Object properties) throws ChannelException
Deprecated.JChannel's conversion to type-specific construction, and the subsequent deprecation of itsJChannel(Object)constructor, necessitate the deprecation of this factory method as well. Type-specific protocol stack configuration should be specfied during construction of an instance of this factory.Creates aJChannelimplementation of theChannelinterface.- Specified by:
createChannelin interfaceChannelFactory- Parameters:
properties- the protocol stack configuration information; anullvalue means use the default protocol stack configuration.- Throws:
ChannelException- if the creation of the channel failed.
-
createChannel
public Channel createChannel() throws ChannelException
Creates aJChannelimplementation of theChannelinterface using the protocol stack configuration information specfied during construction of an instance of this factory.- Specified by:
createChannelin interfaceChannelFactory- Throws:
ChannelException- if the creation of the channel failed.
-
createChannel
public Channel createChannel(java.lang.String stack_name) throws java.lang.Exception
- Specified by:
createChannelin interfaceChannelFactory- Throws:
java.lang.Exception
-
createMultiplexerChannel
public Channel createMultiplexerChannel(java.lang.String stack_name, java.lang.String id) throws java.lang.Exception
Description copied from interface:ChannelFactoryCreates an implementation of the Channel using a given stack name and registering it under a given identity.Channel has to be created with a unique application id per stack name.
Provided stack name has to be one of the stacks defined in a property file that was passed to setMultiplexerConfig (e.g conf/stacks.xml). If clients attempt to create a Channel for an undefined stack name or they attempt to register a duplicate Channel per stack an Exception will be thrown.
- Specified by:
createMultiplexerChannelin interfaceChannelFactory- Parameters:
stack_name- The name of the stack to be used. All stacks are defined in the configuration with which the factory is configured (seeChannelFactory.setMultiplexerConfig(Object)for example.id- The identifier used for multiplexing and demultiplexing (dispatching requests to one of possibly multiple receivers). Note that id needs to be a string since it will be shipped with each message. Try to pick a short string, because this is shipped with every message (overhead).- Returns:
- An implementation of Channel which keeps track of the id, so that it can be attached to each message and be properly dispatched at the receiver.
- Throws:
ChannelExceptionjava.lang.Exception- See Also:
Multiplexer,MuxChannel
-
createMultiplexerChannel
public Channel createMultiplexerChannel(java.lang.String stack_name, java.lang.String id, boolean register_for_state_transfer, java.lang.String substate_id) throws java.lang.Exception
Description copied from interface:ChannelFactoryCreates an implementation of the Channel using a given stack name and registering it under a given identity.Channel has to be created with a unique application id per stack name.
Provided stack name has to be one of the stacks defined in a property file that was passed to setMultiplexerConfig (e.g conf/stacks.xml). If clients attempt to create a Channel for an undefined stack name or they attempt to register a duplicate Channel per stack an Exception will be thrown.
Rather than having each multiplexed channel do a separate state transfer clients can bundle state transfers for all channels created with the same ChannelFactory. First of all, clients have to create Channels with register_for_state_transfer set to true. After the last Channel that was created with register_for_state_transfer set to true connects and initiates state transfer the actual state transfer for all such channels from this ChannelFactory is executed.
Using bundled state transfers is especially useful with the FLUSH protocol in a stack. Recall that each state transfer triggers a flush and thus instead of doing a separate flush for each Channel created with this ChannelFactory we execute only one flush for all state transfers.
However, be aware of the implication of asynchronous nature of bundled state transfer with the respect of channel connect. Recall that each Channel after it returns from successful getState method can assume that state is available. In case of bundled state transfer, state will be set only after the last Channel registered for the bundled state transfer connects and executes getState.
- Specified by:
createMultiplexerChannelin interfaceChannelFactory- Parameters:
stack_name- The name of the stack to be used. All stacks are defined in the configuration with which the factory is configured (seeChannelFactory.setMultiplexerConfig(Object)for example.id- The identifier used for multiplexing and demultiplexing (dispatching requests to one of possibly multiple receivers). Note that id needs to be a string since it will be shipped with each message. Try to pick a short string, because this is shipped with every message (overhead).register_for_state_transfer- If set to true, after all registered listeners called eitherChannel.connect(String, Address, String, long)orand Channel#getState(Address, long)successively on the returned Channel, the state for all registered listeners will be fetched and set in all listeners.substate_id- The ID of the sub state to be retrieved. Set this to null if the entire state should be retrieved. If register_for_state_transfer is false, substate_id will be ignored- Returns:
- An implementation of Channel which keeps track of the id, so that it can be attached to each message and be properly dispatched at the receiver.
- Throws:
ChannelExceptionjava.lang.Exception- See Also:
Multiplexer,MuxChannel
-
hasMuxChannel
public boolean hasMuxChannel(java.lang.String stack_name, java.lang.String id)Returns true if this factory has already registered MuxChannel with given stack_name and an id, false otherwise.- Parameters:
stack_name- name of the stack usedid- service id- Returns:
- true if such MuxChannel exists, false otherwise
-
create
public void create() throws java.lang.Exception- Throws:
java.lang.Exception
-
start
public void start() throws java.lang.Exception- Throws:
java.lang.Exception
-
stop
public void stop()
-
destroy
public void destroy()
-
dumpConfiguration
public java.lang.String dumpConfiguration()
-
dumpChannels
public java.lang.String dumpChannels()
-
-