constructing a CDI '@Inject'able bean with constructor arguments

32 views
Skip to first unread message

Vamsee Lakamsani

unread,
May 3, 2014, 12:00:37 AM5/3/14
to cdiadv...@googlegroups.com

Hi,

I 'm experimenting with CDI in TomEE 1.6 as an alternative to Spring DI.  In spring I can setup a custom data source bean like this:

<bean name="dataSource" class="my.custom.DBDataSource">

 <constructor-arg index="0" name="arg1" value="val1" />

<constructor-arg index="0" name="arg2" value="val2" />

</bean>

What is the CDI equivalent way of doing it? Use a factory with @Produces or a custom annotation with params? I want to be able to @Inject the data source at other places in the code, run unit tests via JUnit etc. 

Reply all
Reply to author
Forward
0 new messages