Interface Registry

  • All Known Implementing Classes:
    DefaultRegistry

    public interface Registry
    Holds system and user objects such as ResourceConfig and ContentHandler.

    A registry is bound to the application context. It allows Smooks to discover and reference registered objects during a filter execution. Clients should call deRegisterObject(Object) to remove a registered object once it is no longer needed.

    • Method Detail

      • registerObject

        void registerObject​(Object value)
        Registers an object with its key derived from the object's Resource.name() attribute or the object's class name.
        Parameters:
        value - object to register
        Throws:
        SmooksException - if the value with the assigned name already exists
        IllegalArgumentException - if the value is null
      • registerObject

        void registerObject​(Object key,
                            Object value)
        Adds an object with the given key to this Registry.
        Parameters:
        key - object that maps to the value to register
        value - object to register which can be retrieved by its key
        Throws:
        SmooksException - if the value with the assigned name already exists
        IllegalArgumentException - if the name or the value is null
      • deRegisterObject

        void deRegisterObject​(Object key)
        Removes a registered object from this Registry.
        Parameters:
        key - key of the registered object to remove
      • lookup

        <R> R lookup​(Function<Map<Object,​Object>,​R> function)
        Looks up a registered object by function.
        Type Parameters:
        R - type of object to be returned
        Parameters:
        function - function to apply for looking up an object
        Returns:
        registered object if it exists or null
      • lookup

        <T> T lookup​(Object key)
        Looks up a registered object by its key.
        Type Parameters:
        T - type of object to be returned
        Parameters:
        key - key of registered object
        Returns:
        the registered object if it exists or null
      • lookup

        <T> T lookup​(TypedKey<T> key)
        Looks up a registered object by its typed key.
        Type Parameters:
        T - type of object to be returned
        Parameters:
        key - typed key of registered object
        Returns:
        the registered object if it exists or null
      • close

        void close()
        Cleans up the resources of this Registry and calls the PreDestroy method of each registered object.
      • getClassLoader

        ClassLoader getClassLoader()
        Returns:
        the class loader of this Registry