public class BindMethod extends BaseMethod<BindParameters,java.util.List<BindMethod.ParamType>> implements ReferenceMethod
Modifier and Type | Class and Description |
---|---|
(package private) static class |
BindMethod.ParamType |
BaseMethod.MethodInfo<T>
Modifier and Type | Field and Description |
---|---|
private java.util.List<BindMethod.ParamType> |
m_paramTypes |
private java.lang.String |
m_referenceClassName |
Constructor and Description |
---|
BindMethod(java.lang.String methodName,
java.lang.Class<?> componentClass,
java.lang.String referenceClassName,
DSVersion dsVersion,
boolean configurableServiceProperties) |
Modifier and Type | Method and Description |
---|---|
protected BaseMethod.MethodInfo<java.util.List<BindMethod.ParamType>> |
doFindMethod(java.lang.Class<?> targetClass,
boolean acceptPrivate,
boolean acceptPackage,
SimpleLogger logger)
Finds the method named in the
BaseMethod.m_methodName field in the given
targetClass . |
private java.lang.reflect.Method |
getComponentObjectsMethod(java.lang.Class<?> targetClass,
boolean acceptPrivate,
boolean acceptPackage,
SimpleLogger logger) |
private java.lang.reflect.Method |
getMapMethod(java.lang.Class<?> targetClass,
java.lang.Class<?> parameterClass,
boolean acceptPrivate,
boolean acceptPackage,
SimpleLogger logger)
Returns a method taking a single map parameter
or
null if no such method exists. |
protected java.lang.String |
getMethodNamePrefix() |
protected java.lang.Object[] |
getParameters(java.lang.reflect.Method method,
BindParameters bp)
Returns the parameter array created from the
rawParameter
using the actual parameter type list of the method . |
<S,T> boolean |
getServiceObject(ComponentContextImpl<S> key,
RefPair<S,T> refPair,
org.osgi.framework.BundleContext context,
SimpleLogger logger) |
private java.lang.reflect.Method |
getServiceObjectAssignableMethod(java.lang.Class<?> targetClass,
java.lang.Class<?> parameterClass,
boolean acceptPrivate,
boolean acceptPackage,
SimpleLogger logger)
Returns a method taking a single object whose type is assignment
compatible with the declared service type or
null if no
such method exists. |
private java.lang.reflect.Method |
getServiceObjectAssignableWithMapMethod(java.lang.Class<?> targetClass,
java.lang.Class<?> parameterClass,
boolean acceptPrivate,
boolean acceptPackage)
Returns a method taking two parameters, the first being an object
whose type is assignment compatible with the declared service type and
the second being a
Map or null if no such
method exists. |
private java.lang.reflect.Method |
getServiceObjectMethod(java.lang.Class<?> targetClass,
java.lang.Class<?> parameterClass,
boolean acceptPrivate,
boolean acceptPackage,
SimpleLogger logger)
Returns a method taking a single parameter of the exact type declared
for the service reference or
null if no such method exists. |
private java.lang.reflect.Method |
getServiceObjectWithMapMethod(java.lang.Class<?> targetClass,
java.lang.Class<?> parameterClass,
boolean acceptPrivate,
boolean acceptPackage,
SimpleLogger logger)
Returns a method taking two parameters, the first being of the exact
type declared for the service reference and the second being a
Map or null if no such method exists. |
private java.lang.reflect.Method |
getServiceReferenceMethod(java.lang.Class<?> targetClass,
boolean acceptPrivate,
boolean acceptPackage,
SimpleLogger logger)
Returns a method taking a single
ServiceReference object
as a parameter or null if no such method exists. |
MethodResult |
invoke(java.lang.Object componentInstance,
ComponentContextImpl<?> componentContext,
RefPair<?,?> refPair,
MethodResult methodCallFailureResult,
SimpleLogger logger) |
protected void |
setTypes(java.util.List<BindMethod.ParamType> types) |
accept, getComponentClass, getDSVersion, getMethod, getMethod, getMethodName, getPackageName, getState, invoke, isDS12Felix, methodExists, returnValue, setMethod
private final java.lang.String m_referenceClassName
private volatile java.util.List<BindMethod.ParamType> m_paramTypes
public BindMethod(java.lang.String methodName, java.lang.Class<?> componentClass, java.lang.String referenceClassName, DSVersion dsVersion, boolean configurableServiceProperties)
protected BaseMethod.MethodInfo<java.util.List<BindMethod.ParamType>> doFindMethod(java.lang.Class<?> targetClass, boolean acceptPrivate, boolean acceptPackage, SimpleLogger logger) throws SuitableMethodNotAccessibleException, java.lang.reflect.InvocationTargetException
BaseMethod.m_methodName
field in the given
targetClass
. If the target class has no acceptable method
the class hierarchy is traversed until a method is found or the root
of the class hierarchy is reached without finding a method.doFindMethod
in class BaseMethod<BindParameters,java.util.List<BindMethod.ParamType>>
targetClass
- The class in which to look for the methodacceptPrivate
- true
if private methods should be
considered.acceptPackage
- true
if package private methods should
be considered.logger
- null
if no acceptable method
can be found in the target class or any super class.java.lang.reflect.InvocationTargetException
- If an unexpected Throwable is caught
trying to find the requested method.SuitableMethodNotAccessibleException
protected void setTypes(java.util.List<BindMethod.ParamType> types)
setTypes
in class BaseMethod<BindParameters,java.util.List<BindMethod.ParamType>>
private java.lang.reflect.Method getServiceReferenceMethod(java.lang.Class<?> targetClass, boolean acceptPrivate, boolean acceptPackage, SimpleLogger logger) throws SuitableMethodNotAccessibleException, java.lang.reflect.InvocationTargetException
ServiceReference
object
as a parameter or null
if no such method exists.targetClass
- The class in which to look for the method. Only this
class is searched for the method.acceptPrivate
- true
if private methods should be
considered.acceptPackage
- true
if package private methods should
be considered.logger
- null
if no acceptable method
can be found in the target class.SuitableMethodNotAccessibleException
- If a suitable method was
found which is not accessiblejava.lang.reflect.InvocationTargetException
- If an unexpected Throwable is caught
trying to find the requested method.private java.lang.reflect.Method getComponentObjectsMethod(java.lang.Class<?> targetClass, boolean acceptPrivate, boolean acceptPackage, SimpleLogger logger) throws SuitableMethodNotAccessibleException, java.lang.reflect.InvocationTargetException
SuitableMethodNotAccessibleException
java.lang.reflect.InvocationTargetException
private java.lang.reflect.Method getServiceObjectMethod(java.lang.Class<?> targetClass, java.lang.Class<?> parameterClass, boolean acceptPrivate, boolean acceptPackage, SimpleLogger logger) throws SuitableMethodNotAccessibleException, java.lang.reflect.InvocationTargetException
null
if no such method exists.targetClass
- The class in which to look for the method. Only this
class is searched for the method.acceptPrivate
- true
if private methods should be
considered.acceptPackage
- true
if package private methods should
be considered.logger
- null
if no acceptable method
can be found in the target class.SuitableMethodNotAccessibleException
- If a suitable method was
found which is not accessiblejava.lang.reflect.InvocationTargetException
- If an unexpected Throwable is caught
trying to find the requested method.private java.lang.reflect.Method getServiceObjectAssignableMethod(java.lang.Class<?> targetClass, java.lang.Class<?> parameterClass, boolean acceptPrivate, boolean acceptPackage, SimpleLogger logger) throws SuitableMethodNotAccessibleException
null
if no
such method exists.targetClass
- The class in which to look for the method. Only this
class is searched for the method.acceptPrivate
- true
if private methods should be
considered.acceptPackage
- true
if package private methods should
be considered.logger
- null
if no acceptable method
can be found in the target class.SuitableMethodNotAccessibleException
- If a suitable method was
found which is not accessibleprivate java.lang.reflect.Method getServiceObjectWithMapMethod(java.lang.Class<?> targetClass, java.lang.Class<?> parameterClass, boolean acceptPrivate, boolean acceptPackage, SimpleLogger logger) throws SuitableMethodNotAccessibleException, java.lang.reflect.InvocationTargetException
Map
or null
if no such method exists.targetClass
- The class in which to look for the method. Only this
class is searched for the method.acceptPrivate
- true
if private methods should be
considered.acceptPackage
- true
if package private methods should
be considered.logger
- null
if no acceptable method
can be found in the target class.SuitableMethodNotAccessibleException
- If a suitable method was
found which is not accessiblejava.lang.reflect.InvocationTargetException
- If an unexpected Throwable is caught
trying to find the requested method.private java.lang.reflect.Method getServiceObjectAssignableWithMapMethod(java.lang.Class<?> targetClass, java.lang.Class<?> parameterClass, boolean acceptPrivate, boolean acceptPackage) throws SuitableMethodNotAccessibleException
Map
or null
if no such
method exists.targetClass
- The class in which to look for the method. Only this
class is searched for the method.acceptPrivate
- true
if private methods should be
considered.acceptPackage
- true
if package private methods should
be considered.null
if no acceptable method
can be found in the target class.SuitableMethodNotAccessibleException
- If a suitable method was
found which is not accessibleprivate java.lang.reflect.Method getMapMethod(java.lang.Class<?> targetClass, java.lang.Class<?> parameterClass, boolean acceptPrivate, boolean acceptPackage, SimpleLogger logger) throws SuitableMethodNotAccessibleException, java.lang.reflect.InvocationTargetException
null
if no such method exists.targetClass
- The class in which to look for the method. Only this
class is searched for the method.acceptPrivate
- true
if private methods should be
considered.acceptPackage
- true
if package private methods should
be considered.logger
- null
if no acceptable method
can be found in the target class.SuitableMethodNotAccessibleException
- If a suitable method was
found which is not accessiblejava.lang.reflect.InvocationTargetException
- If an unexpected Throwable is caught
trying to find the requested method.public <S,T> boolean getServiceObject(ComponentContextImpl<S> key, RefPair<S,T> refPair, org.osgi.framework.BundleContext context, SimpleLogger logger)
getServiceObject
in interface ReferenceMethod
public MethodResult invoke(java.lang.Object componentInstance, ComponentContextImpl<?> componentContext, RefPair<?,?> refPair, MethodResult methodCallFailureResult, SimpleLogger logger)
invoke
in interface ReferenceMethod
protected java.lang.Object[] getParameters(java.lang.reflect.Method method, BindParameters bp)
BaseMethod
rawParameter
using the actual parameter type list of the method
.getParameters
in class BaseMethod<BindParameters,java.util.List<BindMethod.ParamType>>
protected java.lang.String getMethodNamePrefix()
getMethodNamePrefix
in class BaseMethod<BindParameters,java.util.List<BindMethod.ParamType>>