net.officefloor.plugin.section.clazz
Class ClassSectionSource

java.lang.Object
  extended by net.officefloor.compile.spi.section.source.impl.AbstractSectionSource
      extended by net.officefloor.plugin.section.clazz.ClassSectionSource
All Implemented Interfaces:
SectionSourceService<ClassSectionSource>, SectionSource
Direct Known Subclasses:
HttpTemplateSectionSource

public class ClassSectionSource
extends AbstractSectionSource
implements SectionSourceService<ClassSectionSource>

Class SectionSource.

The implementation has been segregated into smaller methods to allow overriding to re-use ClassSectionSource for other uses.

Author:
Daniel Sagenschneider

Nested Class Summary
 
Nested classes/interfaces inherited from class net.officefloor.compile.spi.section.source.impl.AbstractSectionSource
AbstractSectionSource.SpecificationContext
 
Field Summary
static String CLASS_OBJECT_NAME
          Name of the SectionManagedObject for the section class.
 
Constructor Summary
ClassSectionSource()
           
 
Method Summary
protected  SectionManagedObject createClassManagedObject(String objectName, Class<?> sectionClass)
          Creates the SectionManagedObject for providing the section object.
protected  void enrichTask(SectionTask task, TaskType<?,?,?> taskType, Method taskMethod, Class<?> parameterType)
          Enriches the Task.
protected  DependencyMetaData[] extractClassManagedObjectDependencies(String objectName, Class<?> sectionClass)
          Extracts the DependencyMetaData instances for the section object.
protected  SectionSourceContext getContext()
          Obtains the SectionSourceContext.
protected  SectionDesigner getDesigner()
          Obtains the SectionDesigner.
 SectionManagedObject getManagedObject(String typeName)
          Obtains the SectionManagedObject for the type.
 SectionObject getOrCreateObject(String qualifier, String typeName)
           Obtains the SectionObject.
 SectionOutput getOrCreateOutput(String name, String argumentType, boolean isEscalationOnly)
           Obtains the SectionOutput.
 SubSection getOrCreateSubSection(Class<?> sectionInterfaceType, SectionInterface sectionAnnotation)
           Obtains the SubSection.
protected  Class<?> getSectionClass(String sectionClassName)
          Obtains the section class.
protected  String getSectionClassName()
          Obtains the name of the class for the section.
 String getSectionSourceAlias()
          Obtains the alias for the SectionSource Class.
 Class<ClassSectionSource> getSectionSourceClass()
          Obtains the SectionSource Class.
 SectionTask getTaskByName(String taskName)
          Obtains the SectionTask by its name.
 SectionTask getTaskByTypeName(String taskTypeName)
          Obtains the SectionTask by its TaskType name.
protected  String getTaskName(TaskType<?,?,?> taskType)
          Obtains the Task name from the TaskType.
protected  void linkNextTask(SectionTask task, TaskType<?,?,?> taskType, Method taskMethod, Class<?> argumentType, NextTask nextTaskAnnotation)
          Links the next Task.
protected  void linkTaskEscalation(SectionTask task, TaskType<?,?,?> taskType, TaskEscalationType escalationType, SectionTask escalationHandler)
          Links the Task escalation.
protected  void linkTaskFlow(SectionTask task, TaskType<?,?,?> taskType, Class<?> flowInterfaceType, Method flowMethod, Class<?> flowArgumentType)
          Links the TaskFlow.
protected  void linkTaskFlow(TaskFlow taskFlow, TaskType<?,?,?> taskType, Class<?> flowInterfaceType, Method flowMethod, Class<?> flowArgumentType)
          Links the TaskFlow.
protected  void linkTaskObject(SectionTask task, TaskType<?,?,?> taskType, TaskObjectType<?> objectType)
          Links the TaskObject.
protected  void loadSpecification(AbstractSectionSource.SpecificationContext context)
          Loads the SectionSourceSpecification.
 void registerTaskByTypeName(String taskTypeName, SectionTask task)
           Allows being made aware of further SectionTask instances within the section to be considered for linking flows.
 void sourceSection(SectionDesigner designer, SectionSourceContext context)
          Sources the OfficeSection by constructing it via the input SectionDesigner.
 
Methods inherited from class net.officefloor.compile.spi.section.source.impl.AbstractSectionSource
getSpecification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_OBJECT_NAME

public static final String CLASS_OBJECT_NAME
Name of the SectionManagedObject for the section class.

See Also:
Constant Field Values
Constructor Detail

ClassSectionSource

public ClassSectionSource()
Method Detail

getDesigner

protected SectionDesigner getDesigner()
Obtains the SectionDesigner.

Returns:
SectionDesigner;

getContext

protected SectionSourceContext getContext()
Obtains the SectionSourceContext.

Returns:
SectionSourceContext.

getTaskByName

public SectionTask getTaskByName(String taskName)
Obtains the SectionTask by its name.

Parameters:
taskName - Name of the SectionTask.
Returns:
SectionTask or null if no SectionTask by the name.

getTaskByTypeName

public SectionTask getTaskByTypeName(String taskTypeName)
Obtains the SectionTask by its TaskType name.

Parameters:
taskTypeName - TaskType name.
Returns:
SectionTask or null if no SectionTask by the TaskType name.

registerTaskByTypeName

public void registerTaskByTypeName(String taskTypeName,
                                   SectionTask task)

Allows being made aware of further SectionTask instances within the section to be considered for linking flows.

This allows ClassSectionSource to be used in conjunction with other functionality - such as template rendering for dynamic HTTP web pages.

Parameters:
taskTypeName - Name to register the SectionTask.
task - SectionTask.

getOrCreateObject

public SectionObject getOrCreateObject(String qualifier,
                                       String typeName)

Obtains the SectionObject.

Should the SectionObject not yet be added, it is added.

Parameters:
qualifier - Qualifier for the SectionObject. If not Qualifier should be the same as the type name.
typeName - Fully qualified type name of the SectionObject.
Returns:
SectionObject.

getManagedObject

public SectionManagedObject getManagedObject(String typeName)
Obtains the SectionManagedObject for the type.

Parameters:
typeName - Fully qualified type name of the object for the SectionManagedObject.
Returns:
SectionManagedObject or null if no SectionManagedObject for the type.

getOrCreateOutput

public SectionOutput getOrCreateOutput(String name,
                                       String argumentType,
                                       boolean isEscalationOnly)

Obtains the SectionOutput.

Should the SectionOutput not yet be added, it is added.

Parameters:
name - Name of the SectionOutput.
argumentType - Type of the argument. May be null if no argument.
isEscalationOnly - true if escalation only.
Returns:
SectionObject.

getOrCreateSubSection

public SubSection getOrCreateSubSection(Class<?> sectionInterfaceType,
                                        SectionInterface sectionAnnotation)

Obtains the SubSection.

Should the SubSection not already be created, it is created.

Parameters:
sectionInterfaceType - Type that is annotated with SectionInterface.
sectionAnnotation - SectionInterface annotation.
Returns:
SubSection.

getSectionClassName

protected String getSectionClassName()
Obtains the name of the class for the section.

Returns:
Class name for the backing class of the section.

getSectionClass

protected Class<?> getSectionClass(String sectionClassName)
                            throws Exception
Obtains the section class.

Parameters:
sectionClassName - Name of the section class.
Returns:
Section class.
Throws:
Exception - If fails to obtain the section class.

createClassManagedObject

protected SectionManagedObject createClassManagedObject(String objectName,
                                                        Class<?> sectionClass)
Creates the SectionManagedObject for providing the section object.

Parameters:
objectName - Name of the object within the section.
sectionClass - Section object class.
Returns:
SectionManagedObject.

extractClassManagedObjectDependencies

protected DependencyMetaData[] extractClassManagedObjectDependencies(String objectName,
                                                                     Class<?> sectionClass)
                                                              throws Exception
Extracts the DependencyMetaData instances for the section object.

Parameters:
objectName - Name of the object within the section.
sectionClass - Section object class.
Returns:
Extracted DependencyMetaData instances for the section object.
Throws:
Exception - If fails to extract the DependencyMetaData instances.

getTaskName

protected String getTaskName(TaskType<?,?,?> taskType)
Obtains the Task name from the TaskType.

Parameters:
taskType - TaskType.
Returns:
Task name.

enrichTask

protected void enrichTask(SectionTask task,
                          TaskType<?,?,?> taskType,
                          Method taskMethod,
                          Class<?> parameterType)
Enriches the Task.

Parameters:
task - SectionTask.
taskType - TaskType for the SectionTask.
taskMethod - Method for the SectionTask.
parameterType - Parameter type for the SectionTask. May be null if no parameter.

linkNextTask

protected void linkNextTask(SectionTask task,
                            TaskType<?,?,?> taskType,
                            Method taskMethod,
                            Class<?> argumentType,
                            NextTask nextTaskAnnotation)
Links the next Task.

Parameters:
task - SectionTask.
taskType - TaskType.
taskMethod - Method for the SectionTask.
argumentType - Argument type. May be null if no argument type.
nextTaskAnnotation - NextTask annotation on the Method.

linkTaskFlow

protected void linkTaskFlow(SectionTask task,
                            TaskType<?,?,?> taskType,
                            Class<?> flowInterfaceType,
                            Method flowMethod,
                            Class<?> flowArgumentType)
Links the TaskFlow.

Parameters:
task - SectionTask.
taskType - TaskType.
flowInterfaceType - Interface type specifying the flows.
flowMethod - Method on the interface for the flow to be linked.
flowArgumentType - TaskFlow argument type. May be null if no argument.

linkTaskFlow

protected void linkTaskFlow(TaskFlow taskFlow,
                            TaskType<?,?,?> taskType,
                            Class<?> flowInterfaceType,
                            Method flowMethod,
                            Class<?> flowArgumentType)
Links the TaskFlow.

Parameters:
taskFlow - TaskFlow.
taskType - TaskType.
flowInterfaceType - Interface type specifying the flows.
flowMethod - Method on the interface for the flow to be linked.
flowArgumentType - TaskFlow argument type. May be null if no argument.

linkTaskEscalation

protected void linkTaskEscalation(SectionTask task,
                                  TaskType<?,?,?> taskType,
                                  TaskEscalationType escalationType,
                                  SectionTask escalationHandler)
Links the Task escalation.

Parameters:
task - SectionTask.
taskType - TaskType.
escalationType - TaskEscalationType.
escalationHandler - Potential SectionTask that can handle escalation based on its parameter. May be null if no SectionTask can handle the escalation.

linkTaskObject

protected void linkTaskObject(SectionTask task,
                              TaskType<?,?,?> taskType,
                              TaskObjectType<?> objectType)
Links the TaskObject.

Parameters:
task - SectionTask.
taskType - TaskType.
objectType - TaskObjectType.

getSectionSourceAlias

public String getSectionSourceAlias()
Description copied from interface: SectionSourceService
Obtains the alias for the SectionSource Class.

Specified by:
getSectionSourceAlias in interface SectionSourceService<ClassSectionSource>
Returns:
Alias for the SectionSource Class.

getSectionSourceClass

public Class<ClassSectionSource> getSectionSourceClass()
Description copied from interface: SectionSourceService
Obtains the SectionSource Class.

Specified by:
getSectionSourceClass in interface SectionSourceService<ClassSectionSource>
Returns:
SectionSource Class.

loadSpecification

protected void loadSpecification(AbstractSectionSource.SpecificationContext context)
Description copied from class: AbstractSectionSource
Loads the SectionSourceSpecification.

Specified by:
loadSpecification in class AbstractSectionSource
Parameters:
context - AbstractSectionSource.SpecificationContext.

sourceSection

public void sourceSection(SectionDesigner designer,
                          SectionSourceContext context)
                   throws Exception
Description copied from interface: SectionSource
Sources the OfficeSection by constructing it via the input SectionDesigner.

Specified by:
sourceSection in interface SectionSource
Parameters:
designer - SectionDesigner to construct the structure of the OfficeSection.
context - SectionSourceContext to source details to construct the OfficeSection.
Throws:
Exception - If fails to construct the OfficeSection.


Copyright © 2005-2013. All Rights Reserved.