Access keys

EnhancedLocalConnection

Kind of class: class
Inherits from: BasicClass
Author: Simon Wacker, Christoph Atteneder
Classpath: org.as2lib.io.conn.local.core.EnhancedLocalConnection
File last modified: Saturday, 02 July 2005, 22:43:54
EnhancedLocalConnection provides enhanced local connection functionalities.

These functionalities are proper listener support for asynchronous failures
and comprehensible exceptions on synchronous errors like reserved and unknown
connections and oversized arguments. Refer to the specific method for further
descriptions.

You can set up a connection to receive 'remote' method invocations as follows:

var service:EnhancedLocalConnection = new EnhancedLocalConnection();
service["myMethod"] = function(myArg1:String, myArg2:String):Void {
    trace("invoked myMethod(" + myArg1 + ", " + myArg2 + ")");
}
service.connect("myService");

While the above example works it is not as neat as it could be. It would be
better to use another instance as service and the connection only to set it up
to receive 'remote' method calls.

var service:MyService = new MyService();
var connection:EnhancedLocalConnection = new EnhancedLocalConnection(service);
connection.connect("myService");

The service is set up now to receive 'remote' method invocations. You can now
invoke a method on it as follows:

var client:EnhancedLocalConnection = new EnhancedLocalConnection();
var listener:MethodInvocationErrorListener = client.send("myService", "myMethod", ["arg1", "arg2"]);
listener.onError = function(errorInfo:MethodInvocationErrorInfo):Void {
    trace("Error occured: " + errorInfo); 
}

Constructor

EnhancedLocalConnection

function EnhancedLocalConnection (
)

Class methods

connectionExists

static function connectionExists (
connectionName:String) : Boolean
Checks if a connection with the passed-in connectionName exists.

false will always be returned if the connectionName is null,
undefined or an empty string.

Parameters:
connectionName:
the name of the connection
Returns:
true if the connection exists else false

Instance methods

addErrorListener

function addErrorListener (
Adds a new error listener.

Error listener is invoked if an asynchron error occured. This is mostly when
you try to invoke a remote method.

Parameters:
listener:
the new error listener to add

close

function close (
Void) : Void
Closes this connection.

connect

function connect (
connectionName:String) : Void
Prepares this connection to receive 'remote' method invocations.

Closes this connection if it is currenlty running and opens a new one.

If you specified a target, the 'remote' method invocations will be led directly
to it.

Parameters:
connectionName:
name of the connection the client uses to send method calls
Throws:
org.as2lib.env.except.IllegalArgumentException if the passed-in connectionName is
null, undefined or an empty string
ReservedConnectionException if a connection with the passed-in
connectionName is already in use

removeErrorListener

function removeErrorListener (
Removes an error listener.

Error listener is invoked if an asynchron error occured. This is mostly when
you try to invoke a remote method.

Parameters:
listener:
the error listener to remove

sendByConnectionAndMethod

function sendByConnectionAndMethod (
connectionName:String, methodName:String) : MethodInvocationErrorListener
Invokes a method remotely on the connection specified by the passed-in
connectionName, passing no arguments.

Error listeners are informed if the 'remote' method invocation failed asynchron
of an unknown reason.

A new MethodInvocationErrorListener instance is created and returned.
You can set the onError method on it to be informed of occuring errors.

Parameters:
connectionName:
the name of the connection to invoke the method on
methodName :
the name of the method to invoke on the connection
Returns:
an error listener that informs you of occuring errors if you set the
onError method on it
Throws:
org.as2lib.env.except.IllegalArgumentException if connectionName or methodName
are null, undefined or an empty string
UnknownConnectionException if a connection with the passed-in
connectionName does not exist

sendByConnectionAndMethodAndArguments

function sendByConnectionAndMethodAndArguments (
connectionName:String, methodName:String, args:Array) : MethodInvocationErrorListener
Invokes a method remotely on the connection specified by the passed-in
connectionName passing args as parameters.

Error listeners are informed if the 'remote' method invocation failed asynchron
of an unknown reason.

A new MethodInvocationErrorListener instance is created and returned.
You can set the onError method on it to be informed of occuring errors.

Parameters:
connectionName:
the name of the connection to invoke the method on
methodName :
the name of the method to invoke on the connection
args :
the arguments to pass as parameters when invoking the connection
Returns:
an error listener that informs you of occuring errors if you set the
onError method on it
Throws:
org.as2lib.env.except.IllegalArgumentException if connectionName or methodName
are null, undefined or an empty string
UnknownConnectionException if a connection with the passed-in
connectionName does not exist
org.as2lib.io.conn.core.client.MethodInvocationException if the arguments you try to pass are out of size

sendByConnectionAndMethodAndArgumentsAndListener

function sendByConnectionAndMethodAndArgumentsAndListener (
connectionName:String, methodName:String, args:Array, listener:MethodInvocationErrorListener) : MethodInvocationErrorListener
Invokes a method remotely on the connection specified by the passed-in
connectionName passing args as parameters.

Error listeners are informed if the 'remote' method invocation failed asynchron
of an unknown reason.

A new MethodInvocationErrorListener instance is created and returned,
if the passed-in listener is null. Otherwise the passed-in one
is returned. You can set the onError method on it to be informed of
occuring errors.

Parameters:
connectionName:
the name of the connection to invoke a method on
methodName :
the name of the method to invoke on the connection
args :
the arguments to pass as parameters when invoking the method
listener :
the listener to notify if the method invocation failed out of an
asynchron unknwon reason
Returns:
either the passed-in listener if it was not null or undefined,
or a new listener
Throws:
org.as2lib.env.except.IllegalArgumentException if connectionName or methodName
are null, undefined or an empty string
UnknownConnectionException if a connection with the passed-in
connectionName does not exist
org.as2lib.io.conn.core.client.MethodInvocationException if the arguments you try to pass are out of size

sendByConnectionAndMethodAndListener

function sendByConnectionAndMethodAndListener (
connectionName:String, methodName:String, listener:MethodInvocationErrorListener) : MethodInvocationErrorListener
Invokes a method remotely on the connection specified by the passed-in
connectionName passing args as parameters.

Error listeners are informed if the 'remote' method invocation failed asynchron
of an unknown reason.

A new MethodInvocationErrorListener instance is created and returned,
if the passed-in listener is null. Otherwise the passed-in one
is returned. You can set the onError method on it to be informed of
occuring errors.

Parameters:
connectionName:
the name of the connection to invoke a method on
methodName :
the name of the method to invoke on the connection
listener :
the listener to notify if the method invocation failed out of an
asynchron unknwon reason
Returns:
either the passed-in listener if it was not null or undefined,
or a new listener
Throws:
org.as2lib.env.except.IllegalArgumentException if connectionName or methodName
are null, undefined or an empty string
UnknownConnectionException if a connection with the passed-in
connectionName does not exist
org.as2lib.io.conn.core.client.MethodInvocationException if the arguments you try to pass are out of size