org.as2lib.core.BasicClass +--org.as2lib.io.conn.core.client.AbstractClientServiceProxyFactory +--org.as2lib.io.conn.local.client.LocalClientServiceProxyFactory
ClientServiceProxyFactory
LocalClientServiceProxyFactory
acts as central provider of client service
proxies.
This provision is in the simplest case just the returning of a new client
service proxy.
var clientFactory:LocalClientServiceProxyFactory = new LocalClientServiceProxyFactory();
var client:ClientServiceProxy = clientFactory.getClientServiceProxy("local.as2lib.org/myService");
In a more complex case this means creating a client service proxy for a specific
type, mostly an interface, that is the same type of the 'remote' service.
var clientFactory:LocalClientServiceProxyFactory = new LocalClientServiceProxyFactory();
var client:MyType = clientFactory.getClientServiceProxy("local.as2lib.org/myService", MyType);
client.myMethod("myArg1", "myArg2");
There is sadly one flaw with the last type of usage. That is that the method
cannot response directly due to the asynchronity of the call. To get a response
you therefore have to pass a third argument of type MethodInvocationCallback
.
var clientFactory:LocalClientServiceProxyFactory = new LocalClientServiceProxyFactory();
var client:MyType = clientFactory.getClientServiceProxy("local.as2lib.org/myService", MyType);
var callback:MethodInvocationCallback = new MethodInvocationCallback();
client.myMethod("myArg1", "myArg2", callback);
callback.onReturn = function(returnInfo:MethodInvocationReturnInfo):Void {
trace("myMethod - return value: " + returnInfo.getReturnValue());
}
callback.onError = function(errorInfo:MethodInvocationErrorInfo):Void {
trace("myMethod - error: " + errorInfo.getException());
}
new LocalClientServiceProxyFactory()
public function getTypeProxyFactory(Void):ProxyFactory
Returns the currently used type proxy factory that is used to create proxies for a specific type.
That is either the proxy factory set via setTypeProxyFactory or the default one, which is an instance of type InterfaceProxyFactory.
The default InterfaceProxyFactory can only be used to create proxies of interfaces.
the currently used type proxy factory
public function setTypeProxyFactory(typeServiceProxyFactory:ProxyFactory):Void
Sets the new type proxy factory that is used to create proxies for a specific type.
If you set a type proxy factory of value null
, getTypeProxyFactory
will return the default factory.
public function getClientServiceProxyFactory(Void):ClientServiceProxyFactory
Returns the client service proxy factory used to create client service proxy instances.
The returned factory is either the one set via setClientServiceProxyFactory or the default one which is an instance of SimpleClientServiceProxyFactory.
the currently used client service proxy factory
public function setClientServiceProxyFactory(clientServiceProxyFactory:ClientServiceProxyFactory):Void
Sets a new client service proxy factory used to get client service proxy instances.
If you set a new factory of value null or undefined getClientServiceProxyFactory will return the default factory.
clientServiceProxyFactory | the new client service proxy factory |
public function getClientServiceProxyByUrl(url:String):ClientServiceProxy
Returns a client service proxy for the service specified by the passed-in
url
.
You can use the returned proxy to invoke methods on the 'remote' service and to handle responses.
url | the url of the 'remote' service |
a client service proxy to invoke methods on the 'remote' service
getClientServiceProxyByUrl() in org.as2lib.io.conn.core.client.ClientServiceProxyFactory
public function getClientServiceProxyByUrlAndType(url:String, type:Function)
Returns a client service proxy that can be typed to the passed-in type
(class or interface).
The type is therefore normally the type of the 'remote' service you wanna invoke methods on.
If type
is null
, an instance of type ClientServiceProxy
will be returned. That means this method will then do the same as the
getClientServiceProxyByUrl method.
Note that with the default configuration only interfaces can be used as
type
. You can edit this behavior through the setTypeProxyFactory.
method.
url | the url of the 'remote' service |
type | the type of the 'remote' service |
a client service proxy that can be casted to the passed-in type
getClientServiceProxyByUrlAndType() in org.as2lib.io.conn.core.client.ClientServiceProxyFactory
getClientServiceProxyByUrlAndType() in org.as2lib.io.conn.core.client.AbstractClientServiceProxyFactory