net.sourceforge.jfacets.annotations
Class AnnotatedFacetDescriptorManager

java.lang.Object
  extended by net.sourceforge.jfacets.annotations.AnnotatedFacetDescriptorManager
All Implemented Interfaces:
IFacetDescriptorManager

public class AnnotatedFacetDescriptorManager
extends java.lang.Object
implements IFacetDescriptorManager

The AnnotatedFacetDescriptorManager : loads and manages descriptors for facets using the @FacetKey annotation.
This manager scans the classpath in order to find classes that implement the IFacet interface and are marked with a @FacetKey annotation. If found, a descriptor is crated and added for this facet, based on the information supplied in the annotation's attributes.
IMPORTANT : You HAVE to provide at least one base package when creating this objects.

Author:
Remi VANKEISBELCK - remi@rvkb.com

Field Summary
private  java.util.List<java.lang.String> basePackages
          base packages list to search facet scripts in
private  java.util.ArrayList<FacetDescriptor> descriptors
          the list of loaded descriptors
private static JFacetsLogger logger
           
private  int nbDesc
           
 
Constructor Summary
AnnotatedFacetDescriptorManager(java.util.List<java.lang.String> basePackages)
          Create the manager and set base packages.
 
Method Summary
private  FacetDescriptor createDescriptorForAnnotation(FacetKey annot, java.lang.Class facetClass)
          Create a descriptor for passed FacetKey and facet class and adds it to the descriptors list
 FacetDescriptor getDescriptor(java.lang.String name, java.lang.String profileId, java.lang.Class targetObjectType)
          Return the descriptor sctrictly associated to passed params if any, null of not found.
 FacetDescriptor[] getDescriptors()
          Return all descriptors in an array.
 void initialize()
          Loads all available Facet Descriptors by scanning the CLASSPATH with specified base packages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final JFacetsLogger logger

basePackages

private java.util.List<java.lang.String> basePackages
base packages list to search facet scripts in


descriptors

private java.util.ArrayList<FacetDescriptor> descriptors
the list of loaded descriptors


nbDesc

private int nbDesc
Constructor Detail

AnnotatedFacetDescriptorManager

public AnnotatedFacetDescriptorManager(java.util.List<java.lang.String> basePackages)
Create the manager and set base packages.

Parameters:
basePackages -
Method Detail

initialize

public void initialize()
Loads all available Facet Descriptors by scanning the CLASSPATH with specified base packages.


createDescriptorForAnnotation

private FacetDescriptor createDescriptorForAnnotation(FacetKey annot,
                                                      java.lang.Class facetClass)
Create a descriptor for passed FacetKey and facet class and adds it to the descriptors list

Parameters:
annot - The FacetKey annotation
facetClass - The facet implementation class
Returns:
The freshly created descriptor if ok, null if error (missing infos in the facet key)

getDescriptor

public FacetDescriptor getDescriptor(java.lang.String name,
                                     java.lang.String profileId,
                                     java.lang.Class targetObjectType)
Return the descriptor sctrictly associated to passed params if any, null of not found.

Specified by:
getDescriptor in interface IFacetDescriptorManager

getDescriptors

public FacetDescriptor[] getDescriptors()
Return all descriptors in an array.

Specified by:
getDescriptors in interface IFacetDescriptorManager


Copyright © 2010. All Rights Reserved.