org.exoplatform.services.jcr.ext.replication
Class ChannelManager

java.lang.Object
  extended by org.exoplatform.services.jcr.ext.replication.ChannelManager
All Implemented Interfaces:
org.jgroups.blocks.RequestHandler

public class ChannelManager
extends java.lang.Object
implements org.jgroups.blocks.RequestHandler

Created by The eXo Platform SAS.

Version:
$Id: ChannelManager.java 49631 2010-07-22 10:44:40Z paristote $
Author:
Alex Reshetnyak

Nested Class Summary
protected  class ChannelManager.PacketHandler
          PacketHandler.
 
Field Summary
static int CONNECTED
          The connected state.
static int DISCONNECTED
          The disconnected state.
static int INITIALIZED
          The initialized state.
protected  ChannelManager.PacketHandler packetsHandler
          Packets handler.
protected  int state
          State of async channel manager {INITIALIZED, CONNECTED, DISCONNECTED}.
 
Constructor Summary
ChannelManager(java.lang.String channelConfig, java.lang.String channelName)
          ChannelManager constructor.
 
Method Summary
 void addPacketListener(PacketListener packetListener)
          addPacketListener.
 void closeChannel()
          closeChannel.
 void connect()
          connect.
 org.jgroups.JChannel getChannel()
          getChannel.
 org.jgroups.blocks.MessageDispatcher getDispatcher()
          getDispatcher.
 java.lang.Object handle(org.jgroups.Message message)
          
 void init()
          init.
 boolean isConnected()
          Tell if manager is connected to the channel and ready to work.
 void send(byte[] buffer)
          send.
 void sendBigPacket(byte[] data, Packet packet)
          sendBigPacket.
 void sendBinaryFile(java.lang.String filePath, java.lang.String ownerName, java.lang.String identifier, java.lang.String systemId, int firstPacketType, int middlePocketType, int lastPocketType)
          sendBinaryFile.
 void sendPacket(Packet packet)
          sendPacket.
 void setAllowConnect(boolean allowConnect)
          setAllowConnect.
 void setAllowConnect(boolean allowConnect, int id)
          setAllowConnect.
 void setChannelListener(org.jgroups.ChannelListener channelListener)
          setChannelListener.
 void setMembershipListener(org.jgroups.MembershipListener membershipListener)
          setMembershipListener.
 void setMessageListener(org.jgroups.MessageListener messageListener)
          setMessageListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIALIZED

public static final int INITIALIZED
The initialized state.

See Also:
Constant Field Values

CONNECTED

public static final int CONNECTED
The connected state.

See Also:
Constant Field Values

DISCONNECTED

public static final int DISCONNECTED
The disconnected state.

See Also:
Constant Field Values

state

protected int state
State of async channel manager {INITIALIZED, CONNECTED, DISCONNECTED}.


packetsHandler

protected final ChannelManager.PacketHandler packetsHandler
Packets handler.

Constructor Detail

ChannelManager

public ChannelManager(java.lang.String channelConfig,
                      java.lang.String channelName)
ChannelManager constructor.

Parameters:
channelConfig - channel configuration
channelName - name of channel
Method Detail

isConnected

public boolean isConnected()
Tell if manager is connected to the channel and ready to work.

Returns:
boolean, true if connected

init

public void init()
          throws ReplicationException
init. Will be initialized JChannel and MessageDispatcher.

Throws:
ReplicationException - Will be generated the ReplicationException.

connect

public void connect()
             throws ReplicationException
connect. Connect to channel.

Throws:
ReplicationException - Will be generated the ReplicationException.

closeChannel

public void closeChannel()
closeChannel. Close the channel.


setMembershipListener

public void setMembershipListener(org.jgroups.MembershipListener membershipListener)
setMembershipListener.

Parameters:
membershipListener - set the MembershipListener

setMessageListener

public void setMessageListener(org.jgroups.MessageListener messageListener)
setMessageListener.

Parameters:
messageListener - set the MessageListener

addPacketListener

public void addPacketListener(PacketListener packetListener)
addPacketListener.

Parameters:
packetListener - add the PacketListener

setChannelListener

public void setChannelListener(org.jgroups.ChannelListener channelListener)
setChannelListener.

Parameters:
channelListener - set the ChannelListener

getDispatcher

public org.jgroups.blocks.MessageDispatcher getDispatcher()
getDispatcher.

Returns:
MessageDispatcher return the MessageDispatcher object

sendPacket

public void sendPacket(Packet packet)
                throws java.lang.Exception
sendPacket.

Parameters:
packet - the Packet with content
Throws:
java.lang.Exception - will be generated Exception

getChannel

public org.jgroups.JChannel getChannel()
getChannel.

Returns:
JChannel return the JChannel object

send

public void send(byte[] buffer)
send.

Parameters:
buffer - the binary data

sendBigPacket

public void sendBigPacket(byte[] data,
                          Packet packet)
                   throws java.lang.Exception
sendBigPacket.

Parameters:
data - the binary data
packet - the Packet
Throws:
java.lang.Exception - will be generated Exception

sendBinaryFile

public void sendBinaryFile(java.lang.String filePath,
                           java.lang.String ownerName,
                           java.lang.String identifier,
                           java.lang.String systemId,
                           int firstPacketType,
                           int middlePocketType,
                           int lastPocketType)
                    throws java.lang.Exception
sendBinaryFile.

Parameters:
filePath - full path to file
ownerName - owner name
identifier - the identifier String
systemId - system identifications ID
firstPacketType - the packet type for first packet
middlePocketType - the packet type for middle packets
lastPocketType - the packet type for last packet
Throws:
java.lang.Exception - will be generated the Exception

handle

public java.lang.Object handle(org.jgroups.Message message)

Specified by:
handle in interface org.jgroups.blocks.RequestHandler

setAllowConnect

public void setAllowConnect(boolean allowConnect)
setAllowConnect.

Parameters:
allowConnect - allow connection state(true or false)

setAllowConnect

public void setAllowConnect(boolean allowConnect,
                            int id)
setAllowConnect.

Parameters:
allowConnect - allow connection state(true or false)
id - channel id


Copyright © 2010 eXo Platform SAS. All Rights Reserved.