Re: [picocontainer-dev] ConfigParameterTestCase / ConfigParameter

Paul Hammant <[email protected]>
Newsgroups gmane.comp.java.picocontainer.devel
Message-ID <[email protected]>
So the test I really want to pass in ConfigParameterTestCase  is

     public void testComponentInstantiation2() {
         DefaultPicoContainer properties = new DefaultPicoContainer();
         properties.addConfig("longValue", "239");
         properties.addConfig("doubleParameter", "17.95");
         properties.addConfig("stringParameter", "foo.bar");
         properties.addConfig("fileParameter", "bar.txt");

         DefaultPicoContainer container = new DefaultPicoContainer 
(properties);
         container.as(Characteristics.USE_NAMES).addComponent 
(ExternallyConfiguredComponent.class);

         ExternallyConfiguredComponent component =  
container.getComponent(ExternallyConfiguredComponent.class);
		
         assertNotNull(component);
         assertEquals(239,component.getLongValue());
         assertEquals("foo.bar",component.getStringParameter());
         assertEquals(new File("foo.txt"),component.getFileParameter());
         assertEquals(17.95,component.getDoubleParameter(),0);
     }

It basically assumes that any parameter matching by name could be  
automatically type converted from (implicitly) string to the correct  
type.

I'd love to stop using the XSteam converters, and just use the miriad  
of built in converters in the JDK ...

     Currency.getInstance(paramValue)
     Float.valueOf(paramValue)

... etc.

This would allow a massive simplification of the implementation, and  
meet the my need, Konstantin's original need, and the needs in the  
lastest thread.

-ph

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.