org.xins.server
Class Function

java.lang.Object
  extended byorg.xins.common.manageable.Manageable
      extended byorg.xins.server.Function
All Implemented Interfaces:
DefaultResultCodes

public abstract class Function
extends Manageable
implements DefaultResultCodes

Base class for function implementation classes.

A function can be enabled or disabled using the setEnabled(boolean) method. A function that is enabled can be invoked, while a function that is disabled cannot. By default a function is enabled.

Since:
XINS 1.0.0
Version:
$Revision: 1.145 $ $Date: 2006/10/24 13:18:13 $
Author:
Ernst de Haan

Nested Class Summary
 
Nested classes inherited from class org.xins.common.manageable.Manageable
Manageable.State
 
Field Summary
 
Fields inherited from class org.xins.common.manageable.Manageable
BOOTSTRAPPED, BOOTSTRAPPING, DEINITIALIZING, INITIALIZING, UNUSABLE, USABLE
 
Fields inherited from interface org.xins.server.DefaultResultCodes
_DISABLED_FUNCTION, _INTERNAL_ERROR, _INVALID_REQUEST, _INVALID_RESPONSE
 
Constructor Summary
protected Function(API api, String name, String version)
          Constructs a new Function.
 
Method Summary
 API getAPI()
          Returns the API that contains this function.
 String getName()
          Returns the name of this function.
protected abstract  FunctionResult handleCall(CallContext context)
          Handles a call to this function.
 boolean isEnabled()
          Checks if this function is currently accessible.
 void setEnabled(boolean enabled)
          Sets if this function is currently accessible.
 
Methods inherited from class org.xins.common.manageable.Manageable
assertUsable, bootstrap, bootstrapImpl, deinit, deinitImpl, getState, init, initImpl, isBootstrapped, isUsable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Function

protected Function(API api,
                   String name,
                   String version)
            throws IllegalArgumentException
Constructs a new Function.

Parameters:
api - the API to which this function belongs, not null.
name - the name, not null.
version - the version of the specification this function implements, not null.
Throws:
IllegalArgumentException - if api == null || name == null || version == null.
Method Detail

getAPI

public final API getAPI()
Returns the API that contains this function.

Returns:
the API, not null.

getName

public final String getName()
Returns the name of this function.

Returns:
the name, not null.
Since:
XINS 1.5.0.

isEnabled

public final boolean isEnabled()
Checks if this function is currently accessible.

Returns:
true if this function is currently accessible, false otherwise.
See Also:
setEnabled(boolean)

setEnabled

public final void setEnabled(boolean enabled)
Sets if this function is currently accessible.

Parameters:
enabled - true if this function should be accessible, false if not.
See Also:
isEnabled()

handleCall

protected abstract FunctionResult handleCall(CallContext context)
                                      throws Throwable
Handles a call to this function.

Parameters:
context - the context for this call, never null.
Returns:
the result of the call, never null.
Throws:
Throwable - if anything goes wrong.


See http://www.xins.org/.