org.objectweb.dream.protocol.messagePassing
Class UDPProtocolImpl

java.lang.Object
  extended by org.objectweb.dream.AbstractComponent
      extended by org.objectweb.dream.protocol.messagePassing.UDPProtocolImpl
All Implemented Interfaces:
ContextualBindingController, NeedAsyncStartController, PrepareStopLifeCycleController, Loggable, MessagePassingProtocol, UDPProtocol, UDPProtocolAttributeController, Protocol, AttributeController, BindingController, LifeCycleController

public class UDPProtocolImpl
extends AbstractComponent
implements UDPProtocol, UDPProtocolAttributeController

Implementation of the UDP protocol.


Nested Class Summary
protected  class UDPProtocolImpl.ReaderTask
           
protected  class UDPProtocolImpl.Session
           
 
Field Summary
protected static String hostName
           
 
Fields inherited from class org.objectweb.dream.AbstractComponent
bindingLogger, fcNeedAsyncStart, fcState, lifeCycleLogger, logger, weaveableC
 
Fields inherited from interface org.objectweb.dream.protocol.messagePassing.UDPProtocol
ADDRESS, PORT, PORT_RANGE
 
Fields inherited from interface org.objectweb.dream.protocol.messagePassing.MessagePassingProtocol
FROM_CHUNK_NAME
 
Fields inherited from interface org.objectweb.dream.protocol.Protocol
ITF_NAME, LOWER_PROTOCOL_ITF_NAME
 
Fields inherited from interface org.objectweb.fractal.api.control.LifeCycleController
STARTED, STOPPED
 
Constructor Summary
UDPProtocolImpl()
           
 
Method Summary
protected  void beforeFirstStart(Component componentItf)
           
 void bindFc(String clientItfName, Object serverItf)
           
 ExportIdentifier createExportIdentifier(Map info, ExportIdentifier[] next)
          Creates a new export identifier with the provided info
 IPExportIdentifier createExportIdentifier(String hostName, int port)
          Utility method.
 MessagePassingOutgoingPush export(IncomingPush incomingPushItf, int port, int range, String fromChunkChunk)
          Utility method.
 MessagePassingOutgoingPush export(IncomingPush incomingPushItf, Map hints)
          Creates an access point and returns an interface that can be used to send messages through it.
protected  UDPProtocolImpl.Session getAvailable()
           
 int getPort()
          Returns the default value of the UDPProtocol.PORT hint.
 int getRecvBufferSize()
          Returns the recvBufferSize attribute value.
protected  void initSession(UDPProtocolImpl.Session session)
           
 String[] listFc()
           
protected  void setAvailable(UDPProtocolImpl.Session session)
           
 void setPort(int port)
          Sets the default value of the UDPProtocol.PORT hint.
 void setRecvBufferSize(int recvBufferSize)
          Sets the size of buffer used in DatagramPacket when receiving message.
protected  void setThreadPoolManager(ThreadPoolManager threadPoolManager)
           
 
Methods inherited from class org.objectweb.dream.AbstractComponent
bindFc, getFcNeedAsyncStart, getFcState, initComponent, lookupFc, prepareStopFc, setLogger, startFc, stopFc, unbindFc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hostName

protected static String hostName
Constructor Detail

UDPProtocolImpl

public UDPProtocolImpl()
Method Detail

export

public MessagePassingOutgoingPush export(IncomingPush incomingPushItf,
                                         Map hints)
                                  throws ExportException
Description copied from interface: MessagePassingProtocol
Creates an access point and returns an interface that can be used to send messages through it. Messages received on this access point will be passed to the given IncomingPush interface.

Specified by:
export in interface MessagePassingProtocol
Parameters:
incomingPushItf - the interface on which message received on the created access point will be passed, may be null.
hints - additional parameters, can be null.
Returns:
an interface which can be used to send messages through the created access point
Throws:
ExportException - if the export process fails.
See Also:
MessagePassingProtocol.export(IncomingPush, Map)

createExportIdentifier

public ExportIdentifier createExportIdentifier(Map info,
                                               ExportIdentifier[] next)
                                        throws InvalidExportIdentifierException
Description copied from interface: Protocol
Creates a new export identifier with the provided info

Specified by:
createExportIdentifier in interface Protocol
Parameters:
info - the info used to create the export identifier.
next - the export identifier of the lower level protocols.
Returns:
a new export identifier.
Throws:
InvalidExportIdentifierException - if the export identifier can't be created.
See Also:
Protocol.createExportIdentifier(Map, ExportIdentifier[])

export

public MessagePassingOutgoingPush export(IncomingPush incomingPushItf,
                                         int port,
                                         int range,
                                         String fromChunkChunk)
                                  throws ExportException
Description copied from interface: UDPProtocol
Utility method. Creates UDP socket using the given port and range.

Specified by:
export in interface UDPProtocol
Parameters:
incomingPushItf - the interface on which message received on the created access point will be passed.
port - the port of the created UDP socket.
If null, create the UDP socket with an undetermined port.
range - the range of ports on which the UDP protocol will try to open socket.
If null, only one port will be tried before aborting. If negative, range is infinite.
fromChunkChunk - If not null a ExportIdentifierChunk will be added to every received messages (see MessagePassingProtocol.FROM_CHUNK_NAME).
Returns:
An export identifier.
Throws:
ExportException - if the export process fails.
See Also:
UDPProtocol.export(IncomingPush, int, int, String)

createExportIdentifier

public IPExportIdentifier createExportIdentifier(String hostName,
                                                 int port)
Description copied from interface: UDPProtocol
Utility method.

Specified by:
createExportIdentifier in interface UDPProtocol
See Also:
UDPProtocol.createExportIdentifier(String, int)

setAvailable

protected void setAvailable(UDPProtocolImpl.Session session)

getAvailable

protected UDPProtocolImpl.Session getAvailable()

initSession

protected void initSession(UDPProtocolImpl.Session session)

setThreadPoolManager

protected void setThreadPoolManager(ThreadPoolManager threadPoolManager)

beforeFirstStart

protected void beforeFirstStart(Component componentItf)
                         throws IllegalLifeCycleException
Overrides:
beforeFirstStart in class AbstractComponent
Throws:
IllegalLifeCycleException
See Also:
AbstractComponent.beforeFirstStart(Component)

getPort

public int getPort()
Description copied from interface: UDPProtocolAttributeController
Returns the default value of the UDPProtocol.PORT hint.

Specified by:
getPort in interface UDPProtocolAttributeController
Returns:
the port attribute's value.
See Also:
UDPProtocolAttributeController.getPort()

setPort

public void setPort(int port)
Description copied from interface: UDPProtocolAttributeController
Sets the default value of the UDPProtocol.PORT hint.

Specified by:
setPort in interface UDPProtocolAttributeController
Parameters:
port - the new port attribute's value.
See Also:
UDPProtocolAttributeController.setPort(int)

getRecvBufferSize

public int getRecvBufferSize()
Description copied from interface: UDPProtocolAttributeController
Returns the recvBufferSize attribute value.

Specified by:
getRecvBufferSize in interface UDPProtocolAttributeController
Returns:
the recvBufferSize attribute value.
See Also:
UDPProtocolAttributeController.getRecvBufferSize()

setRecvBufferSize

public void setRecvBufferSize(int recvBufferSize)
Description copied from interface: UDPProtocolAttributeController
Sets the size of buffer used in DatagramPacket when receiving message.

Specified by:
setRecvBufferSize in interface UDPProtocolAttributeController
Parameters:
recvBufferSize - the new recvBufferSize attribute value.
See Also:
UDPProtocolAttributeController.setRecvBufferSize(int)

listFc

public String[] listFc()
Specified by:
listFc in interface BindingController
See Also:
BindingController.listFc()

bindFc

public void bindFc(String clientItfName,
                   Object serverItf)
            throws NoSuchInterfaceException,
                   IllegalBindingException,
                   IllegalLifeCycleException
Specified by:
bindFc in interface BindingController
Overrides:
bindFc in class AbstractComponent
Throws:
NoSuchInterfaceException
IllegalBindingException
IllegalLifeCycleException
See Also:
BindingController.bindFc(String, Object)


Copyright © 2003, 2005 - INRIA Rhone-Alpes - All Rights Reserved.