org.eclipse.net4j.signal
Class SignalProtocol<INFRA_STRUCTURE>

java.lang.Object
  extended by org.eclipse.net4j.util.event.Notifier
      extended by org.eclipse.net4j.util.lifecycle.Lifecycle
          extended by org.eclipse.spi.net4j.Protocol<INFRA_STRUCTURE>
              extended by org.eclipse.net4j.signal.SignalProtocol<INFRA_STRUCTURE>
All Implemented Interfaces:
IBufferHandler, ILocationAware, IProtocol<INFRA_STRUCTURE>, ISignalProtocol<INFRA_STRUCTURE>, INotifier, ILifecycle, IUserAware
Direct Known Subclasses:
HeartBeatProtocol, HeartBeatProtocol.Server

public class SignalProtocol<INFRA_STRUCTURE>
extends org.eclipse.spi.net4j.Protocol<INFRA_STRUCTURE>
implements ISignalProtocol<INFRA_STRUCTURE>


Nested Class Summary
static class SignalProtocol.TimeoutChangedEvent
           
 
Nested classes/interfaces inherited from interface org.eclipse.net4j.ILocationAware
ILocationAware.Location
 
Field Summary
static short SIGNAL_MONITOR_CANCELED
           
static short SIGNAL_MONITOR_PROGRESS
           
static short SIGNAL_REMOTE_EXCEPTION
           
static short SIGNAL_SET_TIMEOUT
           
 
Fields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle
USE_LABEL
 
Fields inherited from interface org.eclipse.net4j.signal.ISignalProtocol
DEFAULT_TIMEOUT, NO_TIMEOUT
 
Constructor Summary
SignalProtocol(String type)
           
 
Method Summary
 void addStreamWrapper(IStreamWrapper streamWrapper)
           
 void close()
           
protected  SignalReactor createSignalReactor(short signalID)
          Returns a new signal instance to serve the given signal ID or null if the signal ID is invalid/unknown for this protocol.
protected  void doAfterActivate()
           
protected  void doBeforeDeactivate()
           
protected  void doDeactivate()
           
 IStreamWrapper getStreamWrapper()
           
 long getTimeout()
           
 void handleBuffer(IBuffer buffer)
          Handles a given (incoming) buffer.
protected  void handleChannelDeactivation()
           
protected  boolean isSendingTimeoutChanges()
          Returns true by default, override to change this behaviour.
 IChannel open(IConnector connector)
           
protected  SignalReactor provideSignalReactor(short signalID)
           
 void setStreamWrapper(IStreamWrapper streamWrapper)
           
 void setTimeout(long timeout)
           
 String toString()
           
 boolean waitForSignals(long timeout)
           
 
Methods inherited from class org.eclipse.spi.net4j.Protocol
doBeforeActivate, getBufferProvider, getChannel, getExecutorService, getInfraStructure, getLocation, getType, getUserID, isClient, isServer, setChannel, setExecutorService, setInfraStructure, setUserID
 
Methods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle
activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doActivate, dump, getLifecycleState, isActive, isDeferredActivation
 
Methods inherited from class org.eclipse.net4j.util.event.Notifier
addListener, fireEvent, fireEvent, fireEvent, firstListenerAdded, getListeners, getNotificationService, hasListeners, lastListenerRemoved, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.net4j.protocol.IProtocol
getBufferProvider, getChannel, getExecutorService, getInfraStructure, getType, setChannel, setExecutorService, setInfraStructure
 
Methods inherited from interface org.eclipse.net4j.util.security.IUserAware
getUserID
 
Methods inherited from interface org.eclipse.net4j.ILocationAware
getLocation, isClient, isServer
 
Methods inherited from interface org.eclipse.net4j.util.event.INotifier
addListener, getListeners, hasListeners, removeListener
 

Field Detail

SIGNAL_REMOTE_EXCEPTION

public static final short SIGNAL_REMOTE_EXCEPTION
Since:
2.0
See Also:
Constant Field Values

SIGNAL_MONITOR_CANCELED

public static final short SIGNAL_MONITOR_CANCELED
Since:
2.0
See Also:
Constant Field Values

SIGNAL_MONITOR_PROGRESS

public static final short SIGNAL_MONITOR_PROGRESS
Since:
2.0
See Also:
Constant Field Values

SIGNAL_SET_TIMEOUT

public static final short SIGNAL_SET_TIMEOUT
Since:
4.1
See Also:
Constant Field Values
Constructor Detail

SignalProtocol

public SignalProtocol(String type)
Since:
2.0
Method Detail

getTimeout

public long getTimeout()
Specified by:
getTimeout in interface ISignalProtocol<INFRA_STRUCTURE>
Since:
2.0

setTimeout

public void setTimeout(long timeout)
Specified by:
setTimeout in interface ISignalProtocol<INFRA_STRUCTURE>
Since:
2.0

getStreamWrapper

public IStreamWrapper getStreamWrapper()
Specified by:
getStreamWrapper in interface ISignalProtocol<INFRA_STRUCTURE>

setStreamWrapper

public void setStreamWrapper(IStreamWrapper streamWrapper)
Specified by:
setStreamWrapper in interface ISignalProtocol<INFRA_STRUCTURE>

addStreamWrapper

public void addStreamWrapper(IStreamWrapper streamWrapper)
Specified by:
addStreamWrapper in interface ISignalProtocol<INFRA_STRUCTURE>

open

public IChannel open(IConnector connector)
Specified by:
open in interface ISignalProtocol<INFRA_STRUCTURE>
Since:
2.0

close

public void close()
Specified by:
close in interface ISignalProtocol<INFRA_STRUCTURE>
Since:
2.0

waitForSignals

public boolean waitForSignals(long timeout)

handleBuffer

public void handleBuffer(IBuffer buffer)
Handles a given (incoming) buffer. Creates a signal to act upon the given buffer or uses a previously created signal.

Specified by:
handleBuffer in interface IBufferHandler
Parameters:
buffer - The buffer to be handled and otionally released.

toString

public String toString()
Overrides:
toString in class Lifecycle

doAfterActivate

protected void doAfterActivate()
                        throws Exception
Overrides:
doAfterActivate in class Lifecycle
Throws:
Exception

doBeforeDeactivate

protected void doBeforeDeactivate()
                           throws Exception
Overrides:
doBeforeDeactivate in class Lifecycle
Throws:
Exception

doDeactivate

protected void doDeactivate()
                     throws Exception
Overrides:
doDeactivate in class org.eclipse.spi.net4j.Protocol<INFRA_STRUCTURE>
Throws:
Exception

handleChannelDeactivation

protected void handleChannelDeactivation()
Overrides:
handleChannelDeactivation in class org.eclipse.spi.net4j.Protocol<INFRA_STRUCTURE>

provideSignalReactor

protected final SignalReactor provideSignalReactor(short signalID)

createSignalReactor

protected SignalReactor createSignalReactor(short signalID)
Returns a new signal instance to serve the given signal ID or null if the signal ID is invalid/unknown for this protocol.


isSendingTimeoutChanges

protected boolean isSendingTimeoutChanges()
Returns true by default, override to change this behaviour.

Since:
4.1


Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.