Recent Changes - Search:


Welcome to JFacets : the profile-based framework

JFacets is an Open-Source (Apache v2.0) lightweight framework that deeply integrates the concept of user profile, and allows easy and consistent developement of profile-based software, by implementing kind of profile-based Inversion of Control.
The system allows to encapsulate virtually any users/roles mechanisms, and to assign code (facets) to them at design-time. Then, you get this code injected in the application at run-time for the user's profile (role, group, etc.), in order to behave in a profiled fashion.
Using JFacets, you don't select what to do manually for different user profiles : you assign the code directly to the profile, and retrieve it when needed.

A different approach to user profiling...

A little code snippet often tells more than a long speech... here under is a "profiled code comparison", between old "if" blocks, and the facet approach. The idea is to show a Product object in different ways based on who's supposed to see it !

The ugly "if ... then ... else" way :

// The product
Product product = ... ;

// the current user...
MyUser user = ... ;

// a dirty, non maintainable "if" block for
// handling the roles problem :-/
if (user.isInRole(Role.ADMIN)) {
} else if (user.isInRole(Role.STANDARD)) {
} ...

Doin' it clean : the facet way :

// the product
Product product = ... ;

// the current user...
MyUser user = ... ;

// get hold of the JFacets bean
JFacets jf = JFacets.get();
// retrieve the facet with name 'show' for current user and the product object
ShowProductFacet facet = (ShowProductFacet)jf.getFacet("show", user.getUsername(), product);

// invoke facet method to perform the profiled work !

As you can see, the facets simply encapsulate the code that has to be used for a given user profile (and target object type : here, the Product), so you don't need no "if" block any more ! You just get hold of the facet, and use it as you want.
It results in much more maintainable and extensible code : you can change the behavior of the application by writing some facets for your user profiles and target object types. Then JFacets know how to retrieve these facets and inject them into the application at run-time, so that the executed code is actually the one you've defined for the user's profile.

Learn more in the concepts.


  • simple, effective and powerful !
  • flexible and generic hierarchical profiles management
  • pluggable to virtually any user management system (LDAP, Active Directory, Custom DB, POJOs, etc.)
  • enables reuse of existing models and user directories for profile-aware application development
  • easy configuration, fully extensible
  • Pure Java and/or Groovy facets
  • WebFacets : use facets in the Web Tier


JFacets has been initiated in Y2K, and has been constantly improving since then. It is mainly used in the GUI field, allowing to create personalized User Interfaces (Web & Swing) easily.

Edit - History - Print - Recent Changes - Search
Page last modified on April 04, 2011, at 01:53 PM