Hi Thomas, still using some Jetspeed-1 code which relies on extending ActionEvent, but things will become more transparent (and more clean).
Making use of the functional interface just straight as in your code might be the best choice keeping some valuable name conventions (java Consumer interface definition might be similar). But go ahead, we'll test ;-) ! Best regards, Georg Von: "Jeffery Painter" <[email protected]> An: "Turbine Developers List" <[email protected]> Datum: 03.03.2019 21:29 Betreff: Re: Change modules to interfaces Hi Thomas, I have never done anything more than extend the VelocitySecureAction or the o.a.t.m.Action class. I presume that adapting to this as an interface instead of base class would not be too much work to update. I would say go ahead, and I am happy to give it a try - Jeff > Hi folks, > > I finally found the time to try something I planned to do for Turbine > 4.0 already. I changed all modules (Action, Page, Screen,...) to be > (functional) interfaces instead of base classes. This works fine but > results in some methods to be public that were protected before. > > The advantage is that the whole module and loader code is much cleaner > and simpler now and less spread over the different classes. > > Before I commit this, I wanted to ask if any of your code heavily relies > on the old behavior? > > Bye, Thomas > > Example for Action: > > --8<-- > @FunctionalInterface > public interface Action extends Assembler > { > /** Prefix for action related classes and templates */ > String PREFIX = "actions"; > > /** Property for the size of the module cache if caching is on */ > String CACHE_SIZE_KEY = "action.cache.size"; > > /** The default size for the action cache */ > int CACHE_SIZE_DEFAULT = 20; > > /** Represents Action Objects */ > String NAME = "action"; > > /** > * A subclass must implement this method to perform itself. The > * Action can also set the screen that is associated with {@link > PipelineData}. > * > * @param pipelineData Turbine information. > * @throws Exception a generic exception. > */ > void doPerform(PipelineData pipelineData) throws Exception; > > /** > * Subclasses can override this method to add additional > * functionality. > * > * @param pipelineData Turbine information. > * @throws Exception a generic exception. > */ > default void perform(PipelineData pipelineData) throws Exception > { > doPerform(pipelineData); > } > } > --8<-- > > Example for ActionLoader: > > --8<-- > public class ActionLoader > extends GenericLoader<Action> > { > /** The single instance of this class. */ > private static ActionLoader instance = new ActionLoader(); > > /** > * These ctor's are private to force clients to use getInstance() > * to access this class. > */ > private ActionLoader() > { > super(Action.class, > () -> Turbine.getConfiguration().getInt(Action.CACHE_SIZE_KEY, > Action.CACHE_SIZE_DEFAULT)); > } > > /** > * Attempts to load and execute the external action. > * > * @param pipelineData Turbine information. > * @param name Name of object that will execute the action. > * @throws Exception a generic exception. > */ > @Override > public void exec(PipelineData pipelineData, String name) > throws Exception > { > getAssembler(name).perform(pipelineData); > } > > /** > * The method through which this class is accessed. > * > * @return The single instance of this class. > */ > public static ActionLoader getInstance() > { > return instance; > } > } > --8<-- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
smime.p7s
Description: S/MIME Cryptographic Signature
