You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Jim Marino <jm...@myromatours.com> on 2006/07/15 07:12:47 UTC

constructor-based autowiring

I've checked in support for constructor-based autowiring. System  
components can now do the following:

    private static class FooImpl implements Foo {
         private Bar ref;

         public FooImpl(@Autowire Bar ref) {
             this.ref = ref;
         }

     }

When creating FooImpl, the runtime will pass an autowired Bar to the  
constructor.

Jim
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: constructor-based autowiring

Posted by Jeremy Boynes <jb...@apache.org>.
Cool!
It would be good to have a sweep through and clean up the system  
services as well as the samples.
I'll start on the loaders.

--
Jeremy

On Jul 14, 2006, at 10:12 PM, Jim Marino wrote:

> I've checked in support for constructor-based autowiring. System  
> components can now do the following:
>
>    private static class FooImpl implements Foo {
>         private Bar ref;
>
>         public FooImpl(@Autowire Bar ref) {
>             this.ref = ref;
>         }
>
>     }
>
> When creating FooImpl, the runtime will pass an autowired Bar to  
> the constructor.
>
> Jim
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: constructor-based autowiring

Posted by Jim Marino <jm...@myromatours.com>.
Let me take a look...

On Jul 15, 2006, at 8:16 AM, Jeremy Boynes wrote:

> I have a problem with ComponentLoader - when I use:
>     public ComponentLoader(@Autowire LoaderRegistry registry,
>                            @Autowire StAXPropertyFactory  
> propertyFactory) {
>     }
>
> I get:
> testBoot2Deployment 
> (org.apache.tuscany.core.deployer.BootstrapDeployerTestCase)  Time  
> elapsed: 0.07 sec  <<< ERROR!
> org.apache.tuscany.core.implementation.processor.AmbiguousConstructorE 
> xception: org.apache.tuscany.spi.loader.StAXPropertyFactory
>         at  
> org.apache.tuscany.core.implementation.processor.HeuristicPojoProcesso 
> r.calcConstructor(HeuristicPojoProcessor.java:186)
>         at  
> org.apache.tuscany.core.implementation.processor.HeuristicPojoProcesso 
> r.visitEnd(HeuristicPojoProcessor.java:136)
>         at  
> org.apache.tuscany.core.implementation.IntrospectionRegistryImpl.intro 
> spect(IntrospectionRegistryImpl.java:106)
>         at  
> org.apache.tuscany.core.implementation.system.loader.SystemComponentTy 
> peLoader.loadByIntrospection(SystemComponentTypeLoader.java:82)
>         ...
>
> Any ideas?
> --
> Jeremy
>
> On Jul 14, 2006, at 10:12 PM, Jim Marino wrote:
>
>> I've checked in support for constructor-based autowiring. System  
>> components can now do the following:
>>
>>    private static class FooImpl implements Foo {
>>         private Bar ref;
>>
>>         public FooImpl(@Autowire Bar ref) {
>>             this.ref = ref;
>>         }
>>
>>     }
>>
>> When creating FooImpl, the runtime will pass an autowired Bar to  
>> the constructor.
>>
>> Jim
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: constructor-based autowiring

Posted by Jeremy Boynes <jb...@apache.org>.
On Jul 15, 2006, at 8:35 AM, Jeremy Boynes wrote:

> That got me past that but I now get an NPE from PojoOjectFactory  
> because all entries in initializerFactories are null.
> Can you jump onto IRC?
>

This turned out to be two things:
an @Constructor annotation needed to be present (it shouldn't)
names specified in the @Constructor annotation were being ignored

This is fixed in r422257.
--
Jeremy


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: constructor-based autowiring

Posted by Jeremy Boynes <jb...@apache.org>.
That got me past that but I now get an NPE from PojoOjectFactory  
because all entries in initializerFactories are null.
Can you jump onto IRC?

--
Jeremy
On Jul 15, 2006, at 8:25 AM, Jim Marino wrote:

> Here's the issue: if there is no @Constructor annotation, it  
> currently attempts to heuristically determine the params, ignoring  
> @Autowire. I should probably make the heuristic processor be  
> smarter and understand this.  In the meantime, can you put  
> @Constructor (no name attribute) on the class?
>
> Jim
>
>
> On Jul 15, 2006, at 8:16 AM, Jeremy Boynes wrote:
>
>> I have a problem with ComponentLoader - when I use:
>>     public ComponentLoader(@Autowire LoaderRegistry registry,
>>                            @Autowire StAXPropertyFactory  
>> propertyFactory) {
>>     }
>>
>> I get:
>> testBoot2Deployment 
>> (org.apache.tuscany.core.deployer.BootstrapDeployerTestCase)  Time  
>> elapsed: 0.07 sec  <<< ERROR!
>> org.apache.tuscany.core.implementation.processor.AmbiguousConstructor 
>> Exception: org.apache.tuscany.spi.loader.StAXPropertyFactory
>>         at  
>> org.apache.tuscany.core.implementation.processor.HeuristicPojoProcess 
>> or.calcConstructor(HeuristicPojoProcessor.java:186)
>>         at  
>> org.apache.tuscany.core.implementation.processor.HeuristicPojoProcess 
>> or.visitEnd(HeuristicPojoProcessor.java:136)
>>         at  
>> org.apache.tuscany.core.implementation.IntrospectionRegistryImpl.intr 
>> ospect(IntrospectionRegistryImpl.java:106)
>>         at  
>> org.apache.tuscany.core.implementation.system.loader.SystemComponentT 
>> ypeLoader.loadByIntrospection(SystemComponentTypeLoader.java:82)
>>         ...
>>
>> Any ideas?
>> --
>> Jeremy
>>
>> On Jul 14, 2006, at 10:12 PM, Jim Marino wrote:
>>
>>> I've checked in support for constructor-based autowiring. System  
>>> components can now do the following:
>>>
>>>    private static class FooImpl implements Foo {
>>>         private Bar ref;
>>>
>>>         public FooImpl(@Autowire Bar ref) {
>>>             this.ref = ref;
>>>         }
>>>
>>>     }
>>>
>>> When creating FooImpl, the runtime will pass an autowired Bar to  
>>> the constructor.
>>>
>>> Jim
>>>
>>> -------------------------------------------------------------------- 
>>> -
>>> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: constructor-based autowiring

Posted by Jim Marino <jm...@myromatours.com>.
Here's the issue: if there is no @Constructor annotation, it  
currently attempts to heuristically determine the params, ignoring  
@Autowire. I should probably make the heuristic processor be smarter  
and understand this.  In the meantime, can you put @Constructor (no  
name attribute) on the class?

Jim


On Jul 15, 2006, at 8:16 AM, Jeremy Boynes wrote:

> I have a problem with ComponentLoader - when I use:
>     public ComponentLoader(@Autowire LoaderRegistry registry,
>                            @Autowire StAXPropertyFactory  
> propertyFactory) {
>     }
>
> I get:
> testBoot2Deployment 
> (org.apache.tuscany.core.deployer.BootstrapDeployerTestCase)  Time  
> elapsed: 0.07 sec  <<< ERROR!
> org.apache.tuscany.core.implementation.processor.AmbiguousConstructorE 
> xception: org.apache.tuscany.spi.loader.StAXPropertyFactory
>         at  
> org.apache.tuscany.core.implementation.processor.HeuristicPojoProcesso 
> r.calcConstructor(HeuristicPojoProcessor.java:186)
>         at  
> org.apache.tuscany.core.implementation.processor.HeuristicPojoProcesso 
> r.visitEnd(HeuristicPojoProcessor.java:136)
>         at  
> org.apache.tuscany.core.implementation.IntrospectionRegistryImpl.intro 
> spect(IntrospectionRegistryImpl.java:106)
>         at  
> org.apache.tuscany.core.implementation.system.loader.SystemComponentTy 
> peLoader.loadByIntrospection(SystemComponentTypeLoader.java:82)
>         ...
>
> Any ideas?
> --
> Jeremy
>
> On Jul 14, 2006, at 10:12 PM, Jim Marino wrote:
>
>> I've checked in support for constructor-based autowiring. System  
>> components can now do the following:
>>
>>    private static class FooImpl implements Foo {
>>         private Bar ref;
>>
>>         public FooImpl(@Autowire Bar ref) {
>>             this.ref = ref;
>>         }
>>
>>     }
>>
>> When creating FooImpl, the runtime will pass an autowired Bar to  
>> the constructor.
>>
>> Jim
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: constructor-based autowiring

Posted by Jeremy Boynes <jb...@apache.org>.
I have a problem with ComponentLoader - when I use:
     public ComponentLoader(@Autowire LoaderRegistry registry,
                            @Autowire StAXPropertyFactory  
propertyFactory) {
     }

I get:
testBoot2Deployment 
(org.apache.tuscany.core.deployer.BootstrapDeployerTestCase)  Time  
elapsed: 0.07 sec  <<< ERROR!
org.apache.tuscany.core.implementation.processor.AmbiguousConstructorExc 
eption: org.apache.tuscany.spi.loader.StAXPropertyFactory
         at  
org.apache.tuscany.core.implementation.processor.HeuristicPojoProcessor. 
calcConstructor(HeuristicPojoProcessor.java:186)
         at  
org.apache.tuscany.core.implementation.processor.HeuristicPojoProcessor. 
visitEnd(HeuristicPojoProcessor.java:136)
         at  
org.apache.tuscany.core.implementation.IntrospectionRegistryImpl.introsp 
ect(IntrospectionRegistryImpl.java:106)
         at  
org.apache.tuscany.core.implementation.system.loader.SystemComponentType 
Loader.loadByIntrospection(SystemComponentTypeLoader.java:82)
         ...

Any ideas?
--
Jeremy

On Jul 14, 2006, at 10:12 PM, Jim Marino wrote:

> I've checked in support for constructor-based autowiring. System  
> components can now do the following:
>
>    private static class FooImpl implements Foo {
>         private Bar ref;
>
>         public FooImpl(@Autowire Bar ref) {
>             this.ref = ref;
>         }
>
>     }
>
> When creating FooImpl, the runtime will pass an autowired Bar to  
> the constructor.
>
> Jim
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org