org.eclipse.ecf.provider.datashare
Class BaseChannel

java.lang.Object
  extended by org.eclipse.ecf.core.sharedobject.BaseSharedObject
      extended by org.eclipse.ecf.core.sharedobject.TransactionSharedObject
          extended by org.eclipse.ecf.provider.datashare.BaseChannel
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, IIdentifiable, ISharedObject, IAbstractChannel, IChannel

public class BaseChannel
extends TransactionSharedObject
implements IChannel


Field Summary
protected  IChannelListener listener
           
static java.lang.String RECEIVER_ID_PROPERTY
           
 
Fields inherited from class org.eclipse.ecf.core.sharedobject.TransactionSharedObject
configuration, transaction
 
Fields inherited from class org.eclipse.ecf.core.sharedobject.BaseSharedObject
DESTROYREMOTE_CODE, DESTROYSELFLOCAL_CODE
 
Constructor Summary
BaseChannel()
          Replica implementation of channel class constructor
BaseChannel(ISharedObjectTransactionConfig config, IChannelListener listener)
          Primary copy implementation of channel class constructor
 
Method Summary
 void dispose()
          Dispose this channel.
 java.lang.Object getAdapter(java.lang.Class clazz)
          Override of TransactionSharedObject.getAdapter()
 IChannelListener getListener()
          Get IChannelListener instance for this IAbstractChannel
protected  ReplicaSharedObjectDescription getReplicaDescription(ID targetContainerID)
          Override of BaseSharedObject.getReplicaDescription.
protected  void initialize()
          Override of TransasctionSharedObject.initialize().
protected  void initializeReplicaChannel()
          Initialize replicas of this channel.
protected  void receiveUndeliveredChannelEvent(IChannelEvent channelEvent)
          Receive and process channel events.
 void sendMessage(byte[] message)
          Send message to remote instances of this channel
 void sendMessage(ID receiver, byte[] message)
          Send message to remote instances of this channel
protected  void setChannelListener(IChannelListener l)
           
 IChannelListener setListener(IChannelListener listener)
          Set listener to new IChannelListener instance
protected  void trace(java.lang.String msg)
           
 
Methods inherited from class org.eclipse.ecf.core.sharedobject.BaseSharedObject
addEventProcessor, clearEventProcessors, creationCompleted, destroyRemote, destroySelf, destroySelfLocal, dispose, fireEventProcessors, getConfig, getConnectedID, getContext, getGroupMemberIDs, getHomeContainerID, getID, getLocalContainerID, getProperties, getReplicaDescriptions, getSharedObjectMsgFromEvent, handleEvent, handleEvents, handleSharedObjectCreateResponseEvent, handleSharedObjectMsg, handleSharedObjectMsgEvent, handleUnhandledEvent, init, isConnected, isPrimary, log, log, removeEventProcessor, replicateToRemoteContainers, sendSharedObjectMsgTo, sendSharedObjectMsgToPrimary, sendSharedObjectMsgToSelf, trace, traceCatching, traceEntering, traceEntering, traceEntering, traceExiting, traceExiting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ecf.core.identity.IIdentifiable
getID
 

Field Detail

RECEIVER_ID_PROPERTY

public static final java.lang.String RECEIVER_ID_PROPERTY

listener

protected IChannelListener listener
Constructor Detail

BaseChannel

public BaseChannel(ISharedObjectTransactionConfig config,
                   IChannelListener listener)
Primary copy implementation of channel class constructor

Parameters:
config - the ISharedObjectTransactionConfig associated with this new host instance
listener - the listener associated with this channel instance

BaseChannel

public BaseChannel()
Replica implementation of channel class constructor

Method Detail

setChannelListener

protected void setChannelListener(IChannelListener l)

trace

protected void trace(java.lang.String msg)

initialize

protected void initialize()
                   throws SharedObjectInitException
Override of TransasctionSharedObject.initialize(). This method is called on both the host and the replicas during initialization. Subclasses that override this method should be certain to call super.initialize() as the first thing in their own initialization so they get the initialization defined by TransactionSharedObject and BaseSharedObject.

Overrides:
initialize in class TransactionSharedObject
Throws:
SharedObjectInitException - if initialization should fail

getAdapter

public java.lang.Object getAdapter(java.lang.Class clazz)
Override of TransactionSharedObject.getAdapter()

Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable
Overrides:
getAdapter in class TransactionSharedObject

sendMessage

public void sendMessage(byte[] message)
                 throws ECFException
Description copied from interface: IChannel
Send message to remote instances of this channel

Specified by:
sendMessage in interface IChannel
Parameters:
message - the byte [] message to send. Must not be null.
Throws:
ECFException - if some problem sending message

sendMessage

public void sendMessage(ID receiver,
                        byte[] message)
                 throws ECFException
Description copied from interface: IChannel
Send message to remote instances of this channel

Specified by:
sendMessage in interface IChannel
Parameters:
receiver - the ID of the container to receive message. If null, message sent to all current members of group
message - the byte [] message to send. Must not be null.
Throws:
ECFException - if some problem sending message

getListener

public IChannelListener getListener()
Description copied from interface: IAbstractChannel
Get IChannelListener instance for this IAbstractChannel

Specified by:
getListener in interface IAbstractChannel
Returns:
IChannelListener for this IAbstractChannel instance. If null, the channel has no listener.

setListener

public IChannelListener setListener(IChannelListener listener)
Description copied from interface: IAbstractChannel
Set listener to new IChannelListener instance

Specified by:
setListener in interface IAbstractChannel
Parameters:
listener - the new listener to set for this channel. If null, then there will be no new listener for this channel.
Returns:
IChannelListener that was previously the listener. If null, then then channel had no previous listener

receiveUndeliveredChannelEvent

protected void receiveUndeliveredChannelEvent(IChannelEvent channelEvent)
Receive and process channel events. This method can be overridden by subclasses to process channel events in a sub-class specific manner.

Parameters:
channelEvent - the IChannelEvent to receive and process

getReplicaDescription

protected ReplicaSharedObjectDescription getReplicaDescription(ID targetContainerID)
Override of BaseSharedObject.getReplicaDescription. Note this method should be overridden by subclasses that wish to specify the type of the replica created.

Overrides:
getReplicaDescription in class BaseSharedObject
Parameters:
targetContainerID - the ID of the target container for subsequentreplica creation. If null, the target is all current group members
Returns:
ReplicaSharedObjectDescripton to be used for creating remote replica of this host shared object. If null, no create message will be sent to the target container.

initializeReplicaChannel

protected void initializeReplicaChannel()
                                 throws SharedObjectInitException
Initialize replicas of this channel. This method is only called if isPrimary() returns false. It is called from within the initialize method, immediately after super.initialize but before the listener for this channel is notified of initialization. If this method throws a SharedObjectInitException, then initialization of the replica is halted and the remote transaction creating the replica will be aborted.

Note that this implementation checks for the existence of the RECEIVER_ID_PROPERTY on the replica's properties, and if the property contains a valid ID will

Throws:
SharedObjectInitException - if the replica initialization should fail

dispose

public void dispose()
Description copied from interface: IAbstractChannel
Dispose this channel. This method will typically be called by the enclosing container during IAbstractChannelContainerAdapter.removeChannel(org.eclipse.ecf.core.identity.ID).

Specified by:
dispose in interface IAbstractChannel