net.sourceforge.jfacets.annotations
Class AnnotatedFacetDescriptorManager

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

public class AnnotatedFacetDescriptorManager
extends 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

Constructor Summary
AnnotatedFacetDescriptorManager(List<String> basePackages)
          Create the manager and set base packages that will be scanned for annotated facets.
 
Method Summary
 ClassLoader getClassLoader()
           
 FacetDescriptor getDescriptor(String name, String profileId, Class targetObjectType)
          Return the descriptor sctrictly associated to passed params if any, null of not found.
 FacetDescriptor[] getDescriptors()
          Return all descriptors in an array.
 DuplicatedKeyPolicyType getDuplicatedKeyPolicy()
           
 AnnotatedFacetDescriptorManager initialize()
          Loads all available Facet Descriptors by scanning the CLASSPATH with specified base packages.
 AnnotatedFacetDescriptorManager setClassLoader(ClassLoader classLoader)
          Set the class loader to be used for classpath scanning
 AnnotatedFacetDescriptorManager setDuplicatedKeyPolicy(DuplicatedKeyPolicyType policyType)
          Set the duplicated key policy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotatedFacetDescriptorManager

public AnnotatedFacetDescriptorManager(List<String> basePackages)
Create the manager and set base packages that will be scanned for annotated facets.

Parameters:
basePackages - the packages as a list of Strings
Method Detail

setDuplicatedKeyPolicy

public AnnotatedFacetDescriptorManager setDuplicatedKeyPolicy(DuplicatedKeyPolicyType policyType)
Set the duplicated key policy. This allows to enable duplicated keys, or to throw an exception when dups are found.

Parameters:
policyType - the policy to use
Returns:
this for chained calls

setClassLoader

public AnnotatedFacetDescriptorManager setClassLoader(ClassLoader classLoader)
Set the class loader to be used for classpath scanning

Parameters:
classLoader - the classloader to be used
Returns:
this for chained calls

getClassLoader

public ClassLoader getClassLoader()

getDuplicatedKeyPolicy

public DuplicatedKeyPolicyType getDuplicatedKeyPolicy()

initialize

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

Returns:
this for chained calls

getDescriptor

public FacetDescriptor getDescriptor(String name,
                                     String profileId,
                                     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 © 2012. All Rights Reserved.