Using ServiceStarter to launch a "proxy is service" service
Francisco Dário Mourão <[email protected]>
| Newsgroups | gmane.comp.java.sun.jini |
|---|---|
| Message-ID | <[email protected]> |
Hi there,
I've been reading Jan Newmarch's guide (http://jan.netcomp.monash.edu.au/java/jini/tutorial/Jini.xml) and I was able to write two service/servers:
1) "Proxy is Service" (fat client) -> service is downloaded to client and runs in the client's VM.
Server is kept alive to renewal service lease at the LS. Server's main() calls server constructor and sleeps forever.
ServiceImpl (service implementation) implements IService(interface known to client) and Serializable
ServiceImpl is in service-dl.jar
Server uses JoinManager to register service, passing it an instance of ServiceImpl as the service object
2) "RMI Proxy" (thin client) -> client invokes service methods remotely to the service back end at the server
Server is kept alive to renewal service lease at the LS and process remote method invocation. Server's main() calls server constructor and sleeps forever.
ServiceImpl (service implementation) implements IRemoteService which implements Remote and IService(interface known to client)
IRemoteService is in remoteservice-dl.jar
Server uses JoinManager to register proxy of service, passing it proxy = (IRemoteService) exporter.export(impl) as the service object
Everything runs perfectly when I run the client using 1) or 2) when I start the servers using their main() methods.
Then I tried to use the ServiceStarter to launch each one.
Each one has a start-transient-service.config for ServiceStarter parameter:
1) The ServiceStarter uses a ServiceTransientServer to call the server:
ServiceTransientServer(String[] configArgs, LifeCycle lifeCycle)
{
new Server(configArgs);
}
i.e. it skips the server's main method and calls directly its constructor which calls JoinManager
start-transient-service.config:
....
static serviceDescriptors = new ServiceDescriptor[] {
new NonActivatableServiceDescriptor(
service_codebase, service_policy,
service_classpath, "pt.ServiceTransientServer",
new String[] { "transient-service.config" })
};
2) The ServiceStarter uses a RemoteServiceTransientServer to call the server:
RemoteServiceTransientServer(String[] configArgs, LifeCycle lifeCycle)
{
new RemoteServer(configArgs);
}
i.e. it skips the server's main method and calls directly its constructor which calls JoinManager
start-transient-service.config:
....
static serviceDescriptors = new ServiceDescriptor[] {
new NonActivatableServiceDescriptor(
service_codebase, service_policy,
service_classpath, "pt.RemoteServiceTransientServer",
new String[] { "transient-service.config" })
};
When I launch the ServiceStarter for 2) everything runs fine. It calls RemoteServer constructor. The ServiceStarter main() method terminates but the VM remains alive. Possibly because it is holding some working thread reference.
Although...
THE PROBLEM:
When I launch the ServiceStarter for 1) no error is given. It calls Server constructor, but when the ServiceStarter main() method terminates the VM also terminates.
I tried to put a Sleep at the end of the Server's constructor and while this sleep lasts the server is able to register the service. During this time I ran the client and it worked. But when the sleep terminates, the constructor terminates, the ServiceStarter main() terminates and the VM terminates two.
Is it possible to use ServiceStarter when I don't have a service proxy?
Regards
Francisco Mourão
--------------------------------------------------------------------------
Getting Started: http://www.jini.org/wiki/Category:Getting_Started
Community Web Site: http://jini.org
jini-users Archive: http://archives.java.sun.com/archives/jini-users.html
Unsubscribing: email "signoff JINI-USERS" to [email protected]