Class BindMethod

    • Constructor Summary

      Constructors 
      Constructor Description
      BindMethod​(java.lang.String methodName, java.lang.Class<?> componentClass, java.lang.String referenceClassName, DSVersion dsVersion, boolean configurableServiceProperties)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected BaseMethod.MethodInfo<java.util.List<ValueUtils.ValueType>> doFindMethod​(java.lang.Class<?> targetClass, boolean acceptPrivate, boolean acceptPackage, ComponentLogger 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, ComponentLogger logger)  
      private java.lang.reflect.Method getMapMethod​(java.lang.Class<?> targetClass, java.lang.Class<?> parameterClass, boolean acceptPrivate, boolean acceptPackage, ComponentLogger 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​(BindParameters parameters, org.osgi.framework.BundleContext context)  
      private java.lang.reflect.Method getServiceObjectAssignableMethod​(java.lang.Class<?> targetClass, java.lang.Class<?> parameterClass, boolean acceptPrivate, boolean acceptPackage, ComponentLogger 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, ComponentLogger 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, ComponentLogger 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, ComponentLogger logger)
      Returns a method taking a single ServiceReference object as a parameter or null if no such method exists.
      protected void setTypes​(java.util.List<ValueUtils.ValueType> types)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • m_referenceClassName

        private final java.lang.String m_referenceClassName
    • Constructor Detail

      • BindMethod

        public BindMethod​(java.lang.String methodName,
                          java.lang.Class<?> componentClass,
                          java.lang.String referenceClassName,
                          DSVersion dsVersion,
                          boolean configurableServiceProperties)
    • Method Detail

      • doFindMethod

        protected BaseMethod.MethodInfo<java.util.List<ValueUtils.ValueType>> doFindMethod​(java.lang.Class<?> targetClass,
                                                                                           boolean acceptPrivate,
                                                                                           boolean acceptPackage,
                                                                                           ComponentLogger logger)
                                                                                    throws SuitableMethodNotAccessibleException,
                                                                                           java.lang.reflect.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,​java.util.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:
        java.lang.reflect.InvocationTargetException - If an unexpected Throwable is caught trying to find the requested method.
        SuitableMethodNotAccessibleException
      • getServiceReferenceMethod

        private java.lang.reflect.Method getServiceReferenceMethod​(java.lang.Class<?> targetClass,
                                                                   boolean acceptPrivate,
                                                                   boolean acceptPackage,
                                                                   ComponentLogger logger)
                                                            throws SuitableMethodNotAccessibleException,
                                                                   java.lang.reflect.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
        java.lang.reflect.InvocationTargetException - If an unexpected Throwable is caught trying to find the requested method.
      • getServiceObjectMethod

        private java.lang.reflect.Method getServiceObjectMethod​(java.lang.Class<?> targetClass,
                                                                java.lang.Class<?> parameterClass,
                                                                boolean acceptPrivate,
                                                                boolean acceptPackage,
                                                                ComponentLogger logger)
                                                         throws SuitableMethodNotAccessibleException,
                                                                java.lang.reflect.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
        java.lang.reflect.InvocationTargetException - If an unexpected Throwable is caught trying to find the requested method.
      • getServiceObjectAssignableMethod

        private java.lang.reflect.Method getServiceObjectAssignableMethod​(java.lang.Class<?> targetClass,
                                                                          java.lang.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 java.lang.reflect.Method getServiceObjectWithMapMethod​(java.lang.Class<?> targetClass,
                                                                       java.lang.Class<?> parameterClass,
                                                                       boolean acceptPrivate,
                                                                       boolean acceptPackage,
                                                                       ComponentLogger logger)
                                                                throws SuitableMethodNotAccessibleException,
                                                                       java.lang.reflect.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
        java.lang.reflect.InvocationTargetException - If an unexpected Throwable is caught trying to find the requested method.
      • getServiceObjectAssignableWithMapMethod

        private java.lang.reflect.Method getServiceObjectAssignableWithMapMethod​(java.lang.Class<?> targetClass,
                                                                                 java.lang.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 java.lang.reflect.Method getMapMethod​(java.lang.Class<?> targetClass,
                                                      java.lang.Class<?> parameterClass,
                                                      boolean acceptPrivate,
                                                      boolean acceptPackage,
                                                      ComponentLogger logger)
                                               throws SuitableMethodNotAccessibleException,
                                                      java.lang.reflect.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
        java.lang.reflect.InvocationTargetException - If an unexpected Throwable is caught trying to find the requested method.