Class DefaultTagLibraryResolver

  • All Implemented Interfaces:
    TagLibraryResolver

    public class DefaultTagLibraryResolver
    extends Object
    implements TagLibraryResolver

    DefaultTagLibraryResolver is a default implemenation which attempts to interpret the URI as a String called 'jelly:className' and class load the given Java class. Otherwise META-INF/services/jelly/uri is searched for on the thread context's class path and, if found, that class will be loaded.

    Version:
    $Revision: 155420 $
    Author:
    James Strachan
    • Constructor Detail

      • DefaultTagLibraryResolver

        public DefaultTagLibraryResolver()
    • Method Detail

      • resolveTagLibrary

        public TagLibrary resolveTagLibrary​(String uri)
        Attempts to resolve the given URI to be associated with a TagLibrary otherwise null is returned to indicate no tag library could be found so that the namespace URI should be treated as just vanilla XML.
        Specified by:
        resolveTagLibrary in interface TagLibraryResolver
      • getClassLoader

        public ClassLoader getClassLoader()
        Return the class loader to be used for instantiating application objects when required. This is determined based upon the following rules:
        • The class loader set by setClassLoader(), if any
        • The thread context class loader, if it exists and the useContextClassLoader property is set to true
        • The class loader used to load the XMLParser class itself.
      • setClassLoader

        public void setClassLoader​(ClassLoader classLoader)
        Set the class loader to be used for instantiating application objects when required.
        Parameters:
        classLoader - The new class loader to use, or null to revert to the standard rules
      • getUseContextClassLoader

        public boolean getUseContextClassLoader()
        Return the boolean as to whether the context classloader should be used.
      • setUseContextClassLoader

        public void setUseContextClassLoader​(boolean use)
        Determine whether to use the Context ClassLoader (the one found by calling Thread.currentThread().getContextClassLoader()) to resolve/load classes. If not using Context ClassLoader, then the class-loading defaults to using the calling-class' ClassLoader.
        Parameters:
        use - determines whether to use JellyContext ClassLoader.
      • getDiscoverClasses

        public org.apache.commons.discovery.resource.classes.DiscoverClasses getDiscoverClasses()
        Returns:
        the DiscoverClasses instance to use to locate services. This object is lazily created if it has not been configured.
      • setDiscoverClasses

        public void setDiscoverClasses​(org.apache.commons.discovery.resource.classes.DiscoverClasses discovery)
        Sets the fully configured DiscoverClasses instance to be used to lookup services
      • loadClass

        protected TagLibrary loadClass​(String uri,
                                       String className)
        Instantiates the given class name. Otherwise an exception is logged and null is returned
      • newInstance

        protected TagLibrary newInstance​(String uri,
                                         Class theClass)
        Creates a new instance of the given TagLibrary class or return null if it could not be instantiated.