simple.http.load
Class Service
java.lang.Object
simple.http.serve.Component
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. |
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
engine
protected LoaderEngine engine
- This is the loader engine used to load this service object.
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.
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 bydata
- this object's class determines the preparation
- Throws:
LoadingException
- thrown if preparation fails