Class BindMethod

All Implemented Interfaces:
ReferenceMethod
Direct Known Subclasses:
UnbindMethod, UpdatedMethod

public class BindMethod extends BaseMethod<BindParameters,List<ValueUtils.ValueType>> implements ReferenceMethod
Component method to be invoked on service (un)binding.
  • Field Details

  • Constructor Details

    • BindMethod

      public BindMethod(String methodName, Class<?> componentClass, String referenceClassName, DSVersion dsVersion, boolean configurableServiceProperties)
  • Method Details

    • doFindMethod

      protected BaseMethod.MethodInfo<List<ValueUtils.ValueType>> doFindMethod(Class<?> targetClass, boolean acceptPrivate, boolean acceptPackage, ComponentLogger logger) throws SuitableMethodNotAccessibleException, InvocationTargetException
      Finds the method named in the 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.
      Specified by:
      doFindMethod in class BaseMethod<BindParameters,List<ValueUtils.ValueType>>
      Parameters:
      targetClass - The class in which to look for the method
      acceptPrivate - true if private methods should be considered.
      acceptPackage - true if package private methods should be considered.
      logger -
      Returns:
      The requested method or null if no acceptable method can be found in the target class or any super class.
      Throws:
      InvocationTargetException - If an unexpected Throwable is caught trying to find the requested method.
      SuitableMethodNotAccessibleException
    • setTypes

      protected void setTypes(List<ValueUtils.ValueType> types)
      Specified by:
      setTypes in class BaseMethod<BindParameters,List<ValueUtils.ValueType>>
    • getServiceReferenceMethod

      private Method getServiceReferenceMethod(Class<?> targetClass, boolean acceptPrivate, boolean acceptPackage, ComponentLogger logger) throws SuitableMethodNotAccessibleException, InvocationTargetException
      Returns a method taking a single ServiceReference object as a parameter or null if no such method exists.
      Parameters:
      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 -
      Returns:
      The requested method or null if no acceptable method can be found in the target class.
      Throws:
      SuitableMethodNotAccessibleException - If a suitable method was found which is not accessible
      InvocationTargetException - If an unexpected Throwable is caught trying to find the requested method.
    • getComponentObjectsMethod

      private Method getComponentObjectsMethod(Class<?> targetClass, boolean acceptPrivate, boolean acceptPackage, ComponentLogger logger) throws SuitableMethodNotAccessibleException, InvocationTargetException
      Throws:
      SuitableMethodNotAccessibleException
      InvocationTargetException
    • getServiceObjectMethod

      private Method getServiceObjectMethod(Class<?> targetClass, Class<?> parameterClass, boolean acceptPrivate, boolean acceptPackage, ComponentLogger logger) throws SuitableMethodNotAccessibleException, InvocationTargetException
      Returns a method taking a single parameter of the exact type declared for the service reference or null if no such method exists.
      Parameters:
      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 -
      Returns:
      The requested method or null if no acceptable method can be found in the target class.
      Throws:
      SuitableMethodNotAccessibleException - If a suitable method was found which is not accessible
      InvocationTargetException - If an unexpected Throwable is caught trying to find the requested method.
    • getServiceObjectAssignableMethod

      private Method getServiceObjectAssignableMethod(Class<?> targetClass, Class<?> parameterClass, boolean acceptPrivate, boolean acceptPackage, ComponentLogger logger) throws SuitableMethodNotAccessibleException
      Returns a method taking a single object whose type is assignment compatible with the declared service type or null if no such method exists.
      Parameters:
      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 -
      Returns:
      The requested method or null if no acceptable method can be found in the target class.
      Throws:
      SuitableMethodNotAccessibleException - If a suitable method was found which is not accessible
    • getServiceObjectWithMapMethod

      private Method getServiceObjectWithMapMethod(Class<?> targetClass, Class<?> parameterClass, boolean acceptPrivate, boolean acceptPackage, ComponentLogger logger) throws SuitableMethodNotAccessibleException, InvocationTargetException
      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.
      Parameters:
      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 -
      Returns:
      The requested method or null if no acceptable method can be found in the target class.
      Throws:
      SuitableMethodNotAccessibleException - If a suitable method was found which is not accessible
      InvocationTargetException - If an unexpected Throwable is caught trying to find the requested method.
    • getServiceObjectAssignableWithMapMethod

      private Method getServiceObjectAssignableWithMapMethod(Class<?> targetClass, Class<?> parameterClass, boolean acceptPrivate, boolean acceptPackage) throws SuitableMethodNotAccessibleException
      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.
      Parameters:
      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.
      Returns:
      The requested method or null if no acceptable method can be found in the target class.
      Throws:
      SuitableMethodNotAccessibleException - If a suitable method was found which is not accessible
    • getMapMethod

      private Method getMapMethod(Class<?> targetClass, Class<?> parameterClass, boolean acceptPrivate, boolean acceptPackage, ComponentLogger logger) throws SuitableMethodNotAccessibleException, InvocationTargetException
      Returns a method taking a single map parameter or null if no such method exists.
      Parameters:
      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 -
      Returns:
      The requested method or null if no acceptable method can be found in the target class.
      Throws:
      SuitableMethodNotAccessibleException - If a suitable method was found which is not accessible
      InvocationTargetException - If an unexpected Throwable is caught trying to find the requested method.
    • getServiceObject

      public <S, T> boolean getServiceObject(BindParameters parameters, org.osgi.framework.BundleContext context)
      Specified by:
      getServiceObject in interface ReferenceMethod
    • getParameters

      protected Object[] getParameters(Method method, BindParameters bp)
      Description copied from class: BaseMethod
      Returns the parameter array created from the rawParameter using the actual parameter type list of the method.
      Specified by:
      getParameters in class BaseMethod<BindParameters,List<ValueUtils.ValueType>>
      Returns:
    • getMethodNamePrefix

      protected String getMethodNamePrefix()
      Overrides:
      getMethodNamePrefix in class BaseMethod<BindParameters,List<ValueUtils.ValueType>>