[jboss-jira] [JBoss JIRA] Closed: (JBMICROCONT-380) MC chooses the wrong constructor to build a bean from metadata

Adrian Brock (JIRA) jira-events at lists.jboss.org
Thu Nov 6 10:23:21 EST 2008


     [ https://jira.jboss.org/jira/browse/JBMICROCONT-380?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adrian Brock closed JBMICROCONT-380.
------------------------------------

    Resolution: Rejected


We've been through this discussion before.
If the constructor is ambiguous (number of parameters) then you should specify which one you
want to use by specifying the type on the parameter.
http://www.jboss.org/file-access/default/members/jbossmc/freezone/docs/2.0.x/userGuide/ch10s02.html

This is a design decision within the MC. 

By choosing the constructor early based on the
number of parameters we can avoid being more verbose in
having to specifying the types for string values or anonymous injection.
This has the drawback of being more verbose when there are multiple constructors
within the same no of parameters (a 5% use case compared with the more normal 95% cases).

If you want to try implement some kind of fuzzy match by looking at the
parameter values then go ahead, but that is a feature request.

You'll find its a lot more difficult than this example makes it look,
if not impossible (without hacks) because in general the retrieval of the value
(which can be implemented in anyway you like) needs to know the type of the parameter upfront:
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/microcontainer/trunk/kernel/src/main/java/org/jboss/beans/metadata/spi/ValueMetaData.java?revision=77665&view=markup

Object getValue(TypeInfo info, ClassLoader cl) throws Throwable;

> MC chooses the wrong constructor to build a bean from metadata
> --------------------------------------------------------------
>
>                 Key: JBMICROCONT-380
>                 URL: https://jira.jboss.org/jira/browse/JBMICROCONT-380
>             Project: JBoss Microcontainer
>          Issue Type: Bug
>    Affects Versions: JBossMC.2.0.0.CR5
>            Reporter: Carlo de Wolf
>            Priority: Critical
>
> Given the following piece of xml, MC can pick the wrong constructor to instantiate BeanMetaDataDeployer:
>    <bean name="BeanMetaDataDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer">
>       <constructor><parameter><inject bean="jboss.kernel:service=Kernel"/></parameter></constructor>
>    </bean>
> java.lang.IllegalArgumentException: Wrong arguments. new for target java.lang.reflect.Constructor expected=[org.jboss.dependency.spi.Controller] actual=[org.jboss.kernel.Kernel]
> 	at org.jboss.reflect.plugins.introspection.ReflectionUtils.handleErrors(ReflectionUtils.java:395)
> 	at org.jboss.reflect.plugins.introspection.ReflectionUtils.newInstance(ReflectionUtils.java:153)
> 	at org.jboss.reflect.plugins.introspection.ReflectConstructorInfoImpl.newInstance(ReflectConstructorInfoImpl.java:106)
> 	at org.jboss.joinpoint.plugins.BasicConstructorJoinPoint.dispatch(BasicConstructorJoinPoint.java:80)
> 	at org.jboss.aop.microcontainer.integration.AOPConstructorJoinpoint.createTarget(AOPConstructorJoinpoint.java:276)
> 	at org.jboss.aop.microcontainer.integration.AOPConstructorJoinpoint.dispatch(AOPConstructorJoinpoint.java:97)
> 	at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
> ...

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list