[jboss-user] [JBoss Seam] - Re: Avoiding the DRY Principle with beans

fabio.ita04 do-not-reply at jboss.com
Sun Dec 24 15:51:41 EST 2006


Hi,

I'm trying to implement Session Bean Inheritance, so common business methods (like defaults for search and save) are encapsulated on a superclass, and subclasses overrides just the methods they have a particular behavor. Superclasses can have properties that holds bean state. Multiple interface inheritance is desirable too. Ex:


  | interface BusinessService {
  |   save();
  |   search();
  |   ...
  |   Object getMyProperty(); // holds some state
  | }
  | 


  | class BusinessManager implements BusinessService {
  |   save() { ... };
  |   search() { ... };
  |   ...
  |   
  |   Object myProperty;
  | 
  |   public getMyProperty() {
  |     // defaults to subclasses
  |      return myProperty;
  |   }
  | }
  | 


  | interface UserService {
  |   login();
  | }
  | 


  | @Stateful
  | class UserManager extends BusinessManager implements UserService {
  |   login() { ... };
  |   
  | // overrides default BusinessManager behavior
  |   @Override
  |   save() {
  |     if (checkIfLoginIsUnique())
  |       super.save();
  |   }
  | }
  | 

When I write Session Beans with no inheritance, everything works fine, but with inheritance, I can't get page rendering work, because JSF can't find superclass properties that holds bean states, and even superclass methods.


  | com.sun.facelets.tag.TagAttributeException: index.xhtml @14,44
  | test="#{empty myBean.myProperty}": Bean: myBean$$EnhancerByCGLIB$$e16dcde2, property: myProperty
  | 


  | java.lang.IllegalArgumentException: method not found: myMethod for component: myBean (check that it is declared on the session bean business interface)
  | ...
  | java.lang.NoSuchMethodException: MyService$$EnhancerByCGLIB$$e16dcde2.myMethod()
  | 

Any Help?
Thanx,
Fábio.

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

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




More information about the jboss-user mailing list