Hi Tom,

my goal basically is to set up a 'fat' service, which resides on the server side and the client uses only a proxy. What the service is doing is not important at the moment, I'm just trying to get a first example to run (that's why I'm using the reggie lookup service and the HTTP server provided in the Apache River distribution). If you think that the whole structure can be simplified I would be very happy to do so. The projects I sent you are based on an example from the Jan Newmarch tutorial (book - chapter 21). The example classifies the files by their extensions such as: rtf, jpg, gif etc.

In the "common" package you can find (both should be known also by the client):
   - the interface of the service "FileClassifier";
- the "MIMEType" class which is the object returned by the service.

In the "rmi" package you can find:
- FileClassifierImpl class which represents the service; This class implements the RemoteFileClassifier interface; - RemoteFileClassifier is an interface which implements the Remote and FilleClassifier interfaces (......); - FileClassifierServerRMI is from an earlier attempt to run the service, it is not used in the current implementation and should be removed.

In the "starter" package you can find:
- FileClassifierStarterImpl which is used to start a nonactivatable service. It creates a proxy of the service using the exporter type specified in the file "file_classifier_server.config"; - ServiceDescription class which acts as a server class. It picks up the values from a configuration file ("serviceDesc.config") and creates the service and its proxy. The program essentially uses two parts: one to build the service using a ServiceDescriptor and its configuration entries, the other to advertise the service using JoinManager and its associated AdvertDescription configuration entries.

The src/starter/serviceDesc.config configuration file uses two jar files, starter.ServiceDescription-dl.jar for the service codebase and starter.ServiceDescription-start.jar for the server's classpath. The contents of these files are The starter.ServiceDescription-dl.jar contains all the files that need to be downloaded to a client:
   - common/MIMEType.class;
   - common/FileClassifier.class;
   - rmi/RemoteFileClassifier.class.
The starter.ServiceDescription-start.jar contains all the files that are needed for the server to create the service:
   - common/FileClassifier.class;
   - common/MIMEType.class;
   - rmi/FileClassifierImpl.class;
   - rmi/RemoteFileClassifier.class;
   - starter/FileClassifierStarterImpl.class.

To summarise what is going on here
1.The service is started by running a service.ServiceDescription
2.The classpath for service.ServiceDescription must include (for example) a jar file starter.ServiceDescription.jar that contains starter.ServiceDescription.class as well as the standard Jini classes 3.service.ServiceDescription uses a configuration file such as serviceDesc.config which includes a description of the codebase, etc, which are suitable parameters for the constructor of a ServiceDescriptor 4.The serviceDesc.config configuration also contains an advertisement description to register the service with lookup services 5.When the service is started by ServiceDescriptor.create() it uses its own configuration file file_classifier.config which specifies the exporter 6.The classpath used to start the service includes the files in the jar file starter.ServiceDescription-start.jar 7.The codebase used by clients to download the service includes the jar file starter.ServiceDescription-dl.jar

Thanks, I'm looking forward to your answer!

Best Regards,
Alina




On Thursday 02/02/2012 at 19:07:21, Tom Hobbs  wrote:
Hi Rupert,

This can be done very easily.

Assuming you've got all your config files in known good places, the
few lines of code you'd need are something like;

//Start HTTP server
ClassServer cs = new ClassServer(HTTP_PORT, dir, trees, stoppable, verbose);
cs.start();

//Start reggie
ServiceStarter.main(reggieConfig);

//Start management service
ServiceStarter.main(managementServiceConfig);

Have a look at the API for ConfigurationFile to see how to construct
the arguments to ServiceStarter.main

http://river.apache.org/doc/api/net/jini/config/ConfigurationFile.html

Cheers,

Tom


On Thu, Feb 2, 2012 at 5:00 PM, Rupert Smith
<[email protected]> wrote:

Hi,

At the moment I start the HTTP class server and reggie using scripts:

jini-httpd.sh
jini-reggie.sh

Which I took from the examples. These start Java processes:

java -jar ../lib-jini/classserver.jar -port 8080 -dir ../lib-jini-dl

And:

java -Djava.security.policy=jini-start.policy -jar
../lib-jini/start.jar start-reggie.config

All good, and I appreciate that there are other ways of running Jini, and the various scripts in the examples demonstrate some of the flexibility
available, though I have not yet explored the options in much depth.

What I would like to do now, for the sake of simplicity, is to have a
single Java main() method, that laucnhes the class server, reggie, and my "management console" application, all as a single process. Services that can be managed, will then make themselves available through that registsry, as and when they come online. This is the most common way in which it will
be run.

Are there any example available on doing this? Perhaps I just need to start digging through the main() methods in classserver.jar and start.jar to get
an idea of how it is done.

Thanks for your help.

Rupert

Reply via email to