Class ComponentProvider

  • Direct Known Subclasses:
    CdiComponentProvider, DefaultComponentProvider, EjbComponentProvider

    public abstract class ComponentProvider
    extends java.lang.Object
    Provides an instance.

    Method isApplicable(Class) is called first to check whether the provider is able to provide the given Class. Method create(Class) is called to get the instance.

    Author:
    Stepan Kopriva (stepan.kopriva at oracle.com), Martin Matula (martin.matula at oracle.com), Pavel Bucek (pavel.bucek at oracle.com)
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract <T> java.lang.Object create​(java.lang.Class<T> c)
      Create new instance.
      abstract boolean destroy​(java.lang.Object o)
      Destroys the given managed instance.
      java.lang.reflect.Method getInvocableMethod​(java.lang.reflect.Method method)
      Get the method which should be invoked instead provided one.
      abstract boolean isApplicable​(java.lang.Class<?> c)
      Checks whether this component provider is able to provide an instance of given Class.
      • Methods inherited from class java.lang.Object

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

      • ComponentProvider

        public ComponentProvider()
    • Method Detail

      • isApplicable

        public abstract boolean isApplicable​(java.lang.Class<?> c)
        Checks whether this component provider is able to provide an instance of given Class.
        Parameters:
        c - Class to be checked.
        Returns:
        true iff this ComponentProvider is able to create an instance of the given Class.
      • create

        public abstract <T> java.lang.Object create​(java.lang.Class<T> c)
        Create new instance.
        Type Parameters:
        T - type of the created object.
        Parameters:
        c - Class to be created.
        Returns:
        instance, iff found, null otherwise.
      • getInvocableMethod

        public java.lang.reflect.Method getInvocableMethod​(java.lang.reflect.Method method)
        Get the method which should be invoked instead provided one.

        Useful mainly for EJB container support, where methods from endpoint class cannot be invoked directly - Tyrus needs to use method declared on remote interface.

        Default implementation returns method provided as parameter.

        Parameters:
        method - method from endpoint class.
        Returns:
        method which should be invoked.
      • destroy

        public abstract boolean destroy​(java.lang.Object o)
        Destroys the given managed instance.
        Parameters:
        o - instance to be destroyed.
        Returns:
        true iff the instance was coupled to this ComponentProvider, false otherwise.