public abstract class Function extends Manageable
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.
Manageable.State
BOOTSTRAPPED, BOOTSTRAPPING, DEINITIALIZING, INITIALIZING, UNUSABLE, USABLE
Modifier | Constructor and Description |
---|---|
protected |
Function(API api,
String name,
String version)
Constructs a new
Function . |
Modifier and Type | Method and Description |
---|---|
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.
|
assertUsable, bootstrap, bootstrapImpl, deinit, deinitImpl, getState, init, initImpl, isBootstrapped, isUsable
protected Function(API api, String name, String version) throws IllegalArgumentException
Function
.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
.IllegalArgumentException
- if api == null || name == null || version == null
.public final API getAPI()
API
, not null
.public final String getName()
null
.public final boolean isEnabled()
true
if this function is currently accessible,
false
otherwise.setEnabled(boolean)
public final void setEnabled(boolean enabled)
enabled
- true
if this function should be accessible,
false
if not.isEnabled()
protected abstract FunctionResult handleCall(CallContext context) throws Throwable
context
- the context for this call, never null
.null
.Throwable
- if anything goes wrong.See http://www.xins.org/.