Recent Changes - Search:


SourceForge Logo









YourKit Java Profiler

Architecture

JFacets uses several components (wired together using Spring) to make the whole thing work, and keep it fully extensible.

Here under is the global architecture of the framework :

Let's describe the components involved...

JFacets

This is the top-level class used at run-time for retrieving and executing facets. It encapsulates the internals of the framework, and exposes a simple API. In most of the cases, you will only deal with this one when writing code that uses facets.

You don't have to change anything in there or extend something : this component is already functional and you don't need to replace it in the Spring context.

FacetRepository

This component handles most of the stuff (using sub-components) :

  • loading the facet descriptors (delegates to FacetDescriptorManager) ;
  • locating a facet class from a (name, profile, target object class) key (uses ProfileRepository) ;
  • instanciating facets (using FacetFactory) ;
  • creating facet contexts (using FacetContextFactory) ;

It's implemented in the net.sourceforge.jfacets.impl.FacetRepositoryImpl, and you don't have to change it (excepted if you plan to optimize a few things in there ;-P).

FacetDescriptorManager

The FacetDescriptorManager (net.sourceforge.jfacets.impl.FacetDescriptorManager) handles loading of/access to the FacetDescriptors, which provides informations about facet assignations (the infamous (name, profileId, target class) key).

Some variants of this component are already provided for different use cases (pure Java facets, Groovy facets or both), which should be sufficient for usual situations. Nevertheless, it can be configured via the Spring ApplicationContext, and you could implement your own FacetDescriptorManager for handling additional stuff if you need.

FacetFactory

FacetFactories are responsible of creating facet instances. They must implement the net.sourceforge.jfacets.IFacetFactory interface and be injected using the Spring context.

One again, JFacets ships with default implementations that uses Class.newInstance() (no-args constructors) to create Java and Groovy facets. These ones should be sufficient in most cases, but still you can replace/extend this part if you want to.

FacetContext and FacetContextFactory

The FacetContext (defined by the interface net.sourceforge.jfacets.IFacetContext) provides access to the (name, profile, targetObject) parameters that were passed for retrieving the facet.

When a facet is created, the FacetRepository also creates a FacetContext and passes it to the facet before it's returned to the caller.

FacetContextFactories are reponsible of creating FacetContexts. The FacetContextFactory is defined in the Spring context, and injected into the FacetRepository so that this one can create the contexts and pass them to created facets.

JFacets ships with a default implementation of the FacetContextFactory, and you probably won't need to change this. Anyway, in some circumstances (if you want to add things to the context), you may need to do so. Then just implement the IFacetContextFactory interface, and wire your factory using the Spring context (you can have a look at WebFacets, it's a good custom factory example).

ProfileRepository

The ProfileRepository is the component that encapsulates management of users, roles etc. and abstracts all this as a navigable graph of profiles. It's an adapter for your own stuff that allows JFacets to know about the hierarchical structure of your users, roles etc.

This component must be implemented by developers in order to wrap the user management mechanisms and make them available as JFacets profiles. You also have to provide the class name of your ProfileRepository in the Spring context :

<bean id="profileRepository" singleton="true" 
                        class="net.sourceforge.jfacets.simpleprofiles.SimpleProfileRepository">
        </bean>

Have a look here for more infos about the ProfileRepository.

Edit - History - Print - Recent Changes - Search
Page last modified on August 30, 2006, at 10:52 PM