|
Version: 1.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.biomoby.client.BaseClient
public abstract class BaseClient
This is a base class for Biomoby clients. It takes care about converting user input into Biomoby XML, sending it in a SOAP message to a Biomoby service, waiting for the response and parsing it from Biomoby XML. It also divides requests and responses into so-called jobs - each of them corresponds to a Biomoby query (a Biomoby single network request may contain more queries/jobs).
Any client can override various methods - but the ones she/he
must override in a subclass are those telling what service
to call (getServiceLocator()
), what data to put in a request
(fillRequest
), and what
to do with a response (useResponse
.
Constructor Summary | |
---|---|
BaseClient()
|
Method Summary | |
---|---|
String |
callRemoteService(String xmlInput)
Call a SOAP-based BioMoby service. |
String |
errorsInResponse(String xmlResponse)
Extracts errors from a raw service response. |
String |
fillRequest()
Create raw XML input. |
abstract boolean |
fillRequest(MobyJob request,
MobyPackage inputContext)
Crate data (fill them into 'request') for one Moby job (query). |
boolean |
fillRequest(MobyPackage mobyInput,
int jobCount)
Fill the whole 'mobyInput' - put there any number of jobs (queries) as you wish (you do not need to follow the 'jobCount' hint suggesting how many jobs should be put there). |
abstract MobyServiceLocator |
getServiceLocator()
Return characteristics of a BioMoby service that will be called, and that reveal where to find such service. |
String |
interceptRequest(String xmlInput)
|
void |
process()
The main method that packs input data, invokes a BioMoby service and uses its response. |
void |
process(int jobCount)
The main method that packs input data, invokes a BioMoby service and uses its response. |
abstract boolean |
useResponse(MobyJob response,
MobyPackage responseContext)
Process a single job returned from a BioMoby service. |
void |
useResponse(MobyPackage mobyResponse)
A high-level processing. |
boolean |
useResponse(String xmlResponse)
A raw-level processing. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BaseClient()
Method Detail |
---|
public void process() throws MobyException
process(int)
.
MobyException
- if (a) a sub-class throws it during the
filling data or using response, or (b) a Biomoby service
invocation failspublic void process(int jobCount) throws MobyException
Usually a client developer does not need to overwrite this
method. She or he makes the real input data filling in the
fillRequest()
method, and uses the response in the
useResponse(java.lang.String)
method.
MobyException
- if (a) a sub-class throws it during the
filling data or using response, or (b) a Biomoby service
invocation failspublic String interceptRequest(String xmlInput) throws MobyException
MobyException
public String fillRequest() throws MobyException
MobyException
- if an XML cannot be createdpublic String callRemoteService(String xmlInput) throws MobyException
getServiceLocator()
that
should be implemented by a sub-class. Once it has the service locator, this class does one of the following, in this order:
xmlInput
- data will be sent to the called Biomoby service
MobyException
- (a) if service call (or a call to
registry; for example because the registry does not know given
service) fails, or (b) if the used MobyServiceLocator
does not contain a service name.public boolean fillRequest(MobyPackage mobyInput, int jobCount) throws MobyException
Usually there is not need to overwrite this method. It serves
as an inter-mediator between the main process()
method
and the individual request fillings (done by a sub-class in
method fillRequest(MobyJob,MobyPackage)
).
mobyInput
- is an empty shell that you are supposed to
fill with the input data for a Biomoby service executionjobCount
- is only a suggestion how many requests/job
should be created (it comes from the process()
method) -
but it does not need to be obeyed
MobyException
public boolean useResponse(String xmlResponse) throws MobyException
xmlResponse
- is a raw XML response returned from a
BioMoby service
MobyException
- if you are not satisfied with a response
data, or from whatever reasons; it also throws this exception
if the 'mobyResponse' is brokenpublic void useResponse(MobyPackage mobyResponse) throws MobyException
useResponse(MobyJob,MobyPackage)
.
mobyResponse
- is a full response returned from a BioMoby
service
MobyException
- if you are not satisfied with a response
data, or from whatever reasons; it also throws this exception
if the 'mobyResponse' is brokenpublic String errorsInResponse(String xmlResponse)
xmlResponse
- is a full response returned from a BioMoby
service
public abstract MobyServiceLocator getServiceLocator() throws MobyException
MobyException
- if service locator cannot be
returned/created (e.g. because there is not enough information
about what service to call)callRemoteService(java.lang.String)
public abstract boolean fillRequest(MobyJob request, MobyPackage inputContext) throws MobyException
This is a method that should be implemented by a client developer, and it is the place where the client's business logic sits.
request
- is an object that you are supposed to fill with
input data for one service invocation; it already has a name
(so called 'query id' in the BioMoby speak) but you are free to change itinputContext
- is an envelope where all requests will be
stored and sent to a Biomoby service; you do not need to do
anything with it here unless you wish; note that all already
created requests are there, but not the one you are just
creating in this method
MobyException
- if you need so (from whatever reason in
your business logic); if thrown then nothing will be sent to a
Biomoby servicepublic abstract boolean useResponse(MobyJob response, MobyPackage responseContext) throws MobyException
This is a method that should be implemented by a client developer, and it is the place where the client's business logic using the response sits.
response
- is an object that you are supposed to useresponseContext
- is an envelope where the full response
(all its jobs) is located; you do not need to do anything with
it here unless you wish (e.g. it gives you knowledge about how
many jobs are in the full response, or it gives you access to
the so-called 'service notes')
MobyException
- if you are not satisfied with a response
data, or from whatever reasons; it also throws this exception
if the 'response' is broken
|
Version: 1.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |