[jboss-user] [JBoss Seam] - Re: roles redirecting methods

zhamdi do-not-reply at jboss.com
Mon Jan 21 04:11:49 EST 2008


Hi Shane,

Sorry if my last mail wasn't clear. I'll explain the idea by the mean of a frequent example:

Let's imagine we have an application with 3 rules: client, commercial and administrator : the client can see only its orders, the commercial can only see the orders of his clients and the administrator can see all orders: 

This example can only be developed like this :

  | doCommonCode();
  | if( rule="commercial" ) {
  |   doCommercial(); 
  | } else if( rule="client" ) {
  |   doClient();
  | } else if( rule="administrator" ) {
  |   doAdministrator();
  | } 

The new seam authorization mecanism cant' do this simply beacuse the @Restricted annotation is binary (not a switch). These if else blocks become very frequent and reduce code readability.

The solution I sent is just a proposition: It attempts to add to the annotations the responsibility to redirect to the business rule case method. Here's how I imagine it:

@RuleSensible comes as the @Override annotation : it just enforces readability and code changes safety : it informs this method is a rule switch. (inside the method body comes the common code to all cases)

@RuleCase( method="switchMethodName ) is there to say : this is a switch case for the given method

and finally @Restricted comes to say which rule case must be handled by the annotated method.

So here was my idea, I hope you'll like it.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4121738#4121738

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4121738



More information about the jboss-user mailing list