@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface Callback
Environment to mark
them for exposure to computers.
Any method exposed like this can be enumerated and called from a computer
that can see the node of the environment.
Note that methods annotated with this interface must have the following
signature:
Object[] f(Context context, Arguments arguments);
The method may return null in case it doesn't wish return anything,
which is functionally equivalent to returning an empty array.
To raise an error from your callback, simply throw an exception. The
convention for Lua is to return (null, "reason") for 'soft' errors, i.e.
errors that are no fault of the caller. For example, passing invalid
arguments will generate an exception, requesting information and the lookup
of said information failing should not.| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
direct
Whether this function may be called directly from the computer's executor
thread instead of from the server thread.
|
java.lang.String |
doc
A documentation string that is made available to the computers the
component this callback belongs to is connected to.
|
int |
limit
The maximum number of direct calls that may be performed on this
component in a single tick.
|
java.lang.String |
value
The name under which to make the callback available.
|
public abstract java.lang.String value
public abstract boolean direct
Network is not thread safe!
Be sure you know what you're doing if you're working with a node's
network in a direct callback.public abstract int limit
Component.invoke(String, Context, Object...)
from the host side. Also, this limit is per-computer, so the method may
be invoked more often than this per tick, if different computers call it.
An exception to that rule is Connector.changeBuffer(double),
which is synchronized, so you can consume/produce power in direct calls.public abstract java.lang.String doc