wt.services.applicationcontext
Class ApplicationContextServicesSupport

java.lang.Object
  extended bywt.services.applicationcontext.ApplicationContextServicesSupport
All Implemented Interfaces:
ApplicationContext, ApplicationContextChild, ApplicationContextServices
Direct Known Subclasses:
TypeBasedApplicationContext, WTDefaultApplicationContext

public class ApplicationContextServicesSupport
extends Object
implements ApplicationContextServices

A basic implementation of a ApplicationContextServices.

Supported API: false

Extendable: false


Field Summary
private  ApplicationContext applicationContext
           
private  ApplicationContextServices applicationContextServices
           
private static String CLASSNAME
           
private  ApplicationContextServices peer
           
private static String RESOURCE
           
private  com.objectspace.jgl.HashMap serviceProviders
           
 
Fields inherited from interface wt.services.applicationcontext.ApplicationContextServices
SERVICE
 
Fields inherited from interface wt.services.applicationcontext.ApplicationContextChild
APPLICATION_CONTEXT
 
Constructor Summary
ApplicationContextServicesSupport()
          

Supported API: false
ApplicationContextServicesSupport(ApplicationContextServices peer)
          

Supported API: false
 
Method Summary
 boolean addAllServices(ApplicationContextServiceProvider serviceProvider)
          Register all the services which can be supplied by the service provider.
 boolean addService(String serviceName, ApplicationContextServiceProvider serviceProvider)
          Add an entry which maps the serviceClass argument to the serviceProvider object.
 ApplicationContext getApplicationContext()
          Gets the object for the association that plays role: applicationContext.
 ApplicationContextServices getApplicationContextServices()
          

Supported API: false
 ApplicationContextServices getPeer()
          Gets the object for the association that plays role: peer.
 Object getService(ApplicationContextChild childContext, Object requestor, Class serviceClass, Object selector)
          Get a service based on the context, the requesting object, the selector, and the logical service class.
 Object getService(ApplicationContextChild childContext, Object requestor, String serviceName, Object selector)
          Get a service based on the context, the requesting object, the selector, and the logical service name.
private  Object getServiceImpl(ApplicationContextChild childContext, Object requestor, String serviceName, Object selector)
          Tries to get the requested service in the current context from the ApplicationContextServiceProvider associated with the requested service.
 String getServiceImplementationName(ApplicationContextChild childContext, Object requestor, String serviceName, Object selector)
          Get the name of the service implementation.
 Map getServiceImplementationNameMap(ApplicationContextChild childContext, ACRequestor requestor, String serviceName, Object selector)
          Get the name of the service implementation.
 Map getServiceImplementationNameMap(ApplicationContextChild childContext, Object[] requestors, String serviceName, Object selector)
          Get the name of the service implementation.
 Map getServiceMap(ApplicationContextChild contextChild, ACRequestor requestor, Class serviceClass, Object selector)
          Get a service based on the context, the requesting object, the selector, and the logical service class.
 Map getServiceMap(ApplicationContextChild contextChild, ACRequestor requestor, String serviceName, Object selector)
          Get a service based on the context, the requesting object, the selector, and the logical service name.
 Map getServiceMap(ApplicationContextChild contextChild, Object[] requestors, Class serviceClass, Object selector)
          Get a service based on the context, the requesting object, the selector, and the logical service class.
 Map getServiceMap(ApplicationContextChild contextChild, Object[] requestors, String serviceName, Object selector)
          Get a service based on the context, the requesting object, the selector, and the logical service name.
private  Map getServiceMapImpl(ApplicationContextChild childContext, ACRequestor requestor, String serviceName, Object selector)
           
private  Map getServiceMapImpl(ApplicationContextChild childContext, Object[] requestors, String serviceName, Object selector)
           
 Object[] getServices(ApplicationContextChild contextChild, Object requestor, String serviceName, Object selector)
          Get all available services based on the context, the requesting object, the selector, and the logical service name.
 Enumeration getServiceSelectors(ApplicationContextChild contextChild, String serviceName, Object requestor)
          A service selector is an optional qualifier which can be used to help identify which version of a service is desired.
 Map getServicesMap(ApplicationContextChild contextChild, ACRequestor requestor, String serviceName, Object selector)
          Get all available services based on the context, the requesting object, the selector, and the logical service name.
 Map getServicesMap(ApplicationContextChild contextChild, Object[] requestors, String serviceName, Object selector)
          Get all available services based on the context, the requesting object, the selector, and the logical service name.
 boolean hasService(String serviceName)
          Returns true if there is a mapping from the serviceClass to a service provider.
 void setApplicationContext(ApplicationContext a_ApplicationContext)
          Sets the object for the association that plays role: applicationContext.
 void setPeer(ApplicationContextServices a_Peer)
          Sets the object for the association that plays role: peer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

peer

private ApplicationContextServices peer

applicationContext

private ApplicationContext applicationContext

applicationContextServices

private ApplicationContextServices applicationContextServices

serviceProviders

private com.objectspace.jgl.HashMap serviceProviders
Constructor Detail

ApplicationContextServicesSupport

public ApplicationContextServicesSupport()


Supported API: false


ApplicationContextServicesSupport

public ApplicationContextServicesSupport(ApplicationContextServices peer)


Supported API: false

Parameters:
peer -
Method Detail

getPeer

public ApplicationContextServices getPeer()
Gets the object for the association that plays role: peer.

Supported API: false

Returns:
ApplicationContextServices

setPeer

public void setPeer(ApplicationContextServices a_Peer)
             throws WTPropertyVetoException
Sets the object for the association that plays role: peer.

Supported API: false

Parameters:
a_Peer -
Throws:
WTPropertyVetoException

getApplicationContextServices

public ApplicationContextServices getApplicationContextServices()


Supported API: false

Specified by:
getApplicationContextServices in interface ApplicationContextServices
Returns:
ApplicationContextServices

addService

public boolean addService(String serviceName,
                          ApplicationContextServiceProvider serviceProvider)
Add an entry which maps the serviceClass argument to the serviceProvider object. Return false if the entry already exists.

Supported API: false

Specified by:
addService in interface ApplicationContextServices
Parameters:
serviceName - The logical service which the service provider will manufacture.
serviceProvider - The provider which will manufacture the service.
Returns:
boolean

hasService

public boolean hasService(String serviceName)
Returns true if there is a mapping from the serviceClass to a service provider.

Supported API: false

Specified by:
hasService in interface ApplicationContextServices
Parameters:
serviceName - The logical service class being checked.
Returns:
boolean

addAllServices

public boolean addAllServices(ApplicationContextServiceProvider serviceProvider)
Register all the services which can be supplied by the service provider.

Supported API: false

Specified by:
addAllServices in interface ApplicationContextServices
Parameters:
serviceProvider - The provider which will supply the services.
Returns:
boolean

getService

public Object getService(ApplicationContextChild childContext,
                         Object requestor,
                         String serviceName,
                         Object selector)
                  throws UnableToCreateServiceException,
                         ServiceNotFoundException
Get a service based on the context, the requesting object, the selector, and the logical service name. If the ApplicationContextServiceProvider returns an array of services (Object[]) only the first element of the array is returned.

Supported API: false

Specified by:
getService in interface ApplicationContextServices
Parameters:
childContext -
requestor -
serviceName -
selector -
Returns:
Object
Throws:
UnableToCreateServiceException
ServiceNotFoundException

getService

public Object getService(ApplicationContextChild childContext,
                         Object requestor,
                         Class serviceClass,
                         Object selector)
                  throws UnableToCreateServiceException,
                         ServiceNotFoundException
Get a service based on the context, the requesting object, the selector, and the logical service class. If the ApplicationContextServiceProvider returns an array of services (Object[]) only the first element of the array is returned.

Supported API: false

Specified by:
getService in interface ApplicationContextServices
Parameters:
childContext - The context child requesting the service.
requestor - The object on who's behalf the service is being requested.
serviceClass - The logical service class.
selector -
Returns:
Object
Throws:
UnableToCreateServiceException
ServiceNotFoundException

getServices

public Object[] getServices(ApplicationContextChild contextChild,
                            Object requestor,
                            String serviceName,
                            Object selector)
                     throws UnableToCreateServiceException,
                            ServiceNotFoundException
Get all available services based on the context, the requesting object, the selector, and the logical service name.

Supported API: false

Specified by:
getServices in interface ApplicationContextServices
Parameters:
contextChild - The context child making the service request.
requestor - The target of the service request.
serviceName - The logical name of the service.
selector - An optional selector to further identify the service.
Returns:
Object[]
Throws:
UnableToCreateServiceException
ServiceNotFoundException

getServiceMap

public Map getServiceMap(ApplicationContextChild contextChild,
                         Object[] requestors,
                         String serviceName,
                         Object selector)
                  throws UnableToCreateServiceException,
                         ServiceNotFoundException
Get a service based on the context, the requesting object, the selector, and the logical service name. If the requestor is an instance of Class, it is treated specially: the requestor is treated as an instance of that class, rather than an instance of Class.

Supported API: false

Specified by:
getServiceMap in interface ApplicationContextServices
Parameters:
contextChild - The context child making the service request.
requestors - The target of the service request.
serviceName - The logical name of the service.
selector - An optional selector to further identify the service.
Returns:
Map
Throws:
UnableToCreateServiceException
ServiceNotFoundException

getServiceMap

public Map getServiceMap(ApplicationContextChild contextChild,
                         Object[] requestors,
                         Class serviceClass,
                         Object selector)
                  throws UnableToCreateServiceException,
                         ServiceNotFoundException
Get a service based on the context, the requesting object, the selector, and the logical service class. If the requestor is an instance of Class, it is treated specially: the requestor is treated as an instance of that class, rather than an instance of Class.

Supported API: false

Specified by:
getServiceMap in interface ApplicationContextServices
Parameters:
contextChild -
requestors -
serviceClass -
selector - An optional selector to further identify the service.
Returns:
Map
Throws:
UnableToCreateServiceException
ServiceNotFoundException

getServiceMap

public Map getServiceMap(ApplicationContextChild contextChild,
                         ACRequestor requestor,
                         Class serviceClass,
                         Object selector)
                  throws UnableToCreateServiceException,
                         ServiceNotFoundException
Get a service based on the context, the requesting object, the selector, and the logical service class. If the requestor is an instance of Class, it is treated specially: the requestor is treated as an instance of that class, rather than an instance of Class.

Supported API: false

Specified by:
getServiceMap in interface ApplicationContextServices
Parameters:
contextChild -
requestor -
serviceClass -
selector - An optional selector to further identify the service.
Returns:
Map
Throws:
UnableToCreateServiceException
ServiceNotFoundException

getServiceMap

public Map getServiceMap(ApplicationContextChild contextChild,
                         ACRequestor requestor,
                         String serviceName,
                         Object selector)
                  throws UnableToCreateServiceException,
                         ServiceNotFoundException
Get a service based on the context, the requesting object, the selector, and the logical service name. If the requestor is an instance of Class, it is treated specially: the requestor is treated as an instance of that class, rather than an instance of Class.

Supported API: false

Specified by:
getServiceMap in interface ApplicationContextServices
Parameters:
contextChild - The context child making the service request.
requestor -
serviceName - The logical name of the service.
selector - An optional selector to further identify the service.
Returns:
Map
Throws:
UnableToCreateServiceException
ServiceNotFoundException

getServicesMap

public Map getServicesMap(ApplicationContextChild contextChild,
                          Object[] requestors,
                          String serviceName,
                          Object selector)
                   throws UnableToCreateServiceException,
                          ServiceNotFoundException
Get all available services based on the context, the requesting object, the selector, and the logical service name. If the requestor is an instance of Class, it is treated specially: the requestor is treated as an instance of that class, rather than an instance of Class.

Supported API: false

Specified by:
getServicesMap in interface ApplicationContextServices
Parameters:
contextChild - The context child making the service request.
requestors - The target of the service request.
serviceName - The logical name of the service.
selector - An optional selector to further identify the service.
Returns:
Map
Throws:
UnableToCreateServiceException
ServiceNotFoundException

getServicesMap

public Map getServicesMap(ApplicationContextChild contextChild,
                          ACRequestor requestor,
                          String serviceName,
                          Object selector)
                   throws UnableToCreateServiceException,
                          ServiceNotFoundException
Get all available services based on the context, the requesting object, the selector, and the logical service name. If the requestor is an instance of Class, it is treated specially: the requestor is treated as an instance of that class, rather than an instance of Class.

Supported API: false

Specified by:
getServicesMap in interface ApplicationContextServices
Parameters:
contextChild - The context child making the service request.
requestor -
serviceName - The logical name of the service.
selector - An optional selector to further identify the service.
Returns:
Map
Throws:
UnableToCreateServiceException
ServiceNotFoundException

getServiceImplementationName

public String getServiceImplementationName(ApplicationContextChild childContext,
                                           Object requestor,
                                           String serviceName,
                                           Object selector)
                                    throws ServiceNotFoundException
Get the name of the service implementation. Usually this is the fully qualified class name, but it may be any string (implying that a service can't be instantiated).

Supported API: false

Specified by:
getServiceImplementationName in interface ApplicationContextServices
Parameters:
childContext - The context child for which the service is being requested. May be used to determine which implementation of the service should be returned.
requestor - The requestor or target of the service. Used to determine which implementation of the service should be returned.
serviceName - The logical name of the desired service.
selector -
Returns:
String
Throws:
ServiceNotFoundException

getServiceImplementationNameMap

public Map getServiceImplementationNameMap(ApplicationContextChild childContext,
                                           Object[] requestors,
                                           String serviceName,
                                           Object selector)
                                    throws ServiceNotFoundException
Get the name of the service implementation. Usually this is the fully qualified class name, but it may be any string (implying that a service can't be instantiated).

Supported API: false

Specified by:
getServiceImplementationNameMap in interface ApplicationContextServices
Parameters:
childContext - The context child requesting the service implementation name. May be used to determine which specific service implementation should be provided.
requestors - The requestor or target of the service. Used to help determine which specific service implementation should be provided.
serviceName - The logical name of the service.
selector - An optional selector to further identify the service.
Returns:
Map
Throws:
ServiceNotFoundException

getServiceImplementationNameMap

public Map getServiceImplementationNameMap(ApplicationContextChild childContext,
                                           ACRequestor requestor,
                                           String serviceName,
                                           Object selector)
                                    throws ServiceNotFoundException
Get the name of the service implementation. Usually this is the fully qualified class name, but it may be any string (implying that a service can't be instantiated).

Supported API: false

Specified by:
getServiceImplementationNameMap in interface ApplicationContextServices
Parameters:
childContext - The context child requesting the service implementation name. May be used to determine which specific service implementation should be provided.
requestor -
serviceName - The logical name of the service.
selector - An optional selector to further identify the service.
Returns:
Map
Throws:
ServiceNotFoundException

getServiceSelectors

public Enumeration getServiceSelectors(ApplicationContextChild contextChild,
                                       String serviceName,
                                       Object requestor)
A service selector is an optional qualifier which can be used to help identify which version of a service is desired. An application can determine which selectors are available for a service within a certain context.

Supported API: false

Specified by:
getServiceSelectors in interface ApplicationContextServices
Parameters:
contextChild -
serviceName -
requestor -
Returns:
Enumeration

getServiceImpl

private Object getServiceImpl(ApplicationContextChild childContext,
                              Object requestor,
                              String serviceName,
                              Object selector)
Tries to get the requested service in the current context from the ApplicationContextServiceProvider associated with the requested service. If the service is not available in the current context it will try to get the service in all parent contexts. If this fails it tries to get the service using the WildCardServiceProvider, which is a specific kind of ApplicationContextServiceProvider.

Parameters:
childContext -
requestor -
serviceName -
selector -
Returns:
Object

getApplicationContext

public ApplicationContext getApplicationContext()
Gets the object for the association that plays role: applicationContext.

Supported API: false

Specified by:
getApplicationContext in interface ApplicationContextChild
Returns:
ApplicationContext

setApplicationContext

public void setApplicationContext(ApplicationContext a_ApplicationContext)
                           throws WTPropertyVetoException
Sets the object for the association that plays role: applicationContext.

Supported API: false

Specified by:
setApplicationContext in interface ApplicationContextChild
Parameters:
a_ApplicationContext -
Throws:
WTPropertyVetoException

getServiceMapImpl

private Map getServiceMapImpl(ApplicationContextChild childContext,
                              Object[] requestors,
                              String serviceName,
                              Object selector)

getServiceMapImpl

private Map getServiceMapImpl(ApplicationContextChild childContext,
                              ACRequestor requestor,
                              String serviceName,
                              Object selector)