Authors: Paul Hammant
Apache's Avalon's component 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 (contextualized depenedency lookup) design.
This document details how to do this manually.
public interface Engine { void runEngine(); } public interface Persistor { void persist(String key, Object data); }
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); } }
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); } }
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(); } }