gr.uoa.di.madgik.commons.channel.proxy.local
Class LocalChannelProxy

java.lang.Object
  extended by gr.uoa.di.madgik.commons.channel.proxy.local.LocalChannelProxy
All Implemented Interfaces:
IChannelProxy

public class LocalChannelProxy
extends java.lang.Object
implements IChannelProxy

Defines a local proxy capable of mediating between an ChannelInlet and a number of ChannelOutlet that reside within the same virtual machine's address space

Author:
gpapanikos

Nested Class Summary
 
Nested classes/interfaces inherited from interface gr.uoa.di.madgik.commons.channel.proxy.IChannelProxy
IChannelProxy.ProxyConnector
 
Constructor Summary
LocalChannelProxy(IChannelLocator Locator, java.lang.String NozzleID)
          Creates a new instance.
 
Method Summary
 java.lang.Boolean CanHandleProxyLocator(IChannelLocator.LocatorType Locator)
          Checks if this proxy can handle the specific type of locator
 void Dispose()
          Disposes the proxy
 ChannelState GetChannelState()
          Retrieves the ChannelState that the proxy mediates for and is used to synchronize between the various instances of the ChannelState all connected nozzles use
 IChannelLocator GetLocator()
          Retrieves a locator to this proxy
 IChannelProxy.ProxyConnector GetProxyType()
          Retrieves the type of proxy
 java.lang.Boolean HasConnected()
          Depending on the side the IChannelProxy mediates for, this method has a slightly different meaning.
 void SetChannelRegistryKey(ChannelRegistryKey RegistryKey)
          Sets the ChannelRegistryKey this proxy will manage.
 java.lang.Boolean StillConnected()
          Depending on the side the IChannelProxy mediates for, this method has a slightly different meaning.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalChannelProxy

public LocalChannelProxy(IChannelLocator Locator,
                         java.lang.String NozzleID)
Creates a new instance. This is to be used on the ChannelOutlet side. A call to IChannelProxy.CanHandleProxyLocator(gr.uoa.di.madgik.commons.channel.proxy.IChannelLocator.LocatorType) is made to check if the locator provided can be used with this proxy instantiation. The locator that can be used with this proxy must be of type LocalChannelLocator. If either of the the two above conditions do not hold, an exception is thrown. The local registry is then looked through the ChannelRegistry.Retrieve(ChannelRegistryKey) using as key the id retrieved by IChannelLocator.GetRegistryKey(). If the channel is not registered an exception is thrown. Otherwise, a reference to the ChannelState is retrieved and stored within the proxy. Before continuing the ChannelRegistryEntry.RegisterNozzle(RegisteredNozzle) method is called to register the outlet nozzle

Parameters:
Locator - The locator this proxy should use as returned by the inlet's proxy IChannelProxy.GetLocator()
NozzleID - the id of the outlet nozzle
Method Detail

GetChannelState

public ChannelState GetChannelState()
Description copied from interface: IChannelProxy
Retrieves the ChannelState that the proxy mediates for and is used to synchronize between the various instances of the ChannelState all connected nozzles use

Specified by:
GetChannelState in interface IChannelProxy
Returns:
the channel state

CanHandleProxyLocator

public java.lang.Boolean CanHandleProxyLocator(IChannelLocator.LocatorType Locator)
Description copied from interface: IChannelProxy
Checks if this proxy can handle the specific type of locator

Specified by:
CanHandleProxyLocator in interface IChannelProxy
Parameters:
Locator - The type of Locator
Returns:
Whether or not it can handle the provided locator type

Dispose

public void Dispose()
Description copied from interface: IChannelProxy
Disposes the proxy

Specified by:
Dispose in interface IChannelProxy

GetLocator

public IChannelLocator GetLocator()
Description copied from interface: IChannelProxy
Retrieves a locator to this proxy

Specified by:
GetLocator in interface IChannelProxy
Returns:
The locator

GetProxyType

public IChannelProxy.ProxyConnector GetProxyType()
Description copied from interface: IChannelProxy
Retrieves the type of proxy

Specified by:
GetProxyType in interface IChannelProxy
Returns:
The proxy type

SetChannelRegistryKey

public void SetChannelRegistryKey(ChannelRegistryKey RegistryKey)
Description copied from interface: IChannelProxy
Sets the ChannelRegistryKey this proxy will manage. This method is called by the ChannelRegistry.Register(ChannelState, INozzleConfig, String) when called by the ChannelInlet initialization constructor. This proxy instance is passed to the nozzle's constructor through the INozzleConfig and is updated by calling the IChannelProxy.SetChannelRegistryKey(ChannelRegistryKey) from the registry's method.

Specified by:
SetChannelRegistryKey in interface IChannelProxy
Parameters:
RegistryKey - the registry key

HasConnected

public java.lang.Boolean HasConnected()
Description copied from interface: IChannelProxy
Depending on the side the IChannelProxy mediates for, this method has a slightly different meaning. On the inlet side, it checks if any outlets has been connected to the exposed channel. On the outlet side, it checks if the outlet has been connected to the inlet.

Specified by:
HasConnected in interface IChannelProxy
Returns:
Whether or not someone has been connected

StillConnected

public java.lang.Boolean StillConnected()
Description copied from interface: IChannelProxy
Depending on the side the IChannelProxy mediates for, this method has a slightly different meaning. On the inlet side, it checks if any outlets is still connected to the exposed channel. On the outlet side, it checks if the outlet is still connected to the inlet. This method should only be used after the IChannelProxy.HasConnected() has already been set to true

Specified by:
StillConnected in interface IChannelProxy
Returns:
Whether or not someone is still connected