This package provides classes used for the core
communication of the STARS system.
For using the communication api as a client there are four classes/interfaces
important:
-
stars.communication.client.DispatchCommunicator
-
stars.communication.client.Connector
-
stars.communication.client.ConnectorListener
-
stars.communication.Message
At the beginning you have to invoke a connection to the Dispatcher:
DispatchCommunicator communicator
= new DispatchCommunicator(argv[0],argv[1]);
The first parameter is the address of the dispatcher, in the current implementation
as a rmi address, that means : "rmi://<ip.addr.>/Dispatcher", where
<ip.addr.> is the ip address of the Dispatcher server. (might be a symbolic
name). The second parameter is the ID of the client. This must be a unique
string, no two clients with the same ID are allowed to register to the
Dispatcher at the same time. The ID is related to the maschine, not to
the user. One user could login on serveral maschines. The ID is always
accepted when it is unique. Authentification is done with the user name.
So, before you can use the connection to the dispatcher, you have to login
with a user name and a password.
communicator.login(name,password);
In the current implementation, because of the reason that there is no login
service implemented, all combinations of two strings will be accepted by
the system. (However, you have to login before using the Dispatcher!)
After you installed the DispatchCommunicator and logged in, you can
use it to create connections to services. To offer a service, you need
two more classes/Interfaces:
-
stars.communication.client.Service
-
stars.communication.client.ServiceCallListener
If you implement a service, you have to implement a ServiceCallListener
for this service. The ServiceCallListener contains the method, which will
be invoked by the system, every time a client tries to get a Connector
to the service. In this method you have to set the ConnectorListeners for
your service. The createst part of your service might be implemented in
ConnectorListeners.
You have two possibilities to implement ConnectorListeners.
-
use one "big" ConnectorListener, which will compute all messages which
will be send to the service. (this means, that you will have a lot of
if (msg.command.equals("xyz")){} else if (msg.comand.equals("xyz2")){}
else if .. )
-
use one ConnectorListener for every command which can be send to your service.
Then, the system will select the ConnectorListener which is registered
to compute the given command paramter of the message and then invokes the
method of this listener.
This page is hosted by the Chair for Applied Software Engineering of the Technische Universität München.
Imprint (Impressum)