[nanocontainer-scm] [jira] Created: (NANO-138) Be able to access ComponentAdapter in Groovy Builder
"Michael Rimov (JIRA)" <jira-yCVjj/[email protected]> Fri, 10 Jun 2005 21:41:42 -0500 (CDT)
| Newsgroups | gmane.comp.java.nanocontainer.cvs |
|---|---|
| Message-ID | <9493636.1118457702653.JavaMail.haus-jira@codehaus01.managed.contegix.com> |
Be able to access ComponentAdapter in Groovy Builder
----------------------------------------------------
Key: NANO-138
URL: http://jira.codehaus.org/browse/NANO-138
Project: NanoContainer
Type: Wish
Components: core
Versions: 1.0-beta-5
Reporter: Michael Rimov
Currently, it doesn't appear possible to access a ComponentAdapter from within the Groovy builder syntax. The following test case illustrates an 'ideal' for modifying the component adapter. Of course, I'd be happy to do it nearly any way using the builder syntax. :)
-Mike (R)
public void testBuildWithComponentAdapter() {
Reader script = new StringReader(""
+ "import java.text.SimpleDateFormat;\n"
+ "import com.genfw.core.container.BeanNanoDecorator;\n"
+ "import org.picocontainer.defaults.*\n"
+ "\n"
+ "builder = new org.nanocontainer.script.groovy.NanoContainerBuilder(new BeanNanoDecorator())\n"
+ "pico = builder.container() { \n"
+ " component([ class: SimpleDateFormat) {\n"
+ " //If ComponentAdapter was returned -- then modification would be possible."
+ " properties([\"lenient\":false, \"2DigitYearStart\":new Date(0)\n]]])\n"
+ " }\n"
+ "}");
ObjectReference predefined = new SimpleReference();
predefined.set(new DefaultPicoContainer(new BeanPropertyComponentAdapterFactory(new DefaultComponentAdapterFactory())));
ScriptedContainerBuilder builder = new GroovyContainerBuilder(script, Thread.currentThread().getContextClassLoader());
builder.buildContainer(predefined,null,null, false);
PicoContainer rootContainer = (PicoContainer)predefined.get();
assertNotNull(rootContainer);
assertNotNull(rootContainer.getComponentAdapter(SimpleDateFormat.class));
assertEquals(BeanPropertyComponentAdapter.class, rootContainer.getComponentAdapter(SimpleDateFormat.class).getClass());
SimpleDateFormat dateFormat = (SimpleDateFormat)rootContainer.getComponentInstance(SimpleDateFormat.class);
assertNotNull(dateFormat);
//Currently fails
//assertEquals(false, dateFormat.isLenient());
//assertEquals(new Date(0), dateFormat.get2DigitYearStart());
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira