IS-Cache

From Gcube Wiki
Revision as of 10:56, 13 October 2011 by Vassilis.verroios (Talk | contribs) (Usage)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The IS-Cache provides simple and flexible methods for retrieving and caching the Endpoint references of gCube web services published in the IS. A component that uses the IS-Cache library, is able to retrieve Endpoint references for:

  • services' Running Instances
  • factory services' Running Instances
  • Web Service statefull resources

Additionally the IS-Cache provides an option for further restricting the final results, by using custom filtering criteria.

Usage

The first step for using the ISCache is to create an instance for a specific scope through the following constructor

        /**
	 * Constructor
	 * @param scope scope
	 */
	public ISCache(GCUBEScope scope);

Then using this instance a component can find the EPRs for services' RIs by using the following method

        /**
	 * Get the running instances (array of URLs) of the specified service
	 * 
	 * @param srvClass
	 *            service class
	 * @param srvName
	 *            service name
	 * @param srvType
	 * 			  service type
	 * @return the running instances (array of URLs) of the specified service
	 * @throws Exception
	 *             in case of error; most probably due to the fact that the
	 *             specified service is not registered.
	 * @see org.gcube.informationsystem.cache.ISCacheMBean#getEPRsFor(String, String,
	 *      String)
	 */
	public EndpointReference[] getEPRsFor(String srvClass, String srvName, String srvType);

For example consider the case where a component needs to find the EPRs of the "SearchSystemService":

EndpointReference[] eprs = isCache.getEPRsFor("Search", "SearchSystemService", "SIMPLE");

There are three options for the "srvType" option:

  • SIMPLE - for all the service's EPRs (including the factory porttypes of this service)
  • FACTORY - for the service's endpoints that contain the word "Factory" (this means that we need only the factory porttypes of this service)
  • STATEFULL - for the EPRs of the WS resources of a statefull service

Note that the ISCache periodically harvests the IS, in order to retrieve information for the requested services. Thus, the results of the afforementioned method are pre-fetched(after the first request for a specific service).

The ISCache also provides an option for custom filtering criteria through the following method:

        /**
	 * Add new filtering criterion on a specific service on a given type. This
	 * filtering criterion applies only for the given service type.
	 * 
	 * @param srvClass
	 *            service class
	 * @param srvName
	 *            service name
	 * @param srvType
	 *            service type
	 * @param critVar
	 *            criterion r-value
	 * @param critVal
	 *            criterion l-value
	 * @return true if the critVar has not been added before; false otherwise
	 * @throws Exception
	 *             in case of error
	 * @see org.gcube.informationsystem.cache.ISCacheMBean#addFilterCriterion(String,
	 *      String, String, String, String)
	 */
	public boolean addFilterCriterion(String srvClass, String srvName,
			String srvType, String critVar, String critVal);

For each filtering criteria added, we add a new AtomicCondition to the ISClient query for the corresponding service(defined by the srvClass, srvName, srvType triple ). The new AtomicCondition contains the pair "critVar" - "critVal":

       new AtomicCondition(critVar, critVal)

For more details read the javadoc of the ISCache.