org.peaseplate.service
Interface ResolverService

All Known Implementing Classes:
DefaultResolverService

public interface ResolverService

The resolver service is used to resolve templates and messages from somewhere by the specified key that contains the name and the locale. The resolver service can be enhanced by adding Resolvers to it.

Author:
Manfred Hantschel

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.
 

Method Detail

add

void add(java.lang.ClassLoader... classLoaders)
         throws java.lang.IllegalArgumentException
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.

Parameters:
classLoaders - the class loaders
Throws:
java.lang.IllegalArgumentException - if a class could not be instantiated

add

void add(java.lang.Class<? extends Resolver> resolverClass)
         throws java.lang.IllegalArgumentException
Adds the resolver to the service. Creates the instance immediately.

Parameters:
resolverClass -
Throws:
java.lang.IllegalArgumentException - if the instance could not be created

add

void add(Resolver resolver)
Add the sepcified resolver to the service.

Parameters:
resolver - a resolver

getTemplate

TemplateLocator getTemplate(TemplateEngine engine,
                            ResourceKey key)
                            throws TemplateException
Asks all resolvers for a template described by the specified key and returns a locator for the template if found.

Parameters:
engine - the engine
key - the key
Returns:
a TemplateLocator or null if the template was not found
Throws:
TemplateException - on any error

getMessages

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

Parameters:
engine - the engine
key - the key
Returns:
a MessagesLocator or null if the messages were not found
Throws:
TemplateException - on any error


Copyright © 2008. All Rights Reserved.