|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.services.applicationcontext.implementation.WTServiceProvider
An implementation of ApplicationContextServiceProvider which keeps track of services by keeping a collection of WTServiceInfo objects. It does not know how these objects are derived. WTServiceInfo objects can be manufactured in code or read in from some sort of file.
At the abstraction level of package applicationcontext, the requestor
is just an object instance. This means that in applicationcontext the
getService operations use the requestor object but there is no assumption
about how that object is used to locate the service. Class WTServiceProvider
in implementation uses the object to come up with an ordered set of class
names. These class names are searched for a matching service from the
most concrete to the most abstract.
Supported API: false
Extendable: false
Field Summary | |
private static String |
CLASSNAME
|
private static String |
RESOURCE
|
private Hashtable |
service
|
private com.objectspace.jgl.HashMap |
serviceImplementationSingletons
|
private com.objectspace.jgl.HashMap |
serviceInfos
|
private Hashtable |
serviceInfosForRequestor
|
private com.objectspace.jgl.HashMap |
serviceInfosWOSelector
|
private static boolean |
VERBOSE
|
Fields inherited from interface wt.services.applicationcontext.ApplicationContextServiceProvider |
SERVICE, WILD_CARD |
Constructor Summary | |
WTServiceProvider()
An abstract implementation of ApplicationContextServiceProvider. |
Method Summary | |
boolean |
addServiceInfo(WTServiceInfo serviceInfo)
Add an externally derived service information entry. |
protected String |
createInfoKey(String serviceName,
String selector,
String requestorName)
|
protected String |
createInfoKeyWOSelector(String serviceName,
String requestorName)
|
protected Vector |
getAllClasses(Object object)
|
protected void |
getAllSuperClasses(Class aClass,
Vector allClasses)
|
Object |
getService(ApplicationContextChild contextChild,
Object requestor,
Class serviceClass,
Object selector)
Get an array of services based on context, requestor, selector, and logical service name. |
Object |
getService(ApplicationContextChild contextChild,
Object requestor,
String serviceName,
Object selector)
Get an array of services based on context, requestor, selector, and logical service name. |
protected Object |
getServiceImplementation(ApplicationContextChild contextChild,
Object requestor,
String serviceName,
String implementationName,
boolean isSingleton)
|
String |
getServiceImplementationName(ApplicationContextChild contextChild,
Object requestor,
String serviceName,
Object selector)
Get the name of the service implementation class for a particular context, requestor, selector, and logical service name. |
Map |
getServiceImplementationNameMap(ApplicationContextChild contextChild,
ACRequestor requestor,
String serviceName,
Object selector)
Return the name of the service implementation. |
Map |
getServiceImplementationNameMap(ApplicationContextChild contextChild,
Object[] requestors,
String serviceName,
Object selector)
Return the name of the service implementation. |
WTServiceInfo[] |
getServiceInfos()
Return service info entries. |
protected WTServiceInfo[] |
getServiceInfosForRequestor(ApplicationContextChild contextChild,
Object requestor,
String serviceName,
String selector)
|
protected com.objectspace.jgl.HashMap |
getServiceInfosWOSelector()
Gets the object for the association that plays role: serviceInfosWOSelector. |
Map |
getServiceMap(ApplicationContextChild contextChild,
ACRequestor requestor,
Class serviceClass,
Object selector)
Return a service based on context, requestor and logical service type. |
Map |
getServiceMap(ApplicationContextChild contextChild,
ACRequestor requestor,
String serviceName,
Object selector)
Return an instance of a service based on context, requestor and logical service name. |
Map |
getServiceMap(ApplicationContextChild contextChild,
Object[] requestors,
Class serviceClass,
Object selector)
Return a service based on context, requestor and logical service type. |
Map |
getServiceMap(ApplicationContextChild contextChild,
Object[] requestors,
String serviceName,
Object selector)
Return an instance of a service based on context, requestor and logical service name. |
String[] |
getServiceNames()
Supported API: false |
Enumeration |
getServiceSelectors(ApplicationContextChild contextChild,
String serviceName,
Object requestor)
Supported API: false |
protected Object |
getSingletonImplementation(Class implementationClass)
If the implementation class doesn't have a public constructor, looks for a static getInstance() method to use to instantiate the service. |
void |
printOn(PrintStream ps)
|
protected void |
setServiceInfosWOSelector(com.objectspace.jgl.HashMap a_ServiceInfosWOSelector)
Sets the object for the association that plays role: serviceInfosWOSelector. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final String RESOURCE
private static final String CLASSNAME
private com.objectspace.jgl.HashMap serviceInfosWOSelector
private com.objectspace.jgl.HashMap serviceImplementationSingletons
private Hashtable serviceInfosForRequestor
private com.objectspace.jgl.HashMap serviceInfos
private Hashtable service
private static boolean VERBOSE
Constructor Detail |
public WTServiceProvider()
Method Detail |
protected com.objectspace.jgl.HashMap getServiceInfosWOSelector()
protected void setServiceInfosWOSelector(com.objectspace.jgl.HashMap a_ServiceInfosWOSelector)
a_ServiceInfosWOSelector
- public String[] getServiceNames()
getServiceNames
in interface ApplicationContextServiceProvider
public Object getService(ApplicationContextChild contextChild, Object requestor, String serviceName, Object selector) throws ServiceNotFoundException, UnableToCreateServiceException
Prior to R3.0 this method was implemented to return only a single service, not an array of services.
The algorithm for resolving a service was as follows:
For R3.0 the algortihm has been modified to return multiple service implementation based on the following rules:
ApplicationContextServicesSupport implements a new method, getServices,
which returns all the service implementations resolved through the
above rules.
Supported API: false
getService
in interface ApplicationContextServiceProvider
contextChild
- The context in which the service is being requested. May be null.requestor
- The target of the service request.serviceName
- The name of the logical service.selector
-
ServiceNotFoundException
UnableToCreateServiceException
public Object getService(ApplicationContextChild contextChild, Object requestor, Class serviceClass, Object selector) throws ServiceNotFoundException, UnableToCreateServiceException
getService
in interface ApplicationContextServiceProvider
contextChild
- The context in which the service is being requested.requestor
- The object on who's behalf the service is being requested.serviceClass
- The logical service class.selector
-
ServiceNotFoundException
UnableToCreateServiceException
public Map getServiceMap(ApplicationContextChild contextChild, Object[] requestors, String serviceName, Object selector) throws UnableToCreateServiceException
getServiceMap
in interface ApplicationContextServiceProvider
contextChild
- The context in which the service is being requested.requestors
- The target of the service request.serviceName
- The name of the requested service.selector
- An optional selector to further identify the service.
UnableToCreateServiceException
public Map getServiceMap(ApplicationContextChild contextChild, Object[] requestors, Class serviceClass, Object selector) throws UnableToCreateServiceException
getServiceMap
in interface ApplicationContextServiceProvider
contextChild
- The service context in which the getService request was initiated.requestors
- The object on who's behalf the service request is being made.serviceClass
- The logical service class being requested.selector
- An optional selector to further identify the service.
UnableToCreateServiceException
public Map getServiceMap(ApplicationContextChild contextChild, ACRequestor requestor, String serviceName, Object selector) throws UnableToCreateServiceException
getServiceMap
in interface ApplicationContextServiceProvider
contextChild
- The context in which the service is being requested.requestor
- serviceName
- The name of the requested service.selector
- An optional selector to further identify the service.
UnableToCreateServiceException
public Map getServiceMap(ApplicationContextChild contextChild, ACRequestor requestor, Class serviceClass, Object selector) throws UnableToCreateServiceException
getServiceMap
in interface ApplicationContextServiceProvider
contextChild
- The service context in which the getService request was initiated.requestor
- serviceClass
- The logical service class being requested.selector
- An optional selector to further identify the service.
UnableToCreateServiceException
public Enumeration getServiceSelectors(ApplicationContextChild contextChild, String serviceName, Object requestor)
getServiceSelectors
in interface ApplicationContextServiceProvider
contextChild
- serviceName
- requestor
-
public String getServiceImplementationName(ApplicationContextChild contextChild, Object requestor, String serviceName, Object selector)
getServiceImplementationName
in interface ApplicationContextServiceProvider
contextChild
- requestor
- serviceName
- selector
-
public Map getServiceImplementationNameMap(ApplicationContextChild contextChild, Object[] requestors, String serviceName, Object selector)
getServiceImplementationNameMap
in interface ApplicationContextServiceProvider
contextChild
- The context in which the service request was initiated. May be used to determine which service implementation should be returned.requestors
- The requestor or target of the service. Used to determine which service implementation should be returned.serviceName
- The logical name of the desired service.selector
- An optional selector to further identify the service.
public Map getServiceImplementationNameMap(ApplicationContextChild contextChild, ACRequestor requestor, String serviceName, Object selector)
getServiceImplementationNameMap
in interface ApplicationContextServiceProvider
contextChild
- The context in which the service request was initiated. May be used to determine which service implementation should be returned.requestor
- serviceName
- The logical name of the desired service.selector
- An optional selector to further identify the service.
public boolean addServiceInfo(WTServiceInfo serviceInfo)
serviceInfo
- The service info to be added.
public WTServiceInfo[] getServiceInfos()
protected Object getServiceImplementation(ApplicationContextChild contextChild, Object requestor, String serviceName, String implementationName, boolean isSingleton) throws UnableToCreateServiceException
UnableToCreateServiceException
protected WTServiceInfo[] getServiceInfosForRequestor(ApplicationContextChild contextChild, Object requestor, String serviceName, String selector)
protected Vector getAllClasses(Object object)
protected void getAllSuperClasses(Class aClass, Vector allClasses)
protected String createInfoKeyWOSelector(String serviceName, String requestorName)
protected String createInfoKey(String serviceName, String selector, String requestorName)
public void printOn(PrintStream ps)
protected Object getSingletonImplementation(Class implementationClass) throws ClassNotFoundException, IllegalAccessException, InstantiationException
ClassNotFoundException
IllegalAccessException
InstantiationException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |