Jive is the glue which allows Java Applets/Applications to interact with Erlang.
Java and Erlang has Jive packages which hide the socket communication from the programmer. The Java side also contains a number of wrapper classes for each Erlang variable type (see the Java Jive API).
Java Applets/Applications can interact with Erlang and:
Erlang processes can also send messages to Java objects.
Port = int()start starts the Jive server, listening to
Port. The default port for start/0 is 14000.
stop/0 stops the Jive server.
allow(all)
allow({Module,Function,Arity}) -> ServerRet
Module = Function = atom()Arity = int()ServerRet = all | {allow,{Module,Function,Arity}}allow/1 specifies from which functions processes can be spawn, or which functions to use in apply statements.
register_pid(Pid) -> ServerRet
Pid = pid()ServerRet = error | {pidid,int()}register_pid/1 enables Java to send
messages to a specific Erlang process. The pidid is
the Java client handle to an Erlang process.
unregister_pid(Pid) -> {remove,Pid}
Pid = pid()register_pid/1 inhibits Java from send messages to a specific Erlang process.
PidId = int()Pid = pid()ServerRet = error | Pidget_pid/1 gets the actual Pid associated with
a PidId. The PidId is the Java client handle
to an Erlang process.
list_to_string(List) -> {string,String}
List = String = string()list_to_string/1 converts a list to a string. Java
differentiates between lists and strings to achieve
efficiency and clarity.
string_to_list({string,String}) -> List
String = List = string()string_to_list/1 converts a string to a list. Java
differentiates between lists and strings to achieve
efficiency and clarity.
It is possible to start a Jive server using the following directives in a jive config file. This is used on embedded systems.
{jive,[{args,[Port,AllowedFunctions]}]}.
Port = int()
AllowedFunctions = [{Module,Function,Arity}]
Module = Function = atom()
Arity = int()
The Jive server listens to Port and
AllowedFunctions specifies from which functions processes can be spawn, or which functions to use in apply statements (see allow/0
above).
The following example shows a jive.config file:
[{jive,[{args,[14000,[{clock,start,2},{io,format,1}]]}]}].
The Jive server is started and listens to port 14000, allowing
clock:start/2 and io:format/1 to be used by
Java clients.
ig