org.peaseplate.internal.service
Class DefaultResolverService

java.lang.Object
  extended by org.peaseplate.internal.service.DefaultResolverService
All Implemented Interfaces:
ResolverService

public class DefaultResolverService
extends java.lang.Object
implements ResolverService

The default implementation of the ResolverService.

Author:
Manfred Hantschel

Constructor Summary
DefaultResolverService()
           
 
Method Summary
 void add(java.lang.Class<? extends Resolver> resolverClass)
          Adds the resolver to the service.
 void add(java.lang.ClassLoader... classLoaders)
          Scans the specified class loaders for resolver service definitions.
 void add(Resolver resolver)
          Add the sepcified resolver to the service.
 MessagesLocator getMessages(TemplateEngine engine, ResourceKey key)
          Asks all resolvers for a messages object described by the specified key and returns a locator for the messages if found.
 TemplateLocator getTemplate(TemplateEngine engine, ResourceKey key)
          Asks all resolvers for a template described by the specified key and returns a locator for the template if found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultResolverService

public DefaultResolverService()
Method Detail

add

public void add(java.lang.ClassLoader... classLoaders)
         throws java.lang.IllegalArgumentException
Description copied from interface: ResolverService
Scans the specified class loaders for resolver service definitions. The definitions are located in a resource with the name "META-INF/services/org.peaseplate.service.ResolverService". The file contains class names of Resolvers, one class name per line.

Specified by:
add in interface ResolverService
Parameters:
classLoaders - the class loaders
Throws:
java.lang.IllegalArgumentException - if a class could not be instantiated
See Also:
ResolverService.add(java.lang.ClassLoader[])

add

public void add(java.lang.Class<? extends Resolver> resolverClass)
         throws java.lang.IllegalArgumentException
Description copied from interface: ResolverService
Adds the resolver to the service. Creates the instance immediately.

Specified by:
add in interface ResolverService
Throws:
java.lang.IllegalArgumentException - if the instance could not be created
See Also:
ResolverService.add(java.lang.Class)

add

public void add(Resolver resolver)
Description copied from interface: ResolverService
Add the sepcified resolver to the service.

Specified by:
add in interface ResolverService
Parameters:
resolver - a resolver
See Also:
ResolverService.add(org.peaseplate.resolver.Resolver)

getTemplate

public TemplateLocator getTemplate(TemplateEngine engine,
                                   ResourceKey key)
                            throws TemplateException
Description copied from interface: ResolverService
Asks all resolvers for a template described by the specified key and returns a locator for the template if found.

Specified by:
getTemplate in interface ResolverService
Parameters:
engine - the engine
key - the key
Returns:
a TemplateLocator or null if the template was not found
Throws:
TemplateException - on any error
See Also:
ResolverService.getTemplate(org.peaseplate.TemplateEngine, org.peaseplate.internal.ResourceKey)

getMessages

public MessagesLocator getMessages(TemplateEngine engine,
                                   ResourceKey key)
                            throws TemplateException
Description copied from interface: ResolverService
Asks all resolvers for a messages object described by the specified key and returns a locator for the messages if found.

Specified by:
getMessages in interface ResolverService
Parameters:
engine - the engine
key - the key
Returns:
a MessagesLocator or null if the messages were not found
Throws:
TemplateException - on any error
See Also:
ResolverService.getMessages(org.peaseplate.TemplateEngine, org.peaseplate.internal.ResourceKey)


Copyright © 2008. All Rights Reserved.