Version: 1.1.1

org.biomoby.shared
Class MobyService

java.lang.Object
  extended by org.biomoby.shared.MobyService
All Implemented Interfaces:
Cloneable, Comparable<MobyService>, LSIDAccessible

public class MobyService
extends Object
implements Comparable<MobyService>, Cloneable, LSIDAccessible

A container representing a service. But do not be too excited - this is not a real service but only its definition as it appears in the BioMoby registry.

This container is used mainly to register a new service in a Moby registry, and to find registered services later.

Version:
$Id: MobyService.java,v 1.28 2009/05/19 21:03:56 kawas Exp $
Author:
Martin Senger

Field Summary
static int ALIVE
           
static String BIOMOBY_SERVICE_URI
          An immutable string representing URI (namespace) of all Biomoby services.
static String CATEGORY_CGI
          Name of a category for CGI BioMoby services.
static String CATEGORY_CGI_ASYNC
          Name of an asynchronous CGI category for BioMoby services.
static String CATEGORY_MOBY
          Name of a default category for BioMoby services.
static String CATEGORY_MOBY_ASYNC
          Name of a category for asynchornous BioMoby services.
static String CATEGORY_MOBY_DOCLIT
          Name of a category for document/literal BioMoby services.
static String CATEGORY_MOBY_DOCLIT_ASYNC
          Name of a category for asynchronous document/literal BioMoby services.
static int DEAD
           
static String DUMMY_NAME
          A dummy name used for MobyService instances that do not have (yet) a real name.
static int PINGED
           
static String SUBMIT_ACTION_SUFFIX
          A suffix added to a service name in order to make a method name that submits input to an asynchronous service.
static int TESTED
           
static int UNCHECKED
           
 
Constructor Summary
MobyService()
          Default constructor.
MobyService(String name)
          Normal constructor.
MobyService(String name, String authority)
          Even more normal constructor - because a service is fully qualified only by its name and its authority.
 
Method Summary
 void addInput(MobyData value)
           
 void addOutput(MobyData value)
          Adds an output parameter to the service.
 void addUnitTest(MobyUnitTest unitTest)
           
 MobyService clone()
          Generally, you don't need to clone a service, unless you plan on modifying fields of the object, but do not want it to affect the service definition used by other threads within the JVM (i.e. getService(serviceName) always returns the same object within a single JVM instance).
 int compareTo(MobyService obj)
          Implementing Comparable interface.
 boolean equals(MobyService anotherOne)
           
 boolean equals(Object obj)
           
 String getAuthority()
           
static Comparator getAuthorityComparator()
          Create a comparator for case-insensitive sorting of services by their authorities.
 String getCategory()
           
 String getDescription()
           
 String getEmailContact()
           
 String getId()
          Return an ID that is given to this service instance during its registration.
 String getLSID()
           
 String getName()
           
 String getPathToRDF()
           
 MobyPrimaryData[] getPrimaryInputs()
           
 MobyPrimaryData[] getPrimaryOutputs()
           
 String getRDF()
           
 MobySecondaryData[] getSecondaryInputs()
           
static MobyService getService(String lsid)
           
static MobyService getService(String name, String authority)
           
 MobyServiceType getServiceType()
           
 String getSignatureURL()
          Return a URL pointing to an RDF document that contains this service description (signature).
 int getStatus()
           
 String getType()
           
 String getUniqueName()
           
 MobyUnitTest[] getUnitTests()
           
 String getURL()
          Return a URL where this service is being served from.
 int hashCode()
           
 boolean isAsynchronous()
           
 boolean isAuthoritative()
           
 void removeInput(MobyData value)
           
 void removeOutput(MobyData value)
           
 void removeUnitTest(MobyUnitTest unitTest)
           
 void setAuthoritative(boolean value)
           
 void setAuthority(String value)
           
 void setCategory(String value)
           
 void setDescription(String value)
           
 void setEmailContact(String value)
           
 void setId(String value)
          Don't use it.
 void setInputs(MobyData[] value)
          Adds an array of input parameter to the service.
 void setLSID(String value)
           
 void setName(String value)
           
 void setOutputs(MobyData[] value)
          Adds an array of output parameter to the service.
 void setPathToRDF(String value)
           
 void setRDF(String value)
           
 void setServiceType(MobyServiceType serviceType)
           
 void setSignatureURL(String value)
           
 void setStatus(int statusCode, boolean mode)
           
 void setType(String value)
           
 void setUnitTests(MobyUnitTest[] unitTests)
           
 void setURL(String value)
           
 String toShortString()
          It combines this service name and its authority name.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DUMMY_NAME

public static final String DUMMY_NAME
A dummy name used for MobyService instances that do not have (yet) a real name.

See Also:
Constant Field Values

BIOMOBY_SERVICE_URI

public static final String BIOMOBY_SERVICE_URI
An immutable string representing URI (namespace) of all Biomoby services.

See Also:
Constant Field Values

UNCHECKED

public static final int UNCHECKED
See Also:
Constant Field Values

DEAD

public static final int DEAD
See Also:
Constant Field Values

ALIVE

public static final int ALIVE
See Also:
Constant Field Values

PINGED

public static final int PINGED
See Also:
Constant Field Values

TESTED

public static final int TESTED
See Also:
Constant Field Values

CATEGORY_MOBY

public static final String CATEGORY_MOBY
Name of a default category for BioMoby services.

See Also:
Constant Field Values

CATEGORY_MOBY_ASYNC

public static final String CATEGORY_MOBY_ASYNC
Name of a category for asynchornous BioMoby services.

See Also:
Constant Field Values

CATEGORY_CGI

public static final String CATEGORY_CGI
Name of a category for CGI BioMoby services.

See Also:
Constant Field Values

CATEGORY_CGI_ASYNC

public static final String CATEGORY_CGI_ASYNC
Name of an asynchronous CGI category for BioMoby services.

See Also:
Constant Field Values

CATEGORY_MOBY_DOCLIT

public static final String CATEGORY_MOBY_DOCLIT
Name of a category for document/literal BioMoby services.

See Also:
Constant Field Values

CATEGORY_MOBY_DOCLIT_ASYNC

public static final String CATEGORY_MOBY_DOCLIT_ASYNC
Name of a category for asynchronous document/literal BioMoby services.

See Also:
Constant Field Values

SUBMIT_ACTION_SUFFIX

public static final String SUBMIT_ACTION_SUFFIX
A suffix added to a service name in order to make a method name that submits input to an asynchronous service.

See Also:
Constant Field Values
Constructor Detail

MobyService

public MobyService()
Default constructor.


MobyService

public MobyService(String name)
Normal constructor. Other characteristics are empty - which is usually wrong - therefore use 'set' methods to fill them before using this instance.


MobyService

public MobyService(String name,
                   String authority)
Even more normal constructor - because a service is fully qualified only by its name and its authority.

Method Detail

compareTo

public int compareTo(MobyService obj)
Implementing Comparable interface.

Specified by:
compareTo in interface Comparable<MobyService>

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

clone

public MobyService clone()
Generally, you don't need to clone a service, unless you plan on modifying fields of the object, but do not want it to affect the service definition used by other threads within the JVM (i.e. getService(serviceName) always returns the same object within a single JVM instance).

Overrides:
clone in class Object

getUniqueName

public String getUniqueName()

setStatus

public void setStatus(int statusCode,
                      boolean mode)
Parameters:
statusCode - should be one of ALIVE, PINGED, TESTED
mode - whether the service passed the requirement or not

getStatus

public int getStatus()
Returns:
bit-wise combination of ALIVE, PINGED, TESTED states for the service, or DEAD if no tests passed, or UNCHECKED if no tests have been run

getName

public String getName()

setName

public void setName(String value)

getId

public String getId()
Return an ID that is given to this service instance during its registration. The ID is used only for de-registration of this service instance (you are not supposed to fill it when you create an instance of this object). But it soon becomes obsolete anyway because of the new way of registering services (see getSignatureURL()).


setId

public void setId(String value)
Don't use it.

See Also:
getId()

getLSID

public String getLSID()
Specified by:
getLSID in interface LSIDAccessible

setLSID

public void setLSID(String value)

isAuthoritative

public boolean isAuthoritative()

setAuthoritative

public void setAuthoritative(boolean value)

getAuthority

public String getAuthority()

setAuthority

public void setAuthority(String value)

getEmailContact

public String getEmailContact()

setEmailContact

public void setEmailContact(String value)

getCategory

public String getCategory()

setCategory

public void setCategory(String value)

getDescription

public String getDescription()

setDescription

public void setDescription(String value)

getType

public String getType()

setType

public void setType(String value)

getUnitTests

public MobyUnitTest[] getUnitTests()
Returns:
an array of MobyUnitTest objects set for this service

setUnitTests

public void setUnitTests(MobyUnitTest[] unitTests)
Parameters:
unitTests - the tests to set for the service

addUnitTest

public void addUnitTest(MobyUnitTest unitTest)
Parameters:
unitTest - the MobyUnitTest to add to our service

removeUnitTest

public void removeUnitTest(MobyUnitTest unitTest)
Parameters:
unitTest - the test to remove from the set of tests for the service

getURL

public String getURL()
Return a URL where this service is being served from. It is a URL where the clients of this service are going when they want to use it.

Note that there is nothing in the BioMoby registry remembering (registering) a namespace of your service. Therefore, your service is supposed to use always the namespace http://biomoby.org.


setURL

public void setURL(String value)
See Also:
getURL()

getSignatureURL

public String getSignatureURL()
Return a URL pointing to an RDF document that contains this service description (signature). Note that this RDF document can include also other things, such as other service signatures.

This is how it works:

  1. When you register a service (using an instance of this class) you put here (by calling setSignatureURL(java.lang.String)) a URL pointing to your HTTP space, to an RDF document. But this document does not need to exist yet.
  2. After a successful registration this instance will have an RDF document with this service signature. You can obtain it by calling getRDF().
  3. You are expected to copy this RDF document to the place that you had suggested in step 1. Failing to do it will result in de-registrating your service automatically sometimes later. Therefore, if your service is only a testing one, do not copy RDF anywhere and the service will disappear.
  4. Some implementations of the Central interface (such as its default implementation CentralImpl can copy the RDF document for you if you put here a fully qualified path to the file where the RDF document should be put (by calling setPathToRDF(java.lang.String)).


setSignatureURL

public void setSignatureURL(String value)
See Also:
getSignatureURL()

getPathToRDF

public String getPathToRDF()
See Also:
getSignatureURL()

setPathToRDF

public void setPathToRDF(String value)

getRDF

public String getRDF()
See Also:
getSignatureURL()

setRDF

public void setRDF(String value)

setInputs

public void setInputs(MobyData[] value)
Adds an array of input parameter to the service. NOTE: the "set" is a bit of a misnomer: parameters will be added to the existing list. To clear the existing list of parameters, call this finction with 'null' first.


addInput

public void addInput(MobyData value)

removeInput

public void removeInput(MobyData value)

setOutputs

public void setOutputs(MobyData[] value)
Adds an array of output parameter to the service. NOTE: Unless the parameter is Primary, it will be ignored. ALSO NOTE: the "set" is a bit of a misnomer: parameters will be added to the existing list. To clear the existing list of parameters, call this finction with 'null' first.


addOutput

public void addOutput(MobyData value)
Adds an output parameter to the service. NOTE: Unless the parameter is Primary, it will be ignored.


removeOutput

public void removeOutput(MobyData value)

getPrimaryInputs

public MobyPrimaryData[] getPrimaryInputs()

getSecondaryInputs

public MobySecondaryData[] getSecondaryInputs()

getPrimaryOutputs

public MobyPrimaryData[] getPrimaryOutputs()

equals

public boolean equals(MobyService anotherOne)

toString

public String toString()
Overrides:
toString in class Object

toShortString

public String toShortString()
It combines this service name and its authority name. It is used also in equals(java.lang.Object) and compareTo(org.biomoby.shared.MobyService) methods.

TBD: The authority should be checked that it does not contain character sequence 'space followed by a left parenthesis'.


getAuthorityComparator

public static Comparator getAuthorityComparator()
Create a comparator for case-insensitive sorting of services by their authorities.


getServiceType

public MobyServiceType getServiceType()
Returns:
the MobyServiceType of this service

setServiceType

public void setServiceType(MobyServiceType serviceType)
Parameters:
serviceType - the MobyServiceType of this service

getService

public static MobyService getService(String lsid)

getService

public static MobyService getService(String name,
                                     String authority)

isAsynchronous

public boolean isAsynchronous()

Version: 1.1.1

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