public class CDIAwareServiceContext extends Object implements ServiceContext
This class implements a ServiceContext
, which basically provides a similar loading mechanism as used
by the ServiceLoader
. Whereas the ServiceLoader
only loads configurations
and instances from one classloader, this loader manages configs found and the related instances for each
classloader along the classloader hierarchies individually. It ensures instances are loaded on the classloader
level, where they first are visible. Additionally it ensures the same configuration resource (and its
declared services) are loaded multiple times, when going up the classloader hierarchy.
Finally classloaders are not stored by reference by this class, to ensure they still can be garbage collected. Refer also the inherited parent class for further details.
This class uses an ordinal of 10
, so it overrides any default ServiceContext
implementations
provided with the Tamaya core modules.
Constructor and Description |
---|
CDIAwareServiceContext() |
Modifier and Type | Method and Description |
---|---|
static int |
getPriority(Object o)
Checks the given instance for a @Priority annotation.
|
<T> T |
getService(Class<T> serviceType)
Access a service singleton via its type.
|
<T> List<T> |
getServices(Class<T> serviceType)
Loads and registers services.
|
int |
ordinal()
Returns ordinal of 20, overriding defaults as well as the inherited (internally used) CLAwareServiceContext
instance.
|
public <T> T getService(Class<T> serviceType)
ServiceContext
Priority
will be used.getService
in interface ServiceContext
T
- the type of the service type.serviceType
- the service type.null
public <T> List<T> getServices(Class<T> serviceType)
getServices
in interface ServiceContext
T
- the concrete type.serviceType
- The service type.null
.public static int getPriority(Object o)
o
- the instance, not null.public int ordinal()
ordinal
in interface ServiceContext
Copyright © 2014–2016 Apache Software Foundation. All rights reserved.