|
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 org.biomoby.client.BaseCmdLineClient
public class BaseCmdLineClient
This is a base class for the command-line driven clients. Such clients are mostly used for testing purposes but some of them can be handy, sitting behind some servers as well.
This is not an abstract class - it can be instantiated and directly
use (it has its own the main(java.lang.String[])
method). But it has limited
knowledge how to create input data - see its help for more details.
For more complex data, you need to subclass it.
It also takes care about general-purpose command-like options (that
can be used for any service) - such as an endpoint or the
help option - see main(java.lang.String[])
for their list.
Another feature is that it can dynamically load a local Java class, instead going to a remote BioMoby service. This can be used for testing new BioMoby services before deploying them.
Constructor Summary | |
---|---|
BaseCmdLineClient()
|
|
BaseCmdLineClient(String[] args)
|
Method Summary | |
---|---|
String |
callRemoteService(String xmlInput)
Call either a local class implementing a service, or pass it to the superclass that does a real (usual) SOAP call to a service (or first to a registry and then to a service). |
void |
doEverything()
|
String |
fillRequest()
Create raw XML input. |
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). |
MobyServiceLocator |
getServiceLocator()
Return characteristics of a BioMoby service that will be called, and that reveal where to find such service. |
String |
getUsage()
Return a help text about this this client. |
String |
interceptRequest(String xmlInput)
|
static void |
main(String[] args)
|
void |
reportError(Throwable e)
|
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 org.biomoby.client.BaseClient |
---|
errorsInResponse, process, process |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BaseCmdLineClient()
public BaseCmdLineClient(String[] args)
Method Detail |
---|
public void reportError(Throwable e)
public String getUsage()
public void doEverything()
public boolean fillRequest(MobyPackage mobyInput, int jobCount) throws MobyException
BaseClient
Usually there is not need to overwrite this method. It serves
as an inter-mediator between the main BaseClient.process()
method
and the individual request fillings (done by a sub-class in
method BaseClient.fillRequest(MobyJob,MobyPackage)
).
fillRequest
in class BaseClient
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 BaseClient.process()
method) -
but it does not need to be obeyed
MobyException
public String fillRequest() throws MobyException
BaseClient
fillRequest
in class BaseClient
MobyException
- if an XML cannot be createdpublic String interceptRequest(String xmlInput) throws MobyException
interceptRequest
in class BaseClient
MobyException
public String callRemoteService(String xmlInput) throws MobyException
The local class is used if its name was given on the command-line. This is meant to be used to test services before they are deployed in a servlet environment (such as Apache/Axis).
callRemoteService
in class BaseClient
xmlInput
- data will be sent to the called Biomoby service
MobyException
- if (a) a local class cannot be
instantiated, or if (b) a local class returned an unexpected
result type (should return only String or array of bytes), or
if a (c) super-class call to remote service failedBaseClient.callRemoteService(java.lang.String)
public boolean useResponse(String xmlResponse) throws MobyException
BaseClient
useResponse
in class BaseClient
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
BaseClient
BaseClient.useResponse(MobyJob,MobyPackage)
.
useResponse
in class BaseClient
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 MobyServiceLocator getServiceLocator() throws MobyException
BaseClient
getServiceLocator
in class BaseClient
MobyException
- if service locator cannot be
returned/created (e.g. because there is not enough information
about what service to call)BaseClient.callRemoteService(java.lang.String)
public boolean fillRequest(MobyJob request, MobyPackage inputContext) throws MobyException
BaseClient
This is a method that should be implemented by a client developer, and it is the place where the client's business logic sits.
fillRequest
in class BaseClient
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 boolean useResponse(MobyJob response, MobyPackage responseContext) throws MobyException
BaseClient
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.
useResponse
in class BaseClient
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 brokenpublic static void main(String[] args)
|
Version: 1.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |