Version: 1.1.1

org.biomoby.client
Class BaseCmdLineClient

java.lang.Object
  extended by org.biomoby.client.BaseClient
      extended by org.biomoby.client.BaseCmdLineClient

public class BaseCmdLineClient
extends BaseClient

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.

Version:
$Id: BaseCmdLineClient.java,v 1.7 2006/05/09 13:32:09 senger Exp $
Author:
Martin Senger

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

BaseCmdLineClient

public BaseCmdLineClient()

BaseCmdLineClient

public BaseCmdLineClient(String[] args)
Method Detail

reportError

public void reportError(Throwable e)

getUsage

public String getUsage()
Return a help text about this this client.


doEverything

public void doEverything()

fillRequest

public boolean fillRequest(MobyPackage mobyInput,
                           int jobCount)
                    throws MobyException
Description copied from class: BaseClient
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).

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)).

Overrides:
fillRequest in class BaseClient
Parameters:
mobyInput - is an empty shell that you are supposed to fill with the input data for a Biomoby service execution
jobCount - 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
Returns:
false if you wish to cancel whole request (nothing will be sent to a Biomoby service); otherwise return true.
Throws:
MobyException

fillRequest

public String fillRequest()
                   throws MobyException
Description copied from class: BaseClient
Create raw XML input. Override this method if you have already an input XML, or you want to create it yourself.

Overrides:
fillRequest in class BaseClient
Returns:
a full XML input for a Biomoby service (in this case no other fillRequest methods will called); return null if no XML was created and a usual process to gather it will be used
Throws:
MobyException - if an XML cannot be created

interceptRequest

public String interceptRequest(String xmlInput)
                        throws MobyException
Overrides:
interceptRequest in class BaseClient
Throws:
MobyException

callRemoteService

public String callRemoteService(String xmlInput)
                         throws MobyException
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).

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).

Overrides:
callRemoteService in class BaseClient
Parameters:
xmlInput - data will be sent to the called Biomoby service
Returns:
service response (still in XML)
Throws:
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 failed
See Also:
BaseClient.callRemoteService(java.lang.String)

useResponse

public boolean useResponse(String xmlResponse)
                    throws MobyException
Description copied from class: BaseClient
A raw-level processing. Use it if you need access to raw XML coming from a service.

Overrides:
useResponse in class BaseClient
Parameters:
xmlResponse - is a raw XML response returned from a BioMoby service
Returns:
false if the response should be considered fully processed (in this case no other 'useResponse' will be called); true indicates that normal processing of the response will follow; by default, this class (BaseClient) returns true
Throws:
MobyException - if you are not satisfied with a response data, or from whatever reasons; it also throws this exception if the 'mobyResponse' is broken

useResponse

public void useResponse(MobyPackage mobyResponse)
                 throws MobyException
Description copied from class: BaseClient
A high-level processing. Use it if you need access to all jobs (queries) - that returned from a service - in the same time. Otherwise use the processing on the job level (method BaseClient.useResponse(MobyJob,MobyPackage).

Overrides:
useResponse in class BaseClient
Parameters:
mobyResponse - is a full response returned from a BioMoby service
Throws:
MobyException - if you are not satisfied with a response data, or from whatever reasons; it also throws this exception if the 'mobyResponse' is broken

getServiceLocator

public MobyServiceLocator getServiceLocator()
                                     throws MobyException
Description copied from class: BaseClient
Return characteristics of a BioMoby service that will be called, and that reveal where to find such service.

Specified by:
getServiceLocator in class BaseClient
Returns:
an object defining a location of a BioMoby service
Throws:
MobyException - if service locator cannot be returned/created (e.g. because there is not enough information about what service to call)
See Also:
BaseClient.callRemoteService(java.lang.String)

fillRequest

public boolean fillRequest(MobyJob request,
                           MobyPackage inputContext)
                    throws MobyException
Description copied from class: BaseClient
Crate data (fill them into 'request') for one Moby job (query). The request will be sent within given 'inputContext' - but it is not yet there (because you may wish not to put it there - see the return value), and it is not the task of this method to put it there (just fill the 'request').

This is a method that should be implemented by a client developer, and it is the place where the client's business logic sits.

Specified by:
fillRequest in class BaseClient
Parameters:
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 it
inputContext - 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
Returns:
true if this request should be included into the input data (package) that will be sent to a biomoby service; or return false if you do not wish to create any more requests for this particular package (also this 'request' will not be used)
Throws:
MobyException - if you need so (from whatever reason in your business logic); if thrown then nothing will be sent to a Biomoby service

useResponse

public boolean useResponse(MobyJob response,
                           MobyPackage responseContext)
                    throws MobyException
Description copied from class: BaseClient
Process a single job returned from a BioMoby service.

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.

Specified by:
useResponse in class BaseClient
Parameters:
response - is an object that you are supposed to use
responseContext - 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')
Returns:
false if you do not wish to get any more responses/jobs; otherwise return true
Throws:
MobyException - if you are not satisfied with a response data, or from whatever reasons; it also throws this exception if the 'response' is broken

main

public static void main(String[] args)

Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010