Recent Changes - Search:


SourceForge Logo









YourKit Java Profiler

ProfileRepository

The ProfileRepository is the cornerstone of JFacets. It's the base building block that allows the framework to know about the application's profiles graph.

Encapsulating existing users/roles/groups/etc. models

Many models, services, data structures etc. exist for managing concepts like users, roles, groups etc. They all have one common thing : you can abstract them by a graph. In JFacets, profiles are linked together through parent/child relations, which makes the whole thing a graph. The framework istelf relies on that graph in order to navigate into it and retrieve facets assigned to nodes (profiles).

JFacets only specifies the profiles management system (see the IProfile and IProfileRepository interfaces), and it is up to you to provide an implementation of this spec as bridges to your own users/groups/roles/whatever, and to make the relation with your databases/directories/etc.

Basically, a profile (a node in the graph) has to be identifiable (unique ID), and is represented by an object implementing the net.sourceforge.jfacets.IProfile interface. The ProfileRepository (net.sourceforge.jfacets.IProfileRepository) uses such objects, and allows JFacets to :

  • get a profile by its unique ID ;
  • get parents of a given profile.

This is the simple contract that you have to fulfill in order to get JFacets working with your own system, whatever it can be.

Injection of your ProfileRepository into JFacets is done using the Spring context.

Some examples

Let's think about a few examples to make it more clear. First, a Operating System users/groups management (with groups) :

Now another profiles structure which reflects a company's organisation :

As you can see, in this organisation we've got composite "departments" as well as multiple inheritance for the employee Ma Baker who is in both Sales and Human Resources departments.

Of course, these two examples are not exhaustive, and you can virtually model any kind of profiles management systems with this multiple inheritance model. This concept has been implemented in several applications, all backed by their own proprietary user management API, and it always revealed natural and convenient.

Getting up and ready quicker : the SimpleProfileRepository

JFacets includes the SimpleProfileRepository which allows to quickly create a representation of what the graph will look like with almost no coding. This can be helpful when starting a new project, or for evaluating JFacets.

Regular Users/Roles model

JFacets provides a less "abstract" path for implementing the Profile Repository, in case your system deals with users and roles.

The IUsersAndRolesManager interface specifies a contract that you can implement in order to plug JFacets to your own users/roles system. It supports the following characteristics :

  • Users can have multiple roles ;
  • Roles can "inherit" of other roles.

As you can see, the graph sructure is still there, but with more self-explanatory concepts.

Your implementation of the IUsersAndRolesManager interface has to be configured via Spring, as usual. But this time, instead of declaring the PR class, you'll use an existing one that delegates to your users/roles manager, like this :

<!-- Profile Repo for users/roles systems (don't change this one) -->
        <bean id="profileRepository" singleton="true" 
                        class="net.sourceforge.jfacets.usersandroles.UsersAndRolesProfileRepository">

                <property name="usersAndRolesManager"><ref bean="usersAndRoles"/></property>
        </bean>

        <!-- users/roles datasource : to be configured -->
        <bean id="usersAndRoles" singleton="true"
                        class="com.xyz.myapp.UsersAndRolesImpl">

                 <!-- additional config of your bean goes here -->
        </bean>

Edit - History - Print - Recent Changes - Search
Page last modified on September 19, 2006, at 09:55 AM