Class AbstractResourceServices
java.lang.Object
org.jboss.weld.injection.spi.helpers.AbstractResourceServices
- All Implemented Interfaces:
Service,ResourceInjectionServices
public abstract class AbstractResourceServices
extends Object
implements Service, ResourceInjectionServices
Abstract subclass for
ResourceInjectionServices defining several common capabilities.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()Called by Weld when it is shutting down, allowing the service to perform any cleanup needed.protected abstract ContextReturns theContextinstance.static StringgetPropertyName(Method method) Returns property name as aStringextracted from given method by looking at its name and stripping its prefix.protected jakarta.annotation.ResourcegetResourceAnnotation(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint) Parses theResourceannotation from givenInjectionPoint.protected StringgetResourceName(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint) Retrieves theResourceannotation from providedInjectionPointand extracts resource name from it.protected StringgetResourceName(String jndiName, String mappedName) Returns aStringrepresentation of the resource name from provided parameters.registerResourceInjectionPoint(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint) Register a resource injection point.registerResourceInjectionPoint(String jndiName, String mappedName) Register a resource injection point with the given JNDI name and mapped name.resolveResource(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint) Verifies that providedInjectionPointhasResourceannotation on it, extracts resource name from it and then invokesContext.lookup(String).resolveResource(String jndiName, String mappedName) Uses provided parameters to look up the resource viaContext.lookup(String)
-
Constructor Details
-
AbstractResourceServices
public AbstractResourceServices()
-
-
Method Details
-
resolveResource
Verifies that providedInjectionPointhasResourceannotation on it, extracts resource name from it and then invokesContext.lookup(String).- Parameters:
injectionPoint- injection points to inspect- Returns:
- resource
-
resolveResource
Uses provided parameters to look up the resource viaContext.lookup(String)- Parameters:
jndiName- jndi name of the resource, may benullmappedName- mappedName of the resource, may benull- Returns:
- looked up resource
-
getResourceName
Returns aStringrepresentation of the resource name from provided parameters.mappedNametakes precedence overjndiNameunless it isnull. ThrowsIllegalArgumentExceptionif both parameters arenull.- Parameters:
jndiName- jndiName or nullmappedName- mappedName or null- Returns:
Stringrepresentation of the resource name
-
getContext
Returns theContextinstance.- Returns:
Contextinstance
-
getResourceName
Retrieves theResourceannotation from providedInjectionPointand extracts resource name from it.- Parameters:
injectionPoint- injection point to inspect- Returns:
Stringrepresentation of resource name
-
getPropertyName
Returns property name as aStringextracted from given method by looking at its name and stripping its prefix. May returnnullif the method name does not start with set/get/is prefix.- Parameters:
method- method to parse property name from- Returns:
- property name or null if the name cannot be parsed
-
registerResourceInjectionPoint
public ResourceReferenceFactory<Object> registerResourceInjectionPoint(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint) Description copied from interface:ResourceInjectionServicesRegister a resource injection point. The implementation validates the injection point. If the validation passes, an instance ofResourceReferenceFactoryis returned which may be used at runtime for creating instances of the resource.- Specified by:
registerResourceInjectionPointin interfaceResourceInjectionServices- Parameters:
injectionPoint- the injection point metadata- Returns:
- resource factory
-
registerResourceInjectionPoint
public ResourceReferenceFactory<Object> registerResourceInjectionPoint(String jndiName, String mappedName) Description copied from interface:ResourceInjectionServicesRegister a resource injection point with the given JNDI name and mapped name. The implementation validates the injection point. If the validation passes, an instance ofResourceReferenceFactoryis returned which may be used at runtime for creating instances of the resource.- Specified by:
registerResourceInjectionPointin interfaceResourceInjectionServices- Parameters:
jndiName- JNDI namemappedName- mapped name- Returns:
- resource factory
-
getResourceAnnotation
protected jakarta.annotation.Resource getResourceAnnotation(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint) Parses theResourceannotation from givenInjectionPoint.- Parameters:
injectionPoint- Injection point to parse the annotation from- Returns:
- Instance of
Resourceannotation if present, null otherwise
-
cleanup
public void cleanup()Description copied from interface:ServiceCalled by Weld when it is shutting down, allowing the service to perform any cleanup needed.
-