net.sourceforge.jfacets
Class JFacets

java.lang.Object
  extended by net.sourceforge.jfacets.JFacets

public class JFacets
extends Object

Top-level class for clients : used for retrieving facets at run time (see the getFacet(...) methods). The lifecycle of instances of this class goes like :

The preferred way to obtain a JFacets instance is to use the JFacetsBuilder.

Author:
Remi VANKEISBELCK - rvkb.com (remi 'at' rvkb.com)

Constructor Summary
JFacets()
           
 
Method Summary
 void afterPropertiesSet()
          To be invoked after all props have been set.
 void clearCache()
          Clears the profiles cache
 String dumpFacetsAsXml()
          Dump all facets as an XML facet descriptor (utility method, can be handy sometimes to get a list of all facet definitions).
 Object getFacet(String facetName, String profileId)
          Retrieves a facet for passed parameters.
 Object getFacet(String facetName, String profileId, Object targetObject)
          Retrieves a facet for passed parameters (uses targetObject's class to retrieve the facet).
 Object getFacet(String facetName, String profileId, Object targetObject, Class targetObjectClass)
          Retrieves a facet for passed parameters (uses targetObjectClass class to retrieve the facet, so targetObject can be null).
 IFacetRepository getFacetRepository()
           
 String getFallbackProfileId()
           
protected  IProfile getProfile(String profileId)
          Retrieve a profile for passed ID.
 IProfileRepository getProfileRepository()
           
 boolean isUseProfilesCache()
           
 void setFacetRepository(IFacetRepository facetRepository)
           
 void setFallbackProfileId(String fallbackProfileId)
           
 void setUseProfilesCache(boolean useProfilesCache)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JFacets

public JFacets()
Method Detail

getProfile

protected IProfile getProfile(String profileId)
Retrieve a profile for passed ID. Checks for fallback profile and profiles cache if needed.

Returns:
the profile for passed ID if found, null if no such profile

clearCache

public void clearCache()
Clears the profiles cache


getFacet

public Object getFacet(String facetName,
                       String profileId,
                       Object targetObject,
                       Class targetObjectClass)
Retrieves a facet for passed parameters (uses targetObjectClass class to retrieve the facet, so targetObject can be null).

Parameters:
facetName - The name of the facet
profileId - The id of the profile
targetObject - The target object
targetObjectClass - The target object's class to be used to retrieve the facet
Returns:
the facet for passed params if found, null if not found.

getFacet

public Object getFacet(String facetName,
                       String profileId,
                       Object targetObject)
Retrieves a facet for passed parameters (uses targetObject's class to retrieve the facet).

Parameters:
facetName - The name of the facet
profileId - The id of the profile
targetObject - The target object
Returns:
the facet for passed params if found, null if not found.

getFacet

public Object getFacet(String facetName,
                       String profileId)
Retrieves a facet for passed parameters. This version passes a fake Object as the target object of the facet. It can be used when you need only the profile assignation, but don't really care about the target object.

Parameters:
facetName - The name of the facet
profileId - The id of the profile
Returns:
the facet for passed params if found, null if not found.

getFacetRepository

public IFacetRepository getFacetRepository()

setFacetRepository

public void setFacetRepository(IFacetRepository facetRepository)

getProfileRepository

public IProfileRepository getProfileRepository()

getFallbackProfileId

public String getFallbackProfileId()

setFallbackProfileId

public void setFallbackProfileId(String fallbackProfileId)

afterPropertiesSet

public void afterPropertiesSet()
To be invoked after all props have been set. Checks that required components have been injected, and creates the profiles cache map if required.


isUseProfilesCache

public boolean isUseProfilesCache()

setUseProfilesCache

public void setUseProfilesCache(boolean useProfilesCache)

dumpFacetsAsXml

public String dumpFacetsAsXml()
Dump all facets as an XML facet descriptor (utility method, can be handy sometimes to get a list of all facet definitions).



Copyright © 2012. All Rights Reserved.