gr.uoa.di.madgik.grs.proxy.local
Class LocalWriterProxy

java.lang.Object
  extended by gr.uoa.di.madgik.grs.proxy.local.LocalWriterProxy
All Implemented Interfaces:
IProxy, IWriterProxy

public class LocalWriterProxy
extends java.lang.Object
implements IWriterProxy

This proxy is an implementation of the IWriterProxy interface available to be used by writers that want to make available their authored IBuffer only to readers that are collocated in the same JVM as they are

Author:
gpapanikos

Nested Class Summary
 
Nested classes/interfaces inherited from interface gr.uoa.di.madgik.grs.proxy.IProxy
IProxy.ProxyType
 
Field Summary
 
Fields inherited from interface gr.uoa.di.madgik.grs.proxy.IProxy
ProxyScheme, ProxyStoreScheme
 
Constructor Summary
LocalWriterProxy()
          Creates a new instance
 
Method Summary
 IMirror bind()
          After setting the registry key, this method is used to retrieve the IMirror that can serve the mirroring procedure for a reader
 java.net.URI getLocator()
          Retrieves a locator through which a reader proxy can contact the IMirror serving the registered IBuffer
static boolean isOfType(java.net.URI locator)
          Checks if the provided URI is of a type that can be managed by an instance of this class.
 void setKey(java.lang.String key)
          Sets the key that was assigned to the serving IBuffer through the buffer registry
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalWriterProxy

public LocalWriterProxy()
Creates a new instance

Method Detail

setKey

public void setKey(java.lang.String key)
            throws GRS2ProxyInvalidOperationException
Sets the key that was assigned to the serving IBuffer through the buffer registry

Specified by:
setKey in interface IWriterProxy
Parameters:
key - the registry key
Throws:
GRS2ProxyInvalidOperationException - if the key is already set for this instance
See Also:
IWriterProxy.setKey(java.lang.String)

bind

public IMirror bind()
After setting the registry key, this method is used to retrieve the IMirror that can serve the mirroring procedure for a reader

Always returns null. This type of locator does not employ any IMirror instance to handle the synchronization between reader and writer as this is managed directly though the underlying IBuffer

Specified by:
bind in interface IWriterProxy
Returns:
the associated IMirror
See Also:
IWriterProxy.bind()

getLocator

public java.net.URI getLocator()
                        throws GRS2ProxyInvalidOperationException,
                               GRS2ProxyInvalidArgumentException
Retrieves a locator through which a reader proxy can contact the IMirror serving the registered IBuffer

The created uri uses the scheme of IProxy.ProxyScheme, "localhost" as the host name and sets the fragment to IProxy.ProxyType.Local.
An example of the created locator is grs2-proxy://localhost?key=13bc140f-3013-4ce1-83b4-4d57d46863b0#Local

Specified by:
getLocator in interface IWriterProxy
Returns:
the URI locator
Throws:
GRS2ProxyInvalidOperationException - if the set key is null or empty
GRS2ProxyInvalidArgumentException - if there was a problem creating the locator URI
See Also:
IWriterProxy.getLocator()

isOfType

public static boolean isOfType(java.net.URI locator)
Checks if the provided URI is of a type that can be managed by an instance of this class. It bases its checks on the URI scheme and the fragment type. An example of the URI this proxy can manage is grs2-proxy://localhost?key=13bc140f-3013-4ce1-83b4-4d57d46863b0#Local

Parameters:
locator - the locator URi that needs to be checked
Returns:
true is this proxy class can handle the locator, false otherwise