HPSearch

cgl.hpsearch.wsproxy
Class ProxyWebService

java.lang.Object
  extended bycgl.hpsearch.wsproxy.ProxyWebService
Direct Known Subclasses:
RunnableProxyWebService, WrapperProxyWebService

public abstract class ProxyWebService
extends Object

A Proxy Service that serves as a wrapper to other webservices that need to be hosted.
Created: May 14, 2004

Author:
Harshawardhan Gadgil (hgadgil@grids.ucs.indiana.edu)

Field Summary
 InvocationContainer container
           
static int INCORRECT_PARAMETERS
           
static int INIT_FAILURE
           
static int INIT_SUCCESS
           
static int INVOCATION_ERROR
           
static int SERVICE_DONE
           
static int SERVICE_FINISHED
           
static int SERVICE_NOT_FOUND
           
static int SERVICE_READY
           
static int SERVICE_RUNNING
           
static String[] SERVICE_STATUS
           
static int SERVICE_STOPPED
           
static int SERVICE_SUSPENDED
           
static int SERVICE_TERMINATED
           
 String serviceName
           
 
Constructor Summary
ProxyWebService()
           
 
Method Summary
 void cleanup()
           
 String[] getContext(String contextURI)
          Retrieves the context data from the location specified by contextURI
 String getNewTemporaryFileName()
           
 String getProperty(String name)
          Returns the value of the property
 int getStatus()
           
 void handleException(Exception e)
          Safe error handler for handling processing errors.
abstract  void initService(InputStream[] in, OutputStream[] out)
          Should be used by services to set the i/p and o/p streams.
abstract  void process()
          Other services MUST override this.
 void registerTemporaryFile(String tmpFileName)
           
abstract  void resumeService()
           
abstract  String[] serviceExceptions()
          An array of possible exceptions that can happen when the service is running.
 void serviceFinished()
          Indicates that the service has done processing.
 String setContext(String contextURI, String[] data)
          Stores the context data in teh location specified by contextURI
 void setInvocationHandler(String invokedService, InvocationContainer ic)
          Must be called by the InvocationContainer to specify which service is being run and a pointer to the InvocationConatainer.
 void setLogEntry(String entry)
          Sets the logging entry
 void setProperty(String name, String value)
          Sets the service's system property
 void setStatus(int _status)
          Provides a way for setting the service status.
abstract  void startService()
           
abstract  void stopService()
           
abstract  void suspendService()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INVOCATION_ERROR

public static final int INVOCATION_ERROR
See Also:
Constant Field Values

INCORRECT_PARAMETERS

public static final int INCORRECT_PARAMETERS
See Also:
Constant Field Values

SERVICE_NOT_FOUND

public static final int SERVICE_NOT_FOUND
See Also:
Constant Field Values

INIT_FAILURE

public static final int INIT_FAILURE
See Also:
Constant Field Values

INIT_SUCCESS

public static final int INIT_SUCCESS
See Also:
Constant Field Values

SERVICE_READY

public static final int SERVICE_READY
See Also:
Constant Field Values

SERVICE_RUNNING

public static final int SERVICE_RUNNING
See Also:
Constant Field Values

SERVICE_SUSPENDED

public static final int SERVICE_SUSPENDED
See Also:
Constant Field Values

SERVICE_FINISHED

public static final int SERVICE_FINISHED
See Also:
Constant Field Values

SERVICE_STOPPED

public static final int SERVICE_STOPPED
See Also:
Constant Field Values

SERVICE_TERMINATED

public static final int SERVICE_TERMINATED
See Also:
Constant Field Values

SERVICE_DONE

public static final int SERVICE_DONE
See Also:
Constant Field Values

SERVICE_STATUS

public static final String[] SERVICE_STATUS

container

public InvocationContainer container

serviceName

public String serviceName
Constructor Detail

ProxyWebService

public ProxyWebService()
Method Detail

process

public abstract void process()
                      throws Exception
Other services MUST override this. This defines the unit of execution of the service.

Throws:
Exception

initService

public abstract void initService(InputStream[] in,
                                 OutputStream[] out)
Should be used by services to set the i/p and o/p streams.

Parameters:
in - - An array containing input streams used by the service
out - - An array containing output streams used by the service

serviceExceptions

public abstract String[] serviceExceptions()
An array of possible exceptions that can happen when the service is running. This may be as simple as java.io.Exception or may be even more verbose and lists out all possible exceptions.

Returns:
An array of String containing the possible exceptions to be caught.

setInvocationHandler

public final void setInvocationHandler(String invokedService,
                                       InvocationContainer ic)
Must be called by the InvocationContainer to specify which service is being run and a pointer to the InvocationConatainer.

Parameters:
invokedService - - Name of the service
ic - - Pointer to the invocation Container.

getStatus

public final int getStatus()
Returns:
The current status of the service

setStatus

public final void setStatus(int _status)
Provides a way for setting the service status. Services extending the RunnableProxyWebService can use this function to set the status during initialization stage.

Parameters:
_status -

setProperty

public final void setProperty(String name,
                              String value)
Sets the service's system property

Parameters:
name - Name of the property
value - Value to be set

getProperty

public final String getProperty(String name)
Returns the value of the property

Parameters:
name - The property being queried
Returns:
The value of the property specified by name

setLogEntry

public final void setLogEntry(String entry)
Sets the logging entry

Parameters:
entry - The log entry

setContext

public final String setContext(String contextURI,
                               String[] data)
Stores the context data in teh location specified by contextURI

Parameters:
contextURI - - The context location
data - - the data to store
Returns:

getContext

public final String[] getContext(String contextURI)
Retrieves the context data from the location specified by contextURI

Returns:
retrieved data, "NULL" if nothing found

cleanup

public final void cleanup()

getNewTemporaryFileName

public String getNewTemporaryFileName()

registerTemporaryFile

public void registerTemporaryFile(String tmpFileName)

serviceFinished

public final void serviceFinished()
Indicates that the service has done processing.


handleException

public final void handleException(Exception e)
Safe error handler for handling processing errors. This calls the InvocationContainer's logging function to notify the error and then suspends the execution.
Any other exceptions while suspending the thread are ignored.
TODO: Change the format for conveying error. Maybe enclose it in some XML structure

Parameters:
e - - The error that occurred while processing.

startService

public abstract void startService()
                           throws Exception
Throws:
Exception

stopService

public abstract void stopService()
                          throws Exception
Throws:
Exception

suspendService

public abstract void suspendService()
                             throws Exception
Throws:
Exception

resumeService

public abstract void resumeService()
                            throws Exception
Throws:
Exception

HPSearch

For comments and suggestions please send e-mail to Harshawardhan Gadgil
Last updated: June 9 2006