## org.apache.commons.jelly.impl
Class DefaultTagLibraryResolver

    java.lang.Object
      org.apache.commons.jelly.impl.DefaultTagLibraryResolver

All Implemented Interfaces:
  TagLibraryResolver

    public class DefaultTagLibraryResolver

extends java.lang.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 Summary
`DefaultTagLibraryResolver()`

Method Summary
`java.lang.ClassLoader` `getClassLoader()` Return the class loader to be used for instantiating application objects when required.
`org.apache.commons.discovery.resource.classes.DiscoverClasses` `getDiscoverClasses()`
`boolean` `getUseContextClassLoader()` Return the boolean as to whether the context classloader should be used.
`protected TagLibrary` `loadClass(java.lang.String uri, java.lang.String className)` Instantiates the given class name.
`protected TagLibrary` `newInstance(java.lang.String uri, java.lang.Class theClass)` Creates a new instance of the given TagLibrary class or return null if it could not be instantiated.
`TagLibrary` `resolveTagLibrary(java.lang.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.
`void` `setClassLoader(java.lang.ClassLoader classLoader)` Set the class loader to be used for instantiating application objects when required.
`void` `setDiscoverClasses(org.apache.commons.discovery.resource.classes.DiscoverClasses discovery)` Sets the fully configured DiscoverClasses instance to be used to lookup services
`void` `setUseContextClassLoader(boolean use)` Determine whether to use the Context ClassLoader (the one found by calling `Thread.currentThread().getContextClassLoader()`) to resolve/load classes.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DefaultTagLibraryResolver

    public DefaultTagLibraryResolver()

Method Detail

### resolveTagLibrary

    public TagLibrary resolveTagLibrary(java.lang.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 java.lang.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(java.lang.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:
    `boolean` - 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(java.lang.String uri,
                                   java.lang.String className)

  Instantiates the given class name. Otherwise an exception is logged and null is returned

### newInstance

    protected TagLibrary newInstance(java.lang.String uri,
                                     java.lang.Class theClass)

  Creates a new instance of the given TagLibrary class or return null if it could not be instantiated.

Copyright © 2002-2005 Apache Software Foundation. All Rights Reserved.