Package com.ericsson.otp.erlang


package com.ericsson.otp.erlang

This package provides support for communication with Erlang and representation of Erlang datatypes.

Note: By default, jinterface is only guaranteed to be compatible with other Erlang/OTP components from the same release as jinterface itself. For example, jinterface from the OTP R10 release is not compatible with an Erlang emulator from the OTP R9 release by default. jinterface can be set in compatibility mode of an earlier release (not earlier that R7), though. The compatibility mode is set by usage of the OtpCompatRel property. By starting the jvm with the command-line argument -DOtpCompatRel=9, jinterface will be compatible with the R9 release of OTP. Warning! You may run into trouble if this feature is used carelessly. Always make sure that all communicating components are either from the same Erlang/OTP release, or from release X and release Y where all components from release Y are in compatibility mode of release X.

The classes OtpErlangList, OtpErlangTuple, OtpErlangBinary, OtpErlangAtom, OtpErlangBoolean, OtpErlangByte, OtpErlangChar, OtpErlangDouble, OtpErlangFloat, OtpErlangLong, OtpErlangInt, OtpErlangUInt, OtpErlangShort, OtpErlangUShort, OtpErlangString, OtpErlangObject, OtpErlangPid, OtpErlangPort, and OtpErlangRef represent the various Erlang datatypes.

There are two basic mechanisms for communicating with Erlang, described briefly here. Note that the two mechanisms are not intended to be used together. Which mechanism you choose depends on your application and the level of control it needs.

You can use OtpNode, which can manage incoming and outgoing connections for you. With OtpNode a thread is automatically started to listen for incoming connections, make necessary outgoing connections, and dispatch messages to their recipients. OtpNode supports the concept of mailboxes, allowing you to have several Java components communicating independently with Erlang.

  OtpNode node = new OtpNode("bingo");
  OtpMbox mbox = node.createMbox();
  
  mbox.send("foo@localhost",new OtpErlangAtom("hej"));

If you need more control (but less support from the library), you can manage connections yourself using the OtpSelf and OtpConnection classes, in which case you can control explicitly which connections are made and which messages are sent. Received messages are not dispatched by OtpConnection.

The classes OtpPeer, OtpSelf and OtpServer are used to represent OTP nodes and are neccessary in order to set up communication between the Java thread and a remote node. Once a connection has been established, it is represented by an OtpConnection, through which all communication goes.

Setting up a connection with a remote node is straightforward. You create objects representing the local and remote nodes, then call the local node's connect() method:

  OtpSelf self = new OtpSelf("client","cookie");
  OtpPeer other = new OtpPeer("server");
  OtpConnection conn = self.connect(other);

If you wish to be able to accept incoming connections as well as make outgoing ones, you first must register the listen port with EPMD (described in the Erlang documentation). Once that is done, you can accept incoming connections:

  OtpServer self = new OtpSelf("server","cookie");
  self.publishPort();
  OtpConnection conn = self.accept();

Once the connection is established by one of the above methods (connect() or accept()), you can use the resulting OtpConnection to send and receive messages:

  OtpErlangAtom msg = new ErlangOtpAtom("hello");
  conn.send("echoserver", msg);
  
  OtpErlangObject reply = conn.receive();
  System.out.println("Received " + reply);

Finally, you can get an even greater level of control (and even less support from the library) by subclassing AbstractConnection and implementing the communication primitives needed by your application.

  • Class
    Description
    Maintains a connection between a Java process and a remote Erlang, Java or C node.
    Represents an OTP node.
    This class implements a generic FIFO queue.
    Exception raised when a node attempts to establish a communication channel when it is not authorized to do so, or when a node sends a message containing an invalid cookie on an established channel.
    Maintains a connection between a Java process and a remote Erlang, Java or C node.
    Maintains a connection between a Java process and a remote Erlang, Java or C node.
    Provides methods for registering, unregistering and looking up nodes with the Erlang portmapper daemon (Epmd).
    Provides a Java representation of Erlang atoms.
    Provides a Java representation of Erlang binaries.
    Provides a Java representation of Erlang bitstrs.
    Provides a Java representation of Erlang booleans, which are special cases of atoms with values 'true' and 'false'.
    Provides a Java representation of Erlang integral types.
    Provides a Java representation of Erlang integral types.
    Exception raised when an attempt is made to create an Erlang term by decoding a sequence of bytes that does not represent the type of term that was requested.
    Provides a Java representation of Erlang floats and doubles.
    Base class for the other OTP erlang exception classes.
    Exception raised when a communication channel is broken.
     
    Provides a Java representation of Erlang floats and doubles.
     
    Provides a Java representation of Erlang integral types.
    Provides a Java representation of Erlang lists.
     
    Provides a Java representation of Erlang integral types.
    Provides a Java representation of Erlang maps.
    Base class of the Erlang data type classes.
     
    Provides a Java representation of Erlang PIDs.
    Provides a Java representation of Erlang ports.
    Exception raised when an attempt is made to create an Erlang term with data that is out of range for the term in question.
    Provides a Java representation of Erlang refs.
    Provides a Java representation of Erlang integral types.
    Provides a Java representation of Erlang strings.
    Provides a Java representation of Erlang tuples.
    Provides a Java representation of Erlang integral types.
    Provides a Java representation of Erlang integral types.
    Base class for the other OTP exception classes.
    Provides a collection of constants used when encoding and decoding Erlang terms.
    Provides a stream for decoding Erlang terms from external format.
    This class represents local node types.
    Provides a simple mechanism for exchanging messages with Erlang processes or other instances of this class.
    Provides a carrier for Erlang messages.
    Represents a local OTP node.
    Provides a callback mechanism for receiving status change information about other nodes in the system.
    Provides a stream for encoding Erlang terms to external format, for transmission or storage.
    Represents a remote OTP node.
    Represents an OTP node.
    Deprecated.
    the functionality of this class has been moved to OtpSelf .
    Default socket-based server transport
    Server-side connection-oriented transport interface.
    Default socket-based client transport
    Default socket-based transport factory
    Client-side connection-oriented transport interface.
    Factory class used to create client- and server-side transport instances.