Message-ID: <646718510.299340.1368976766676.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_299339_1749892025.1368976766676" ------=_Part_299339_1749892025.1368976766676 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
A "distributed service" is a service running on multiple peers= within a given Service Space. They have a name which uniquely identifies t= hem, once again within a given Service Space, and can be remotely invoked v= ia a RPCish API.
Any class implementing a set of interfaces is a valid distributed servic=
e implementation. Implemented interfaces capture the contracts, i.e. method=
s, which can be remotely executed.
Optionally, a service may implement the org.codehaus.wadi.core.Lifecycle in= terface. If implemented, it receives lifecycle callbacks when it is started= or stopped. A service is started or stopped by the service registry it has= been registered with when the associated service space starts or stops.
The following snippets show a basic service space implementation:
and its registration:
A service defined by a given service space can be remotely executed via =
a RPC like API. This API offers multiple configuration parameters developer=
s can use to specify how invocations are to be performed.
The first step is to retrieve a ServiceProxyFactory from the service space = defining the service to be invoked:
The first parameter of getServiceProxyFactory is the name of the targete= d service and the second is an array of interfaces the service implements.<= br /> The returned ServiceProxyFactory allows the configuration of global invocat= ion parameters , which are inherited by all the service proxies created by = this factory. For instance, here is how to set a global request-reply timeo= ut to 2000ms:
The actual creation of a service proxy is done through the getProxy() co= ntract. The returned object is a ServiceProxy instance, which also implemen= ts the interfaces passed in to getServiceProxyFactory. Invocation parameter= s can be configured for this instance by retrieving the attached Invocation= MetaData and the remote invocation is simply done by casting the instance t= o one of the service interfaces and executing it. For instance, this is how= our BasicTaskExecutor service is executed on peer1:
The way remote invocations are executed is controlled by the InvocationM=
etaData instance attached to ServiceProxyFactory, for inherited global set-=
up, and ServiceProxy, for instance specific set-up.
The following invocation parameters are available: