org.objectweb.david.libs.services.handler
Class DavidServicesHandler

java.lang.Object
  extended byorg.objectweb.david.libs.services.handler.DavidServicesHandler
All Implemented Interfaces:
ServicesHandler

public class DavidServicesHandler
extends java.lang.Object
implements ServicesHandler

Default implementation of a ServicesHandler.

The services managed by this handler must be components of a Context provided at initialization time. The names to use should be integers representing service identifiers. The service components' values must be Service instances.

The list of services managed by a DavidServicesHandler instance is initialized when the instance is created.


Constructor Summary
DavidServicesHandler(org.objectweb.jonathan.apis.kernel.Context services_context)
          Builds a new DavidServicesHandler instance.
 
Method Summary
 org.omg.IOP.ServiceContext[] getReplyContexts(int request_id, org.objectweb.jonathan.apis.kernel.Context message_context)
          Returns a list of service contexts.
 org.omg.IOP.ServiceContext[] getRequestContexts(int request_id, boolean response_expected, byte[] object_key, org.objectweb.jonathan.apis.kernel.Context message_context)
          Returns a list of service contexts.
 void handleReplyContexts(org.omg.IOP.ServiceContext[] contexts, int request_id, org.objectweb.jonathan.apis.kernel.Context message_context)
          Lets the handler manage the provided contexts.
 void handleRequestContexts(org.omg.IOP.ServiceContext[] contexts, int request_id, boolean response_expected, byte[] object_key, org.objectweb.jonathan.apis.kernel.Context message_context)
          Lets the handler manage the provided contexts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DavidServicesHandler

public DavidServicesHandler(org.objectweb.jonathan.apis.kernel.Context services_context)
                     throws org.objectweb.jonathan.apis.kernel.JonathanException
Builds a new DavidServicesHandler instance.

Parameters:
services_context - the context containing the services (as local objects);
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if something goes wrong
Method Detail

getRequestContexts

public org.omg.IOP.ServiceContext[] getRequestContexts(int request_id,
                                                       boolean response_expected,
                                                       byte[] object_key,
                                                       org.objectweb.jonathan.apis.kernel.Context message_context)
Returns a list of service contexts.

This method simply tries to get a request context from each managed service. No service order is specified.

Specified by:
getRequestContexts in interface ServicesHandler
Parameters:
request_id - the request id;
response_expected - indicates if a response is expected;
object_key - the target object key.
message_context - the context of the request marshaller.
Returns:
a list of service contexts.

getReplyContexts

public org.omg.IOP.ServiceContext[] getReplyContexts(int request_id,
                                                     org.objectweb.jonathan.apis.kernel.Context message_context)
Returns a list of service contexts.

This method simply tries to get a reply context from each managed service. No service order is specified.

Specified by:
getReplyContexts in interface ServicesHandler
Parameters:
request_id - the request id.
message_context - the context of the reply marshaller.
Returns:
a list of service contexts.

handleRequestContexts

public void handleRequestContexts(org.omg.IOP.ServiceContext[] contexts,
                                  int request_id,
                                  boolean response_expected,
                                  byte[] object_key,
                                  org.objectweb.jonathan.apis.kernel.Context message_context)
Lets the handler manage the provided contexts.

When a context bears the same identifier as one of the services handled by the target handler, the context is sent to the service. No order is specified.

Specified by:
handleRequestContexts in interface ServicesHandler
Parameters:
contexts - the list of contexts contained in the request;
request_id - the request id;
response_expected - indicates whether a response is expected;
object_key - the target object key.
message_context - the context of the request unmarshaller.

handleReplyContexts

public void handleReplyContexts(org.omg.IOP.ServiceContext[] contexts,
                                int request_id,
                                org.objectweb.jonathan.apis.kernel.Context message_context)
Lets the handler manage the provided contexts.

When a context bears the same identifier as one of the services handled by the target handler, the context is sent to the service. No order is specified.

Specified by:
handleReplyContexts in interface ServicesHandler
Parameters:
contexts - the list of contexts contained in the reply;
request_id - the request id;
message_context - the context of the reply unmarshaller.