|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.scr.impl.helper.BindMethod
public class BindMethod
Component method to be invoked on service (un)binding.
Nested Class Summary | |
---|---|
static interface |
BindMethod.Service
|
Field Summary | |
---|---|
protected static Class |
BUNDLE_CONTEXT_CLASS
|
protected static Class |
COMPONENT_CONTEXT_CLASS
|
protected static Class |
INTEGER_CLASS
|
protected static Class |
MAP_CLASS
|
protected static Class |
SERVICE_REFERENCE_CLASS
|
Constructor Summary | |
---|---|
BindMethod(AbstractComponentManager componentManager,
String methodName,
Class componentClass,
String referenceName,
String referenceClassName)
|
Method Summary | |
---|---|
protected static boolean |
accept(Method method,
boolean acceptPrivate,
boolean acceptPackage)
Returns true if the method is acceptable to be returned from the
getMethod(Class, String, Class[], boolean, boolean) and also
makes the method accessible. |
protected Method |
doFindMethod(Class targetClass,
boolean acceptPrivate,
boolean acceptPackage)
Finds the method named in the m_methodName field in the given
targetClass . |
protected Class |
getComponentClass()
|
protected AbstractComponentManager |
getComponentManager()
|
Method |
getMethod(Class clazz,
String name,
Class[] parameterTypes,
boolean acceptPrivate,
boolean acceptPackage)
Finds the named public or protected method in the given class or any super class. |
protected String |
getMethodName()
|
protected String |
getMethodNamePrefix()
|
static String |
getPackageName(Class clazz)
Returns the name of the package to which the class belongs or an empty string if the class is in the default package. |
protected Object[] |
getParameters(Method method,
Object rawParameter)
Returns the parameter array created from the rawParameter
using the actual parameter type list of the method . |
boolean |
invoke(Object componentInstance,
Object rawParameter,
boolean methodCallFailureResult)
Calls the declared method on the given component with the provided method call arguments. |
protected boolean |
isDS11()
|
boolean |
methodExists()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Class COMPONENT_CONTEXT_CLASS
protected static final Class BUNDLE_CONTEXT_CLASS
protected static final Class SERVICE_REFERENCE_CLASS
protected static final Class MAP_CLASS
protected static final Class INTEGER_CLASS
Constructor Detail |
---|
public BindMethod(AbstractComponentManager componentManager, String methodName, Class componentClass, String referenceName, String referenceClassName)
Method Detail |
---|
protected Method doFindMethod(Class targetClass, boolean acceptPrivate, boolean acceptPackage) throws SuitableMethodNotAccessibleException, InvocationTargetException
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.
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.
null
if no acceptable method
can be found in the target class or any super class.
InvocationTargetException
- If an unexpected Throwable is caught
trying to find the requested method.
SuitableMethodNotAccessibleException
protected Object[] getParameters(Method method, Object rawParameter)
rawParameter
using the actual parameter type list of the method
.
protected String getMethodNamePrefix()
protected final AbstractComponentManager getComponentManager()
protected final boolean isDS11()
protected final String getMethodName()
protected final Class getComponentClass()
public Method getMethod(Class clazz, String name, Class[] parameterTypes, boolean acceptPrivate, boolean acceptPackage) throws SuitableMethodNotAccessibleException, InvocationTargetException
Method.setAccessible
method if required and
the method is returned. Enforcing accessibility is required to support
invocation of protected methods.
clazz
- The Class
which provides the method.name
- The name of the method.parameterTypes
- The parameters to the method. Passing
null
is equivalent to using an empty array.
null
if no such method exists in the class.
SuitableMethodNotAccessibleException
- If method with the given
name taking the parameters is found in the class but the method
is not accessible.
InvocationTargetException
- If an unexpected Throwable is caught
trying to access the desired method.protected static boolean accept(Method method, boolean acceptPrivate, boolean acceptPackage)
true
if the method is acceptable to be returned from the
getMethod(Class, String, Class[], boolean, boolean)
and also
makes the method accessible.
This method returns true
iff:
void
return typeacceptPrivate
is true
acceptPackage
is true
This method is package private for unit testing purposes. It is not meant to be called from client code.
method
- The method to checkacceptPrivate
- Whether a private method is acceptableacceptPackage
- Whether a package private method is acceptable
public static String getPackageName(Class clazz)
public boolean invoke(Object componentInstance, Object rawParameter, boolean methodCallFailureResult)
componentInstance
- The component instance on which to call the
methodrawParameter
- The parameter container providing the actual
parameters to provide to the called methodmethodCallFailureResult
- The result to return from this method if
calling the method resulted in an exception.
true
if the method was called successfully or the
method was not found and was not required. false
if
the method was not found but required.
methodCallFailureResult
is returned if the method was
found and called, but the method threw an exception.public boolean methodExists()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |