net.xoetrope.optional.service
Class ServiceProxy

java.lang.Object
  extended by net.xoetrope.optional.service.ServiceProxy

public abstract class ServiceProxy
extends java.lang.Object

The basis of each element in the service proxy stack.

Copyright (c) Xoetrope Ltd., 2001-2006, see license.txt for details


Field Summary
static java.lang.String ARG_OPTION_FALSE
           
static java.lang.String ARG_OPTION_TRUE
           
protected  boolean available
           
static java.lang.Integer COMPLETE
          The call has ended
protected  XExceptionHandler exceptionHandler
           
static java.lang.Integer FAILED
          The call has failed
protected  ServiceProxy nextProxy
          The next proxy in the route
static java.lang.Integer OK
          Call is OK
static java.lang.Integer PENDING
          The call is pending
static java.lang.String RETURN_VALUE
          The default service call's return value location in the return params.
protected  java.lang.String routeName
          The name of the route of which this ServiceProxy is a layer
protected  java.lang.String serviceName
          The name of the service being called
protected  int side
          is this instance of the layer on the client or the server?
static java.lang.Integer STARTED
          The call has been started
protected  java.lang.Integer status
          The status of the ServiceProxy call
 
Constructor Summary
ServiceProxy()
           
 
Method Summary
 java.lang.Object call()
          Calls call( null, null ) Services should place data they wish to return in the ServiceContext.
abstract  java.lang.Object call(java.lang.String method, ServiceContext context)
          Call this proxy with the specified arguments.
 java.lang.Object callNextProxy(java.lang.String method, ServiceContext context, java.lang.Object ret)
          Utility function to call the next ServiceProxy if it is not null.
protected  java.lang.String getRouteName()
          Retrieve the name of the proxy route.
protected  java.lang.String getServiceName()
          Retrieves the service name.
protected  int getSide()
          Retrieve the side of the proxy (Client or Server)
 java.lang.Integer getStatus()
          Retrieves the current state of the proxy
 boolean isAvailable()
          Check if the proxy is available
 void setAttributes(java.util.Hashtable t)
          Set the attributes for this service proxy.
 void setAvailable(boolean state)
          Set teh available state of the proxy
 void setExceptionHandler(XExceptionHandler handler)
          Set an exception handler for the ServiceProxy
 void setNextProxy(ServiceProxy sp)
          Set the next ServiceProxy in the route.
 void setRouteName(java.lang.String route)
          Set the name of the proxy route
 void setServiceName(java.lang.String name)
          Sets the proxy service name
 void setSide(int activeSide)
          Sets the side on which the proxy resides (Client or Server)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OK

public static final java.lang.Integer OK
Call is OK


STARTED

public static final java.lang.Integer STARTED
The call has been started


PENDING

public static final java.lang.Integer PENDING
The call is pending


COMPLETE

public static final java.lang.Integer COMPLETE
The call has ended


FAILED

public static final java.lang.Integer FAILED
The call has failed


routeName

protected java.lang.String routeName
The name of the route of which this ServiceProxy is a layer


serviceName

protected java.lang.String serviceName
The name of the service being called


status

protected java.lang.Integer status
The status of the ServiceProxy call


nextProxy

protected ServiceProxy nextProxy
The next proxy in the route


side

protected int side
is this instance of the layer on the client or the server?


exceptionHandler

protected XExceptionHandler exceptionHandler

ARG_OPTION_TRUE

public static final java.lang.String ARG_OPTION_TRUE
See Also:
Constant Field Values

ARG_OPTION_FALSE

public static final java.lang.String ARG_OPTION_FALSE
See Also:
Constant Field Values

RETURN_VALUE

public static final java.lang.String RETURN_VALUE
The default service call's return value location in the return params.

See Also:
Constant Field Values

available

protected boolean available
Constructor Detail

ServiceProxy

public ServiceProxy()
Method Detail

call

public java.lang.Object call()
                      throws ServiceProxyException
Calls call( null, null ) Services should place data they wish to return in the ServiceContext. The RETURN_PARAM is the default location for a single return value.

Returns:
the status of the service call
Throws:
ServiceProxyException - Throw a ServiceProxyException if there is a problem

call

public abstract java.lang.Object call(java.lang.String method,
                                      ServiceContext context)
                               throws ServiceProxyException
Call this proxy with the specified arguments. Services should place data they wish to return in the ServiceContext. The RETURN_PARAM is the default location for a single return value.

Parameters:
context - The ServiceContext contain pass and return parameters
method - the name of the service being called
Returns:
the status of the service call
Throws:
ServiceProxyException - Throw an exception if there is a problem with the call

callNextProxy

public java.lang.Object callNextProxy(java.lang.String method,
                                      ServiceContext context,
                                      java.lang.Object ret)
                               throws ServiceProxyException
Utility function to call the next ServiceProxy if it is not null.

Parameters:
context - The ServiceContext contain pass and return parameters
method - the name of the service being called
ret - the return object if the next proxy is null
Returns:
the passed return object or the result of the proxy call
Throws:
ServiceProxyException - Throw an exception if there is a problem with the call

getStatus

public java.lang.Integer getStatus()
Retrieves the current state of the proxy

Returns:
the proxy state

setSide

public void setSide(int activeSide)
Sets the side on which the proxy resides (Client or Server)

Parameters:
activeSide - the side of the proxy

getSide

protected int getSide()
Retrieve the side of the proxy (Client or Server)

Returns:
the proxy instance side

getRouteName

protected java.lang.String getRouteName()
Retrieve the name of the proxy route.

Returns:
the route name

setRouteName

public void setRouteName(java.lang.String route)
Set the name of the proxy route

Parameters:
route - the route name

getServiceName

protected java.lang.String getServiceName()
Retrieves the service name.

Returns:
the name of the proxy service

setServiceName

public void setServiceName(java.lang.String name)
Sets the proxy service name

Parameters:
name - the proxy service name

setNextProxy

public void setNextProxy(ServiceProxy sp)
Set the next ServiceProxy in the route.

Parameters:
sp - the next ServiceProxy in the route

setAttributes

public void setAttributes(java.util.Hashtable t)
Set the attributes for this service proxy.

Parameters:
t - The Hashtable of attributes as found in the XML declaration

setExceptionHandler

public void setExceptionHandler(XExceptionHandler handler)
Set an exception handler for the ServiceProxy

Parameters:
handler - The XExceptionHandler which will take care of problems.

isAvailable

public boolean isAvailable()
Check if the proxy is available

Returns:
true if the proxy can be used and is available

setAvailable

public void setAvailable(boolean state)
Set teh available state of the proxy

Parameters:
state - true if the proxy can be used and is available