org.webmacro.directive
Class DirectiveProvider

java.lang.Object
  extended byorg.webmacro.directive.DirectiveProvider
All Implemented Interfaces:
Provider

public final class DirectiveProvider
extends java.lang.Object
implements Provider

Utility class to assist in the creation of directives.


Field Summary
static java.lang.String DIRECTIVE_KEY
           
 
Constructor Summary
DirectiveProvider()
           
 
Method Summary
 void destroy()
          Close down this provider, freeing any allocated resources.
 void flush()
          Clear any cache this provider may be maintaining
 java.lang.Object get(java.lang.String name)
          The DirectiveProvider doesn't throw an exception when it can't find the directive -- it just returns null.
 java.lang.String getType()
          Return an array representing the types this provider serves up
 void init(Broker broker, Settings config)
          Initialize this provider based on the specified config.
 void registerDescriptor(DirectiveDescriptor dd, java.lang.String dirName)
          Register an org.webmacro.directive.DirectiveDescriptor to be used as if it were a real Directive named dirName.
 void registerDirective(java.lang.String dirClassName, java.lang.String dirName)
          Register a new directive class, so that a builder of this type can be retrieved later.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECTIVE_KEY

public static final java.lang.String DIRECTIVE_KEY
See Also:
Constant Field Values
Constructor Detail

DirectiveProvider

public DirectiveProvider()
Method Detail

registerDescriptor

public final void registerDescriptor(DirectiveDescriptor dd,
                                     java.lang.String dirName)
Register an org.webmacro.directive.DirectiveDescriptor to be used as if it were a real Directive named dirName.

If the specified dirName is already registered, it is happily, and silently replaced.

Once registered, one can use this "directive" from a template like so:

    #dirName arg1 arg2 argN

 where the args are dependant on the DirectiveDescriptor
 

Parameters:
dd - the DirectiveDescriptor
dirName - name of the "directive"

registerDirective

public final void registerDirective(java.lang.String dirClassName,
                                    java.lang.String dirName)
                             throws IntrospectionException,
                                    InitException
Register a new directive class, so that a builder of this type can be retrieved later.

Throws:
IntrospectionException - something wrong with the class
InitException - duplicate registration

getType

public java.lang.String getType()
Description copied from interface: Provider
Return an array representing the types this provider serves up

Specified by:
getType in interface Provider

init

public void init(Broker broker,
                 Settings config)
          throws InitException
Description copied from interface: Provider
Initialize this provider based on the specified config.

Specified by:
init in interface Provider
Throws:
InitException

destroy

public void destroy()
Description copied from interface: Provider
Close down this provider, freeing any allocated resources.

Specified by:
destroy in interface Provider

get

public java.lang.Object get(java.lang.String name)
The DirectiveProvider doesn't throw an exception when it can't find the directive -- it just returns null.

Specified by:
get in interface Provider

flush

public void flush()
Description copied from interface: Provider
Clear any cache this provider may be maintaining

Specified by:
flush in interface Provider