Class ServiceFactoryObject
- java.lang.Object
-
- com.attivio.service.ServiceFactoryObject
-
- All Implemented Interfaces:
ServiceFactory
public class ServiceFactoryObject extends java.lang.Object implements ServiceFactory
SDK supported methods for getting and using registered Attivio APIs.
-
-
Constructor Summary
Constructors Constructor Description ServiceFactoryObject()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TgetService(java.lang.Class<T> clazz)<T> TgetService(java.lang.Class<T> clazz, long timeout)<T> TgetService(java.lang.Class<T> clazz, java.lang.String nodeName)<T> TgetService(java.lang.Class<T> clazz, java.lang.String nodeName, long timeout)Returns an implementation of the desired service API.<T> TgetService(java.lang.Class<T> clazz, java.util.Map<java.lang.String,java.lang.String> attributes, long timeout)Returns an implementation of the desired service API.voidsetParams(java.lang.String projectName, java.lang.String projectEnvironment, java.lang.String zookeeperConnectionInfo, java.lang.Object serviceFactoryParams)Set parameters needed to get services from a remote instance of attivio and allow for arbitrary service factory parameters
-
-
-
Method Detail
-
setParams
public void setParams(java.lang.String projectName, java.lang.String projectEnvironment, java.lang.String zookeeperConnectionInfo, java.lang.Object serviceFactoryParams)Set parameters needed to get services from a remote instance of attivio and allow for arbitrary service factory parameters- Parameters:
projectName-projectEnvironment-zookeeperConnectionInfo-serviceFactoryParams- this is optional
-
getService
public <T> T getService(java.lang.Class<T> clazz) throws AttivioExceptionDescription copied from interface:ServiceFactorySeeServiceFactory.getService(Class, String, long). Node will default tonulland timeout will be-1L.- Specified by:
getServicein interfaceServiceFactory- Throws:
AttivioException
-
getService
public <T> T getService(java.lang.Class<T> clazz, long timeout) throws AttivioExceptionDescription copied from interface:ServiceFactorySeeServiceFactory.getService(Class, String, long). Node will default tonull.- Specified by:
getServicein interfaceServiceFactory- Throws:
AttivioException
-
getService
public <T> T getService(java.lang.Class<T> clazz, java.lang.String nodeName) throws AttivioExceptionDescription copied from interface:ServiceFactorySeeServiceFactory.getService(Class, String, long). Timeout will default to-1L.- Specified by:
getServicein interfaceServiceFactory- Throws:
AttivioException
-
getService
public <T> T getService(java.lang.Class<T> clazz, java.lang.String nodeName, long timeout) throws AttivioExceptionDescription copied from interface:ServiceFactoryReturns an implementation of the desired service API.Services come in two flavors. Some services are registered by a service provider and provide services through remote client implementations. Other services are built on an external platform such as a database. The latter are referred to as client-base services since from the AIE point of view, only a client is required. In either case, this method returns a (generally proxied) implementation that provides the service API.
The timeout parameter is applicable only to registered services. This is because client-based services are provided externally and the ServiceFactory has no way of knowing if those services are up or not. For registered services, the timeout applies to the time for that service to be registered with the system. This lets callers wait a bit (say during a startup situation) for the service to come online but not wait indefinitely.
When the timeout is in use, the service will be checked for registration every 100ms. A timeout < 0 will wait indefinitely. Regardless of the timeout, the availability of the service will always be tried at least once. That is, a low timeout or timeout of 0 will still succeed if the service is registered or is provided by a client-based API.
- Specified by:
getServicein interfaceServiceFactory- Parameters:
clazz- the class type of the desired APInodeName- name of the AIE node the service must be running on, ornullif any node is fine.timeout- timeout in ms- Returns:
- an implementation of the API or
nullif unavailable within the timeout. - Throws:
AttivioException
-
getService
public <T> T getService(java.lang.Class<T> clazz, java.util.Map<java.lang.String,java.lang.String> attributes, long timeout) throws AttivioExceptionReturns an implementation of the desired service API.Services come in two flavors. Some services are registered by a service provider and provide services through remote client implementations. Other services are built on an external platform such as a database. The latter are referred to as client-base services since from the AIE point of view, only a client is required. In either case, this method returns a (generally proxied) implementation that provides the service API.
The timeout parameter is applicable only to registered services. This is because client-based services are provided externally and the ServiceFactory has no way of knowing if those services are up or not. For registered services, the timeout applies to the time for that service to be registered with the system. This lets callers wait a bit (say during a startup situation) for the service to come online but not wait indefinitely.
When the timeout is in use, the service will be checked for registration every 100ms. A timeout < 0 will wait indefinitely. Regardless of the timeout, the availability of the service will always be tried at least once. That is, a low timeout or timeout of 0 will still succeed if the service is registered or is provided by a client-based API.
- Specified by:
getServicein interfaceServiceFactory- Parameters:
clazz- the class type of the desired APIattributes- map of attributes that must match the service, ornullor an empty map if any instance is fine. To match by node name, use a key value ofnodeNameand the the node name as the value.timeout- timeout in ms- Returns:
- an implementation of the API or
nullif matching service unavailable within the timeout. - Throws:
AttivioException
-
-