org.objectweb.dream.channel
Class IPSocketManagerCachingImpl

java.lang.Object
  extended byorg.objectweb.dream.AbstractComponent
      extended byorg.objectweb.dream.channel.IPSocketManagerCachingImpl
All Implemented Interfaces:
AttributeController, BindingController, IPSocketManager, IPSocketManagerCachingAttributeController, LifeCycleController, Loggable

public class IPSocketManagerCachingImpl
extends AbstractComponent
implements IPSocketManager, IPSocketManagerCachingAttributeController

This component manage a cache of SocketState.


Nested Class Summary
protected  class IPSocketManagerCachingImpl.CacheEntry
           
 
Field Summary
protected  boolean blocking
           
protected  Map cache
           
static String DELEGATE_IP_SOCKET_MANAGER
          The name of the client interface used to retreive a socket when it can't be found in the cache.
protected  IPSocketManager delegateSocketManagerItf
           
protected  IPSocketManagerCachingImpl.CacheEntry lruHead
           
protected  IPSocketManagerCachingImpl.CacheEntry lruTail
           
protected  int nbMaxSocket
           
protected  IPSocketManagerCachingImpl.CacheEntry reusableKey
           
protected  Map reversCache
           
 
Fields inherited from class org.objectweb.dream.AbstractComponent
bindingLogger, componentDesc, fcState, firstStart, lifeCycleLogger, logger, weaveableC
 
Fields inherited from interface org.objectweb.dream.channel.IPSocketManager
ITF_NAME
 
Fields inherited from interface org.objectweb.fractal.api.control.LifeCycleController
STARTED, STOPPED
 
Constructor Summary
IPSocketManagerCachingImpl()
           
 
Method Summary
 void bindFc(String clientItfName, Object serverItf)
           
 boolean getBlocking()
          Returns the blocking parameter value.
 int getNbMaxSocket()
          Returns the number of maximum open sockets.
 SocketState getSocket(InetAddress address, int port)
          Returns a socket that can be used to send message to the ChannelIn identified by the given IP address and port.
 String[] listFc()
           
 void releaseSocket(SocketState socketState, boolean error)
          Releases the given SocketStateImpl.
 void setBlocking(boolean blocking)
          Sets the blocking property of this IPSocketManager.
 void setNbMaxSocket(int nbMaxSocket)
          Sets the nbMaxSocket attribute value.
 
Methods inherited from class org.objectweb.dream.AbstractComponent
beforeFirstStart, getFcState, initComponent, lookupFc, setLogger, startFc, stopFc, unbindFc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELEGATE_IP_SOCKET_MANAGER

public static final String DELEGATE_IP_SOCKET_MANAGER
The name of the client interface used to retreive a socket when it can't be found in the cache.

See Also:
Constant Field Values

reusableKey

protected IPSocketManagerCachingImpl.CacheEntry reusableKey

cache

protected Map cache

reversCache

protected Map reversCache

lruHead

protected IPSocketManagerCachingImpl.CacheEntry lruHead

lruTail

protected IPSocketManagerCachingImpl.CacheEntry lruTail

blocking

protected boolean blocking

nbMaxSocket

protected int nbMaxSocket

delegateSocketManagerItf

protected IPSocketManager delegateSocketManagerItf
Constructor Detail

IPSocketManagerCachingImpl

public IPSocketManagerCachingImpl()
Method Detail

getSocket

public SocketState getSocket(InetAddress address,
                             int port)
                      throws IOException,
                             InterruptedException
Description copied from interface: IPSocketManager
Returns a socket that can be used to send message to the ChannelIn identified by the given IP address and port.

Specified by:
getSocket in interface IPSocketManager
Parameters:
address - the address of the ChannelIn.
port - the port of the ChannelIn.
Returns:
a connection to the ChannelIn.
Throws:
InterruptedException - if the component is interrupted while waiting for a socket to be released.
IOException - if the socket can't be opened.
See Also:
IPSocketManager.getSocket(InetAddress, int)

releaseSocket

public void releaseSocket(SocketState socketState,
                          boolean error)
Description copied from interface: IPSocketManager
Releases the given SocketStateImpl.

Specified by:
releaseSocket in interface IPSocketManager
Parameters:
socketState - the socket state to release.
error - true if an exception has been catched while sending the message, false otherwise.
See Also:
IPSocketManager.releaseSocket(SocketState, boolean)

getNbMaxSocket

public int getNbMaxSocket()
Description copied from interface: IPSocketManagerCachingAttributeController
Returns the number of maximum open sockets.

Specified by:
getNbMaxSocket in interface IPSocketManagerCachingAttributeController
Returns:
the nbMaxSocket attribute value.
See Also:
IPSocketManagerCachingAttributeController.getNbMaxSocket()

setNbMaxSocket

public void setNbMaxSocket(int nbMaxSocket)
Description copied from interface: IPSocketManagerCachingAttributeController
Sets the nbMaxSocket attribute value.

Specified by:
setNbMaxSocket in interface IPSocketManagerCachingAttributeController
Parameters:
nbMaxSocket - the new nbMaxSocket attribute value.
See Also:
IPSocketManagerCachingAttributeController.setNbMaxSocket(int)

setBlocking

public void setBlocking(boolean blocking)
Description copied from interface: IPSocketManagerCachingAttributeController
Sets the blocking property of this IPSocketManager. If blocking is set to true then the manager waits if the required socket is in use. Otherwise, it raises an exeption.

Specified by:
setBlocking in interface IPSocketManagerCachingAttributeController
Parameters:
blocking - the boolean value to set.
See Also:
IPSocketManagerCachingAttributeController.setBlocking(boolean)

getBlocking

public boolean getBlocking()
Description copied from interface: IPSocketManagerCachingAttributeController
Returns the blocking parameter value.

Specified by:
getBlocking in interface IPSocketManagerCachingAttributeController
Returns:
the blocking parameter value.
See Also:
IPSocketManagerCachingAttributeController.getBlocking()

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
Throws:
NoSuchInterfaceException
IllegalBindingException
IllegalLifeCycleException
See Also:
BindingController.bindFc(String, Object)


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