We have an EJB application with both local/remote views.
There are some common business rules validations used across EJB components in the application. I was thinking on lines, if these common validation methods could be seperated out into a POJO (probably implemented as singleton) which could be called from various EJB(s).
Is the approach correct? Any better alternatives/patterns?
The purpose is to have common validations at once place (class) in the EJB tier.
-
Common Business Rules Validations (4 messages)
- Posted by: Aarkay .
- Posted on: December 31 2003 00:32 EST
Threaded Messages (4)
- Common Business Rules Validations by Paul Strack on December 31 2003 21:05 EST
- Common Business Rules Validations by Mircea Crisan on January 13 2004 11:49 EST
- Common Business Rules Validations by Aarkay . on January 15 2004 08:35 EST
- Common Business Rules Validations by Paul Strack on January 15 2004 05:18 EST
- Common Business Rules Validations by Aarkay . on January 15 2004 08:35 EST
-
Common Business Rules Validations[ Go to top ]
- Posted by: Paul Strack
- Posted on: December 31 2003 21:05 EST
- in response to Aarkay .
That's not a bad approach, provided that your POJO singleton does not use any instance variables.
For that matter, you may find that you can make many of your simple validations (max, min, maxlength, minlength) static methods. -
Common Business Rules Validations[ Go to top ]
- Posted by: Mircea Crisan
- Posted on: January 13 2004 11:49 EST
- in response to Aarkay .
Try using the jakarta validator framework. Struts uses it too. In this way you can
obtain a flexible validation because you can exeternalize your validation rules in configuration files. I suppose that this validation service will be heavily used
so I suggest you make it a session bean. Maybe a session bean sounds to heavy because you don't need all the enterprise services (transactions, security, distribution, etc), you just need the object pooling. Making it a singleton implies that you have to aware of the threading and distribution issues imposed by the application server.
Best regards, Mircea -
Common Business Rules Validations[ Go to top ]
- Posted by: Aarkay .
- Posted on: January 15 2004 08:35 EST
- in response to Mircea Crisan
I had initially posted this message.
Actually, by validations, I meant business rules on domain objects, the business rule is inside EJB components. For e.g. isAccountExists(), isBalanceAvailable(), hasMatchingEmployees() etc ...
These validations are commonly required in across the components (session beans). So the question was, could the common validations be centralized into some class accessible from various session beans. The common validation class might need to lookup session beans for business rules validations. -
Common Business Rules Validations[ Go to top ]
- Posted by: Paul Strack
- Posted on: January 15 2004 17:18 EST
- in response to Aarkay .
The answer is still yes. Just be careful about how you do the lookups. If your Java Objects are singletons, do not use any instance variables. Restrict yourself to local variables within your validation methods, and you should be OK.