uws.service
Class BasicUWS<J extends AbstractJob>

java.lang.Object
  extended by uws.job.SerializableUWSObject
      extended by uws.service.AbstractUWS<JobList<J>,J>
          extended by uws.service.BasicUWS<J>
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<JobList<J>>, java.util.EventListener, javax.servlet.http.HttpSessionBindingListener
Direct Known Subclasses:
QueuedBasicUWS

public class BasicUWS<J extends AbstractJob>
extends AbstractUWS<JobList<J>,J>

Convenient implementation of AbstractUWS.

You do not have to extend this implementation to create a job. The function createJob(Map) uses the Constructor found in the Class given at the instantiation of this UWS to create a new job. Thus whatever is the type of the extension of AbstractJob this method will always call its constructor which contains a Map as only parameter.

IMPORTANT: THE EXTENSION OF AbstractJob MUST CONTAIN A CONSTRUCTOR WITH ONLY ONE PARAMETER OF TYPE MAP<STRING,STRING> !!!

Example:
        public class MyServlet extends HttpServlet {
 
                private BasicUWS<JobImpl> uws = null;
 
                public void init(ServletConfig conf) throws ServletException {
                        super.init(conf);
                        try{
                                uws = new BasicUWS<JobImpl>(JobImpl.class);
                                uws.addJobList(new JobList<JobImpl>("myJobList"));
                        }catch(UWSException ex){
                                throw new ServletException(ex);
                        }
                }
 
                public void destroy(){
                        uws.removeAllJobLists();
                        super.destroy();
                }

                public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
                        try{
                                uws.executeRequest(request, response);
                        }catch(UWSException ex){
                                res.sendError(uwsEx.getHttpErrorCode(), uwsEx.getMessage());
                        }
                }
        }
 

Version:
02/2011
Author:
Grégory Mantelet (CDS)
See Also:
Serialized Form

Field Summary
protected  java.lang.reflect.Constructor<J> constructor
          The constructor to use when the method createJob(Map) is called.
protected  java.lang.Class<J> jobClass
          The class object of the type of job to manage.
 
Fields inherited from class uws.service.AbstractUWS
choosenSerializer, defaultSerializer, description, executedAction, homePage, homeRedirection, mapJobLists, name, reInitUrlInterpreter, serializers, urlInterpreter, userIdentifier, uwsActions
 
Constructor Summary
BasicUWS(java.lang.Class<J> cl)
          Builds a BasicUWS with the class object of the type of job to manage.
BasicUWS(java.lang.Class<J> cl, java.lang.String baseURI)
          Builds a BasicUWS with the class object of the type of job to manage and the base UWS URI.
BasicUWS(java.lang.Class<J> cl, UWSUrl urlInterpreter)
          Builds a BasicUWS with the class object of the type of job to manage and the UWS URL interpreter to use.
 
Method Summary
 J createJob(java.util.Map<java.lang.String,java.lang.String> parameters)
          Creates a job of the type (extension of AbstractJob) which parameterized this implementation of AbstractUWS.
protected  java.lang.reflect.Constructor<J> getConstructor()
          Gets the constructor of the type of job to use.
 
Methods inherited from class uws.service.AbstractUWS
addJobList, addSerializer, addUWSAction, addUWSAction, destroyAllJobLists, destroyJobList, destroyJobList, executeRequest, getBaseURI, getChoosenSerializer, getDefaultSerializer, getDescription, getDestructionManager, getDestructionTimeController, getExecutedAction, getExecutionDurationController, getExecutionManager, getHomePage, getJobList, getName, getNbJobList, getNbSerializers, getNbUWSActions, getSerializer, getSerializers, getUrlInterpreter, getUserIdentifier, getUWSAction, getUWSActions, getXsltURL, hasSerializerFor, isDefaultHomePage, isHomePageRedirection, iterator, redirect, removeAllJobLists, removeJobList, removeJobList, removeSerializer, removeUWSAction, removeUWSAction, replaceUWSAction, sendError, sendError, serialize, setDefaultHomePage, setDefaultSerializer, setDescription, setDestructionManager, setDestructionTimeController, setExecutionDurationController, setExecutionManager, setHomePage, setHomePage, setName, setUrlInterpreter, setUserIdentifier, setUWSAction, setXsltURL, sync, valueBound, valueUnbound
 
Methods inherited from class uws.job.SerializableUWSObject
serialize, serialize, serialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jobClass

protected final java.lang.Class<J extends AbstractJob> jobClass
The class object of the type of job to manage.


constructor

protected transient java.lang.reflect.Constructor<J extends AbstractJob> constructor
The constructor to use when the method createJob(Map) is called.

Constructor Detail

BasicUWS

public BasicUWS(java.lang.Class<J> cl)
         throws UWSException
Builds a BasicUWS with the class object of the type of job to manage.

Parameters:
cl - The class object of the type of job to manage.
Throws:
UWSException -
  • If the given class is abstract.
  • If the constructor with one parameter of type Map< String, String > doesn't exist for the given class object.
  • If any other error occurs during the fetching of the good constructor.
See Also:
AbstractUWS.AbstractUWS(), getConstructor()

BasicUWS

public BasicUWS(java.lang.Class<J> cl,
                java.lang.String baseURI)
         throws UWSException
Builds a BasicUWS with the class object of the type of job to manage and the base UWS URI.

Parameters:
cl - The class object of the type of job to manage.
baseURI - The base UWS URI.
Throws:
UWSException -
  • If there is an error when calling the constructor super(String).
  • If the given class is abstract.
  • If the constructor with one parameter of type Map< String, String > doesn't exist for the given class object.
  • If any other error occurs during the fetching of the good constructor.
See Also:
AbstractUWS.AbstractUWS(String), getConstructor()

BasicUWS

public BasicUWS(java.lang.Class<J> cl,
                UWSUrl urlInterpreter)
         throws UWSException
Builds a BasicUWS with the class object of the type of job to manage and the UWS URL interpreter to use.

Parameters:
cl - The class object of the type of job to manage.
urlInterpreter - The UWS URL interpreter to use in this UWS.
Throws:
UWSException -
  • If the given class is abstract.
  • If the constructor with one parameter of type Map< String, String > doesn't exist for the given class object.
  • If any other error occurs during the fetching of the good constructor.
See Also:
AbstractUWS.AbstractUWS(UWSUrl), getConstructor()
Method Detail

getConstructor

protected final java.lang.reflect.Constructor<J> getConstructor()
                                                                             throws UWSException

Gets the constructor of the type of job to use. This constructor has only one parameter of type Map<String,String>.

Note: If this UWS has just been de-serialized, the constructor is extracted one more time from the stored class object !

Returns:
The constructor of the type of job to use.
Throws:
UWSException - If it is impossible to extract the constructor with one parameter (Map<String, String>) from the stored class object.

createJob

public J createJob(java.util.Map<java.lang.String,java.lang.String> parameters)
                                throws UWSException
Description copied from class: AbstractUWS
Creates a job of the type (extension of AbstractJob) which parameterized this implementation of AbstractUWS.

Specified by:
createJob in class AbstractUWS<JobList<J extends AbstractJob>,J extends AbstractJob>
Parameters:
parameters - The map of parameters to give to the constructor of AbstractJob.
Returns:
The created job.
Throws:
UWSException - If any error occurs while creating the job.
See Also:
AbstractUWS.createJob(java.util.Map), getConstructor(), Constructor.newInstance(Object...)