[jboss-user] [JBoss Seam] - Stop the violence! How should we be separating our beans?
cingram
do-not-reply at jboss.com
Thu Mar 29 14:25:47 EDT 2007
Our developers are getting ready to come to blows.
How should we be separating our session beans? Is the preferred method for application design in seam to have 1 ejb for the Action Listener and another to contain the actual business methods, refer to ex 1? Or should we just combine the 2 beans in to 1 refer to ex 2.
ex 1.
| @Stateful
| @Name("addressmanager")
| public class AddressManagerBean implements AddressManager {
|
| @In
| private Address address;
|
| //..some other business methods.
|
| public boolean allowAddressChange() {
| //perform some sort of rules check.
|
| return rulecheck.checkAddressRules();
| }
| }
|
|
| @Stateful
| @Name("addressmanageraction")
| public class AddressManagerActionBean implements AddressManagerAction {
|
| @In
| private Address address;
|
| @In
| private AddressManager addressManager;
|
| @In
| private FacesMessages facesMessages;
|
| //..some other business methods.
|
| public void checkifAllowAddressChange() {
| if ( ! addressManager.allowAddressChange()) {
| facesMessages.addToControl("FailedAddressChangeRuleCheck", "The addrress can not be changed.");
| }
| }
| }
|
| //The pages.xml or .jpdl.xml file would contain the navigation rules.
|
ex 2.
| @Stateful
| @Name("addressmanager")
| public class AddressManagerBean implements AddressManager {
|
| @In
| private Address address;
|
| @In
| private FacesMessages facesMessages;
|
| //..some other business methods.
|
| public boolean checkifAllowAddressChange() {
|
| boolean allowAddressChange rulecheck.checkAddressRules(); //This could maybe be replaced by Drools
|
|
| if ( ! allowAddressChange()) {
| facesMessages.addToControl("FailedAddressChangeRuleCheck", "The addrress can not be changed.");
| }
|
| return allowAddressChange();
| }
| }
|
| // The pages.xml or .jpdl.xml file would contain the navigation rules.
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4032890#4032890
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4032890
More information about the jboss-user
mailing list