avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leo Simons <leosim...@apache.org>
Subject Re: Jini 2.0 Configuration Files
Date Sat, 04 Oct 2003 14:04:38 GMT
hammett wrote:
> Jini 2.0 was just released. It supports a new type of configuration
> The ConfigurationFile supports a subset of Java code
> Thoughs?

well....ugh! A *real* scripting language works much nicer IMNSHO....for 
example, you can use BeanShell to not support a subset of java, but a 
superset that is very clean!

One could also use javascript, python, ruby, whatever. Once you make the 
(sometimes, admittedly questionable) decision that your configuration is 
allowed to "act" directly on your component (as opposed to the 
conceptually very clean avalon-style configuration where a component is 
allowed to "read" from its configuration, but the configuration itself 
is passive), it makes no sense at all to invent a new language (be it 
Jelly, Droolz, xmlbeans, or Jini 2.0 config files).

Here's an example of how simple this actually is:
Object getComponent( Factory factory, Container container ) // fragment
     throws ConfigurationException
   ComponentEntry entry = factory.getEntry( /* ... */ );
   InputStream script = entry.getConfigScript();

   Interpreter i = new Interpreter();

     i.set( "entry", entry );
     i.set( "container", container );
     i.source( script ); // actual configuration at this point

     return i.get( "component" );
   catch( Error e )
     throw new ConfigurationException( e );
your config script might look like:
component = entry.getInstance();
component.setParameter( container.get( "someDependencyKey" ) );
component.setBlah( container.get( "somethingelse" ) );


- Leo

To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org

View raw message