eu.lindenbaum.maven.erlang
Class MavenSelf

java.lang.Object
  extended by eu.lindenbaum.maven.erlang.MavenSelf

public final class MavenSelf
extends Object

A wrapper around an OtpSelf node that acts as a connection cache for destination erlang nodes. Instantiation is guarded by the singleton pattern. To retrieve an instance call get(String). Connections retrieved by connect(String) are cached in order to return an already established connection. Thus this method can be called multiple times.

Author:
Tobias Schlager

Method Summary
 com.ericsson.otp.erlang.OtpConnection connect(String peer)
          Establishes an OtpConnection between this node and a specific OtpPeer.
<T> T
exec(String peer, Script<T> script)
          Executes a Script on a specific remote erlang node using RPC.
<T> T
exec(String peer, Script<T> script, List<File> codePaths)
          Executes a Script on a specific remote erlang node using RPC.
static MavenSelf get(String cookie)
          Returns a unique instance of MavenSelf per cookie using the singleton pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static MavenSelf get(String cookie)
                     throws org.apache.maven.plugin.MojoExecutionException
Returns a unique instance of MavenSelf per cookie using the singleton pattern.

Parameters:
cookie - the cookie to use for this java node
Returns:
an instance of MavenSelf, never null
Throws:
org.apache.maven.plugin.MojoExecutionException - in case the instance cannot be created

connect

public com.ericsson.otp.erlang.OtpConnection connect(String peer)
                                              throws org.apache.maven.plugin.MojoExecutionException
Establishes an OtpConnection between this node and a specific OtpPeer. The returned connection may be an already existing, cached connection.

Parameters:
peer - to connect to
Returns:
an OtpConnection that may be used for rpc communication
Throws:
org.apache.maven.plugin.MojoExecutionException - in case the connection cannot be established

exec

public <T> T exec(String peer,
                  Script<T> script)
       throws org.apache.maven.plugin.MojoExecutionException
Executes a Script on a specific remote erlang node using RPC. A connection to the remote node will be established if necessary. NOTE: This will not automatically purge dynamically loaded modules neither will it cleanup the code path of the backend node's code server.

Parameters:
peer - to evaluate the Script on
script - to evaluate
Returns:
the processed result of the Script
Throws:
org.apache.maven.plugin.MojoExecutionException

exec

public <T> T exec(String peer,
                  Script<T> script,
                  List<File> codePaths)
       throws org.apache.maven.plugin.MojoExecutionException
Executes a Script on a specific remote erlang node using RPC. A connection to the remote node will be established if necessary. NOTE: This will not automatically purge dynamically loaded modules neither will it cleanup the code path of the backend node's code server.

Parameters:
peer - to evaluate the Script on
script - to evaluate
codePaths - a list of paths needed for the script to run
Returns:
the processed result of the Script
Throws:
org.apache.maven.plugin.MojoExecutionException


Copyright © 2012 Lindenbaum GmbH. All Rights Reserved.