com.pietschy.command.annotation.impl
Class DefaultAnnotationSupport

java.lang.Object
  extended by com.pietschy.command.annotation.impl.DefaultAnnotationSupport
All Implemented Interfaces:
AnnotationSupport

public class DefaultAnnotationSupport
extends java.lang.Object
implements AnnotationSupport

Default implementation of AnnotationSupport.

This class uses instances of AnnotationProcessor to process annotated methods. Two processors are installed by default, the ActionCommandProcessor and SwingWorkerCommandProcessor.

New annotation processors can be installed using installProcessor(AnnotationProcessor).


Nested Class Summary
protected static interface DefaultAnnotationSupport.BindStrategy
          Simple interface for handling the various type of bind operation.
protected  class DefaultAnnotationSupport.ComponentBindStrategy
          BindAction implementation that binds to a component.
protected  class DefaultAnnotationSupport.ContainerBindStrategy
          BindAction implementation that binds to a CommandContainer.
 
Constructor Summary
DefaultAnnotationSupport()
          Creates a new instance.
 
Method Summary
 void bindAnnotatedCommands(CommandContainer container, java.lang.Object target)
          Binds the annotated methods of the specified target to the specified CommandContainer.
 void bindAnnotatedCommands(java.awt.Component component, java.lang.Object target)
          Binds the annotated methods of the specified target to the specified component.
protected  void installDefaultProcessors()
          Installs the default processors defined by the library.
 void installProcessor(AnnotationProcessor processor)
          Installs a new processor.
protected  void processAnnotatedMethods(java.lang.Object target, DefaultAnnotationSupport.BindStrategy bindStrategy)
          Scans all the annotated methods of the specified target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultAnnotationSupport

public DefaultAnnotationSupport()
Creates a new instance.

Method Detail

installDefaultProcessors

protected void installDefaultProcessors()
Installs the default processors defined by the library.


installProcessor

public void installProcessor(AnnotationProcessor processor)
Installs a new processor. Any existing process for the same annotation class will be replaced.

Parameters:
processor - the new processor to install.

bindAnnotatedCommands

public void bindAnnotatedCommands(CommandContainer container,
                                  java.lang.Object target)
Binds the annotated methods of the specified target to the specified CommandContainer.

Specified by:
bindAnnotatedCommands in interface AnnotationSupport
Parameters:
container - the container to bind to.
target - the object with the annotated methods.

bindAnnotatedCommands

public void bindAnnotatedCommands(java.awt.Component component,
                                  java.lang.Object target)
Binds the annotated methods of the specified target to the specified component.

Specified by:
bindAnnotatedCommands in interface AnnotationSupport
Parameters:
component - the component to bind to.
target - the object with the annotated methods.

processAnnotatedMethods

protected void processAnnotatedMethods(java.lang.Object target,
                                       DefaultAnnotationSupport.BindStrategy bindStrategy)
Scans all the annotated methods of the specified target. All created commands are bound using the specified DefaultAnnotationSupport.BindStrategy.

Parameters:
target - the object to scan.
bindStrategy - the bind action to take.


Copyright © 2006 - 2007 Andrew Pietsch