[nanocontainer-scm] [jira] Updated: (NANO-138) Be able to access ComponentAdapter in Groovy Builder
"Mauro Talevi (JIRA)" <jira-yCVjj/[email protected]> Sat, 11 Jun 2005 19:54:43 -0500 (CDT)
| Newsgroups | gmane.comp.java.nanocontainer.cvs |
|---|---|
| Message-ID | <24884705.1118537683139.JavaMail.haus-jira@codehaus01.managed.contegix.com> |
[ http://jira.codehaus.org/browse/NANO-138?page=all ]
Mauro Talevi updated NANO-138:
------------------------------
Component: (was: core)
groovy
> Be able to access ComponentAdapter in Groovy Builder
> ----------------------------------------------------
>
> Key: NANO-138
> URL: http://jira.codehaus.org/browse/NANO-138
> Project: NanoContainer
> Type: Wish
> Components: groovy
> 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