2 Replies Latest reply on Mar 21, 2006 8:07 PM by chung chung

    confusion - JavassistTypeInfoFactory can Overloaded construc

    chung chung Newbie

      JavassistTypeInfoFactory sample 1: is work

      <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
       xmlns="urn:jboss:bean-deployer:2.0">
       <bean name="BeanInstanceFactory" class="org.jboss.example.microcontainer.constructor.ConstructorBeanInstanceFactory" mode="On Demand" />
       <bean name="InjectBean" class="org.jboss.example.microcontainer.constructor.ConstructorBean" mode="On Demand">
       <constructor factoryMethod="newInstance">
       <factory bean="BeanInstanceFactory" state="Start"/>
       <parameter class="int" >9999</parameter>
       </constructor>
       </bean>
       <bean name="TestInstanceBean" class="org.jboss.example.microcontainer.constructor.ConstructorBean" >
       <constructor>
       <parameter class="java.lang.Object"><inject bean="InjectBean" state="Create"/></parameter>
       </constructor>
       </bean>
       <bean name="TestInstanceBean1" class="org.jboss.example.microcontainer.constructor.ConstructorBean" >
       <constructor>
       <parameter><inject bean="InjectBean" state="Create"/></parameter>
       </constructor>
       </bean>
       <bean name="AnyTypeBean" class="org.jboss.example.microcontainer.constructor.ConstructorBean">
       <constructor factoryMethod="getConstructorBean">
       <factory>
       <javabean xmlns="urn:jboss:javabean:1.0" class="org.jboss.example.microcontainer.constructor.ConstructorBeanJavaBeanFactory">
       <property name="num">5555</property>
       </javabean>
       </factory>
       </constructor>
       </bean>
      </deployment>
      
      AbstractConfiguration
       protected TypeInfoFactory createDefaultTypeInfoFactory() throws Throwable
       {
      
       //return new IntrospectionTypeInfoFactory();
       // TOMYTEST - javassistReflect
       return new JavassistTypeInfoFactory();
      
       }
      JavaBeanSchemaInitializer
      
       /** The type info factory */
       //protected static final TypeInfoFactory typeInfoFactory = new IntrospectionTypeInfoFactory();
       // TOMYTEST - javassistReflect
       protected static final TypeInfoFactory typeInfoFactory = new JavassistTypeInfoFactory();
      
      PrimitiveInfo
      
       /** The type info factory */
       //protected static final TypeInfoFactory typeInfoFactory = new IntrospectionTypeInfoFactory();
       // TOMYTEST - javassistReflect
       protected static final TypeInfoFactory typeInfoFactory = new JavassistTypeInfoFactory();
      
      

      IntrospectionTypeInfoFactory sample 2 : DEPLOYMENTS IN ERROR: Name -> Error

      TestInstanceBean1 -> java.lang.IllegalArgumentException: Wrong arguments. new for target java.lang.reflect.Constructor expected=[int] actual=[org.jboss.example.microcontainer.constructor.ConstructorBean]

      <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
       xmlns="urn:jboss:bean-deployer:2.0">
       <bean name="BeanInstanceFactory" class="org.jboss.example.microcontainer.constructor.ConstructorBeanInstanceFactory" mode="On Demand" />
       <bean name="InjectBean" class="org.jboss.example.microcontainer.constructor.ConstructorBean" mode="On Demand">
       <constructor factoryMethod="newInstance">
       <factory bean="BeanInstanceFactory" state="Start"/>
       <parameter class="int" >9999</parameter>
       </constructor>
       </bean>
       <bean name="TestInstanceBean" class="org.jboss.example.microcontainer.constructor.ConstructorBean" >
       <constructor>
       <parameterclass="java.lang.Object"><inject bean="InjectBean" state="Create"/></parameter>
       </constructor>
       </bean>
       <bean name="TestInstanceBean1" class="org.jboss.example.microcontainer.constructor.ConstructorBean" >
       <constructor>
       <parameter><inject bean="InjectBean" state="Create"/></parameter>
       </constructor>
       </bean>
       <bean name="AnyTypeBean" class="org.jboss.example.microcontainer.constructor.ConstructorBean">
       <constructor factoryMethod="getConstructorBean">
       <factory>
       <javabean xmlns="urn:jboss:javabean:1.0" class="org.jboss.example.microcontainer.constructor.ConstructorBeanJavaBeanFactory">
       <property name="num">5555</property>
       </javabean>
       </factory>
       </constructor>
       </bean>
      </deployment>
      
      AbstractConfiguration
       protected TypeInfoFactory createDefaultTypeInfoFactory() throws Throwable
       {
      
       return new IntrospectionTypeInfoFactory();
       // TOMYTEST - javassistReflect
       //return new JavassistTypeInfoFactory();
      
       }
      JavaBeanSchemaInitializer
      
       /** The type info factory */
       protected static final TypeInfoFactory typeInfoFactory = new IntrospectionTypeInfoFactory();
       // TOMYTEST - javassistReflect
       //protected static final TypeInfoFactory typeInfoFactory = new JavassistTypeInfoFactory();
      
      PrimitiveInfo
      
       /** The type info factory */
       protected static final TypeInfoFactory typeInfoFactory = new IntrospectionTypeInfoFactory();
       // TOMYTEST - javassistReflect
       //protected static final TypeInfoFactory typeInfoFactory = new JavassistTypeInfoFactory();
      
      

      ConstructorBean is
      public class ConstructorBean {
       String hello ="helloConstructorBean";
       public ConstructorBean(int integer)
       {
       System.out.println("ConstructorBean(int) with " + integer);
       }
       public ConstructorBean(String string, int integer)
       {
       System.out.println("ConstructorBean(String, int) with " + string + " and " + integer);
       }
       public ConstructorBean(String string, long l)
       {
       System.out.println("ConstructorBean(String, long) with " + string + " and " + l);
       }
       public ConstructorBean(Object o)
       {
       System.out.println("ConstructorBean(Object) with " + o );
       }
      ......
      

      parameterType in bean-deployer_2_0.xsd haven't use="required" .
      so MC can Overloaded constructor ?