simple.http.load
Class Service

java.lang.Object
  extended by simple.http.serve.Component
      extended by simple.http.load.Service
All Implemented Interfaces:
Resource
Direct Known Subclasses:
Controller, Process, Redirect

public abstract class Service
extends Component

The Service is a loadable component that is used to process requests. Typically services are loaded in to the server using a LoaderEngine object. It can be initialized using any number of arguments, these arguments are passed from the LoaderEngine.load to the service instance. This allows a flexible initialization of services to be achieved using arbitrary prepare methods.

This will attempt to discover the prepare method implemented by the subclass before invoking it. The discovery is done using Java reflection to match the arguments to the prepare method signature. For example take the prepare signatures illustrated below.


    public void prepare(Map) throws Exception
    public void prepare(List, String) throws Exception

 
The data passed into the prepare method from the loader engine is a variable length argment list. So, this enables any number of objects to be passed into the loader engine load method. Once the arguments have been passed into the service instance they are matched against all publicly declared prepare methods for the implementation. So it is the task of the developer to ensure the arguments to the load method match the arguments to the implementation initializer. If no initializer is declared, then initialization is ignored.

Author:
Niall Gallagher
See Also:
Introspector

Field Summary
protected  LoaderEngine engine
          This is the loader engine used to load this service object.
 
Fields inherited from class simple.http.serve.Component
context
 
Constructor Summary
Service(Context context)
          Constructor to the Service object.
 
Method Summary
 void prepare(LoaderEngine engine, java.lang.Object[] data)
          This method is used as a driver to the prepare method implemented by the subclass.
 
Methods inherited from class simple.http.serve.Component
handle, handle, handle, process, process, process
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

engine

protected LoaderEngine engine
This is the loader engine used to load this service object.

Constructor Detail

Service

public Service(Context context)
Constructor to the Service object. This will create a service that can have an arbitrary preparation method. This will be used by a LoaderEngine to create an instance using the context of that loader engine.

Parameters:
context - this is the context used by this instance.
Method Detail

prepare

public void prepare(LoaderEngine engine,
                    java.lang.Object[] data)
             throws LoadingException
This method is used as a driver to the prepare method implemented by the subclass. The selection of the prepare method is determined by the class of the issued object, using Object.getClass. This discovers the method using the class and its subclasses.

Parameters:
engine - this is the engine that this object loaded by
data - this object's class determines the preparation
Throws:
LoadingException - thrown if preparation fails