org.astrogrid.acr.builtin
Interface ACR


public interface ACR

Interface into a running Astro Runtime, from which AR services can be accessed.

See Also:
Example of accessing an AR service by interface class, Example of accessing an AR service by name, Finder

Method Summary
 Object getService(Class interfaceClass)
          Retrieve an instance of an AR Service by class.
 Object getService(String componentName)
          Retreive an instance of an AR service by name.
 

Method Detail

getService

Object getService(Class interfaceClass)
                  throws ACRException,
                         InvalidArgumentException,
                         NotFoundException
Retrieve an instance of an AR Service by class.

Example:

import org.astrogrid.acr.system.Configuration;
import org.astrogrid.acr.builtin.ACR;
import org.astrogrid.acr.Finder;
Finder f = new Finder();
ACR ar = f.find(); 
Configuration c = (Configuration) ar.getService(Configuration.class)

Parameters:
interfaceClass - the interface class for a service. This must be one of the interface classes in this api marked as 'AR Service'.
Returns:
an instance of the requested service.
Throws:
InvalidArgumentException - if the parameter class is not an interface
NotFoundException - if the parameter class is not an available service in the ACR
ACRException - if another error occurs while retrieving the service instance

getService

Object getService(String componentName)
                  throws ACRException,
                         InvalidArgumentException,
                         NotFoundException
Retreive an instance of an AR service by name.

Note:

This method is a less-well-typed equvalent to ACR.getService(Class) - prefer use that method. However, this method is handy when it isn't easy to get hold of class objects - e.g. from in-java scripting languages, and via the xmlrpc interface.

Example:

import org.astrogrid.acr.system.Configuration;
import org.astrogrid.acr.builtin.ACR;
import org.astrogrid.acr.Finder;
Finder f = new Finder();
ACR ar = f.find(); 
Configuration c = (Configuration) ar.getService("system.configuration")

Parameters:
componentName - the name of the service - (as defined by the Service Name block in API documentation). These are the same component names as used in the XMLRPC interface - all follow the form moduleName.componentName
Returns:
an instance of the requested service.
Throws:
InvalidArgumentException - if the componentName does not follow the form moduleName.componentName
NotFoundException - if this componentName is not an available service in the ACR
ACRException - if another error occurs while retrieving the service instance


Copyright © 2002-2010 AstroGrid. All Rights Reserved.