Recent Changes - Search:


SourceForge Logo









YourKit Java Profiler

SimpleProfileRepository

The SimpleProfileRepository is an implementation of the ProfileRepository included by default in JFacets. You can use it directly when starting a new project ("fake" the future graph in a few minutes to start developing, and build the real implementation later or in parallel). It's also used in the examples.

Default profiles

The SimpleProfileRepository creates a default profiles tree if you don't override its feed() method, used to represent a fictious users and roles hierarchy :

  • root_profile
    • role_standard
      • john
    • role_standard
      • ivar

Defining your own profiles

The use of the SimpleProfileRepository is easy. You simply have to do 2 things :

  • write a class that extends jfacets.profiles.simple.SimpleProfileRepository, and override the protected void feed() method to create the graph :

package com.xyz.myapp.jfacets;

public class MyProfileRepository extends SimpleProfileRepository {

  @Override
  protected void feed() {
    // create the graph (erf, here it's a tree)
    SimpleProfile root_profile = createProfile("root_profile");
    SimpleProfile admin_role = createProfile("admin_role");
    root_profile.addChild(admin_role);
    SimpleProfile ivar = createProfile("ivar");
    admin_role.addChild(ivar);
    SimpleProfile standard_role = createProfile("standard_role");
    root_profile.addChild(standard_role);
    SimpleProfile john = createProfile("john");
    standard_role.addChild(john);       
  }

}

  • set your implementation class in the Spring context :

<bean id="profileRepository" singleton="true" 
     class="com.xyz.myapp.jfacets.MyProfileRepository">
 </bean>

Then, you can start assigning facets to profiles in the graph and retrieve them.

Edit - History - Print - Recent Changes - Search
Page last modified on December 22, 2006, at 10:59 AM