aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: Inject constructor using Blueprint
Date Tue, 25 Jun 2013 15:07:18 GMT

I believe you should be using the MutableBeanMetadata classes:

MutableBeanMetadata m = context.createMetadata(MutableBeanMetadata.class);
m.setClassName("org.mycompany.MyFactoryBean");
m.addArgument(createValue(context, id), null, 0);
….

At least that's what CXF uses in all it's namespace handlers.

Dan


On Jun 25, 2013, at 2:15 AM, Charles Moulliard <ch007m@gmail.com> wrote:

> Hi,
> 
> Aries Blueprint project allows to inject constructors parameters using
> BeanArgumentImpl. Here is an example of such usage :
> 
>        BeanMetadataImpl beanMetadata = (BeanMetadataImpl)
> context.createMetadata(BeanMetadata.class);
>        beanMetadata.setClassName("org.mycompany.MyFactoryBean");
>        beanMetadata.setFactoryMethod("doSomething");
>        beanMetadata.setId(id);
> 
>        BeanArgumentImpl argument = new BeanArgumentImpl();
>        argument.setIndex(0);
>        argument.setValue(createValue(context, id));
>        beanMetadata.addArgument(argument);
> 
> Unfortunately, with release 1.0 of Apache Blueprint, this class has been
> packaged with blueprint - parser which is a jar and not a bundle and even
> if I use wrap to generate a bundle, it cannot be used as such as we get on
> Apache Karaf a classcast exception
> 
> java.lang.ClassCastException:
> org.apache.aries.blueprint.reflect.BeanMetadataImpl cannot be cast to
> org.apache.aries.blueprint.reflect.BeanMetadataImpl
> at
> org.kie.aries.blueprint.namespace.ReleaseIdElementParser.parseElement(ReleaseIdElementParser.java:47)[120:org.kie.aries.blueprint:6.0.0.20130624-2122]
> 
> Question : How can we inject constructors parameters with Aries Blueprint
> 1.0 without using classes packaged under blueprint-parser ?
> 
> Regards,
> 
> -- 
> Charles Moulliard
> Apache Committer / Architect @RedHat
> Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Mime
View raw message