public class ASync extends java.lang.Object implements TAPResource
Asynchronous resource of a TAP service.
Requests sent to this resource are ADQL queries (plus some execution parameters) to execute asynchronously. Results and/or errors of the execution are stored on the server side and can be fetched by the user whenever he wants.
This resource is actually another VO service: a UWS (Universal Worker Service pattern).
That's why all requests sent to this resource are actually forwarded to an instance of UWSService
.
All the behavior of UWS described by the IVOA is already fully implemented by this implementation.
This resource is also representing the only jobs' list of this UWS service.
The UWS service is created and configured at the creation of this resource. Here are the list of the most important configured elements:
ServiceConnection
.ServiceConnection.getNbMaxAsyncJobs()
. Jobs are also queued if no more DB
connection is available ; when connection(s) will be available, this resource will be notified by freeConnectionAvailable()
so that the execution manager
can be refreshed.UWSService
instance is using the same logger as the TAP service. It is also provided by the given ServiceConnection
object at creation.UWSService
Modifier and Type | Field and Description |
---|---|
protected JobList |
jobList
The only jobs' list managed by the inner UWS service.
|
static java.lang.String |
RESOURCE_NAME
Name of this TAP resource.
|
protected ServiceConnection |
service
Description of the TAP service owning this resource.
|
protected UWSService |
uws
UWS service represented by this TAP resource.
|
Constructor and Description |
---|
ASync(ServiceConnection service)
Build an Asynchronous Resource of a TAP service.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Let free properly all system/file/DB resources kept opened by this TAP resource.
|
boolean |
executeResource(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Interpret the given request, execute the appropriate action and finally return a result or display information to the user.
|
void |
freeConnectionAvailable()
Notify this TAP resource that free DB connection(s) is(are) now available.
|
java.lang.String |
getName()
Get the name of this TAP resource.
|
UWSService |
getUWS()
Get the UWS behind this TAP resource.
|
void |
init(javax.servlet.ServletConfig config)
Let initialize this TAP resource.
|
void |
setTAPBaseURL(java.lang.String baseURL)
Let diffuse the base URL of the TAP service to all its TAP resources.
|
public static final java.lang.String RESOURCE_NAME
protected final ServiceConnection service
protected final UWSService uws
protected final JobList jobList
public ASync(ServiceConnection service) throws UWSException, TAPException
service
- Description of the TAP service which will own this resource.TAPException
- If any error occurs while creating a UWS service or its backup manager.UWSException
- If any error occurs while setting a new execution manager to the recent inner UWS service,
or while restoring a UWS backup.public void freeConnectionAvailable()
Notify this TAP resource that free DB connection(s) is(are) now available. It means that the execution manager should be refreshed in order to execute one or more queued jobs.
Note: This function has no effect if there is no execution manager.
public java.lang.String getName()
TAPResource
Get the name of this TAP resource.
Important note: This name MUST NOT be NULL and SHOULD NEVER change.
getName
in interface TAPResource
public void setTAPBaseURL(java.lang.String baseURL)
TAPResource
Let diffuse the base URL of the TAP service to all its TAP resources.
Important note: This function should be called just once: either at the creation of the service or when the first request is sent to the TAP service (in this case, the request is also used to finish the initialization of the TAP service, and of all its resources).
setTAPBaseURL
in interface TAPResource
baseURL
- Common URL/URI used in all requests sent by any user to the TAP service.public final UWSService getUWS()
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
TAPResource
init
in interface TAPResource
config
- Servlet configuration. (may be useful for the configuration of this resource)javax.servlet.ServletException
- If any error prevent the initialization of this TAP resource. In case a such exception is thrown, the service should stop immediately.public void destroy()
TAPResource
destroy
in interface TAPResource
public boolean executeResource(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, TAPException
TAPResource
Interpret the given request, execute the appropriate action and finally return a result or display information to the user.
IMPORTANT:
"TAP resources can not take the law in their own hands!" :-)
Errors that could occur inside this function should not be written directly in the given HttpServletResponse
.
They should be thrown to the resources executor: an instance of TAP
, which
will fill the HttpServletResponse
with the error in the format described by the IVOA standard - VOTable. Besides, TAP
may also
add more information and may log the error (in function of this type).
executeResource
in interface TAPResource
request
- Request sent by the user and which should be interpreted/executed here.response
- Response in which the result of the request must be written.java.io.IOException
- If any error occurs while writing the result of the given request.TAPException
- If any other error occurs while interpreting and executing the request or by formating and writing its result.