Authors: paul
Overview
Apache's Avalon framework specification is enshrined in a number of interfaces. What this means is that the component writer has to implement them to designate their class as an Avalon component. PicoComponents require adaptation to fit the Avalon Framework (contextualzed lookup) design.
A simple example component
Example component APIs
public interface Engine { void runEngine(); } public interface Persistor { void persist(String key, Object data); }
A simple Pico implementation of the hypothetical engine.
public class EngineImpl implements Engine { Persistor persistor; String persistenceKey; Object persistable; public void EngineImpl(Persistor persistor, String persistenceKey) { this.persistor = persistor; this.persistorKey = persistorKey; persistable = new Object(); // not very 'heavy' we appreciate. } public void runEngine() { { persistor.persist(persistorKey, persistable); } }
The same component natively written for Apache Avalon
public class AvalonEngine implements Engine, Servicable, Configurable, Initializable { Persistor persistor; String persistenceKey; Object persistable; public void service (ServiceManager sm) throws ServiceException { this.persistor = (Persistor) sm.lookup("Persistor"); } public void configure(Configuration conf) { this.persistorKey = conf.getAttribute("persistorKey"); } public void initialize() { persistable = new Object(); // not very 'heavy' we appreciate. } public void runEngine() { { persistor.persist(persistorKey, persistable); } }
An alternate wrapping strategy for Apache Avalon compatability.
public class AvalonEngine implements Engine, Servicable, Configurable, Initializable { private Engine engine; // temporary private Persistor persistor; private String persistenceKey; public void service (ServiceManager sm) throws ServiceException { this.persistor = (Persistor) sm.lookup("Persistor"); } public void configure(Configuration conf) { this.persistorKey = conf.getAttribute("persistorKey"); } public void initialize() { engine = new EngineImpl(persistor persistenceKey); } public void runEngine() { { engine.runEngine(); } }
Labels
(None)
