Fork me on GitHub

Odds and Ends

Setting Up A Logger

The YAAFI container expects that you setup the logging facilty to be used. The Avalon Service Framework provides wrappers for commonly used loggers such as

  • JDK 1.4 logger
  • Log4J logger
  • LogKit logger
  • Console logger
  • Null logger

The following examples shows how to use a Log4J logger assuming that the configuration is located in the "conf" directory and tells Log4J to monitor the configuration file to detect changes of the trace level.

Main cli = new Main(args)
String log4jConfig = cli.makeAbsolutePath( System.getProperty("log4j.configuration", "./conf/log4j.properties") );
PropertyConfigurator.configureAndWatch( log4jConfig, 2000 );
cli.setLogger( new Log4JLogger( Logger.getLogger("main") ) );
          

Looking up a Service

Using an Avalon container requires your application to lookup services during runtime. This functionality is exposed through the "ServiceManager" interface. The real question is how to get hold of a "ServiceManager" interface without polluting the whole application with Avalon dependencies. Unfortunately there is no simple answer to that

  • You can keep a "ServiceManager" instance from initializing the YAAFI container.
  • Your service can implement the "Servicable" interface to get an instance of a "ServiceManager".
  • Your can lookup the services using the ServiceManagerService

Dynamic Reconfiguration

A reconfiguration can be triggered by your application code or by the ReconfigurationService which monitors the component configuration file.