Protected methods on Seam components
quilleashm Feb 14, 2007 3:35 PMHi all,
If I have a protected method in some circumstances on a Seam component I get an error when the method is called via a cglib proxy.
I get this exception thrown out of the cglib MethodProxy class.
throw new IllegalArgumentException("Protected method: " + sig1);
The class structure involved..
@Scope( ScopeType.STATELESS ) public abstract class ScreenActionComponent { public abstract void execute( ScreenActionMetadata screenActionMetadata, ScreenActionContext screenActionContext ); public abstract ScreenActionMetadata[] getScreenActionMetadata( ScreenActionContext screenActionContext ); }
public abstract class SingleItemScreenAction extends ScreenActionComponent { public final void execute( ScreenActionMetadata screenActionMetadata, ScreenActionContext screenActionContext ) { execute( screenActionContext ); } public final ScreenActionMetadata[] getScreenActionMetadata( ScreenActionContext screenActionContext ) { if ( isValidSelection( screenActionContext ) ) return new ScreenActionMetadata[]{ new DefaultScreenActionMetadata( getDisplay(), getTooltip(), getImage() ) }; else return new ScreenActionMetadata[ 0 ]; } protected abstract void execute( ScreenActionContext screenActionContext ); protected abstract boolean isValidSelection( ScreenActionContext screenActionContext ); protected abstract String getDisplay(); protected abstract String getTooltip(); protected abstract String getImage(); }
@Name( "deleteEntityScreenAction" ) public class DeleteEntityScreenAction extends SingleItemScreenAction { @In private Session referenceSession; public void execute( ScreenActionContext screenActionContext ) { // TODO } public boolean isValidSelection( ScreenActionContext screenActionContext ) { return !screenActionContext.getSelection().isEmpty(); } protected final String getDisplay() { return "Delete"; } protected final String getTooltip() { return "Logically deletes the selected items"; } protected final String getImage() { // TODO: return null; } }
Without the final modifiers on the DeleteEntityScreenAction getXXX methods I get the above exception when they are called from SingleItemScreenAction.getScreenActionMetadata(). But obviously with the final modifier I get no interception/bijection etc.
Wondered if this is a known limitation in cglib or not.
Cheers.
Mike.