• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New to Spring

 
Yogesh Kumar Yadav
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a question regarding the declaration of a bean ....

If I have a jar which is outside of my EAR and i want to get a handle or an instance of a bean from the outside jar ...
how can i have that ??? Is it the same as if I am working on a bean which is inside my EAR ....

I can add the outside jar and and then can configure the bean in my app-context.xml ?

I am little confused in this ...

Can anyone help ?
 
Anil Vupputuri
Ranch Hand
Posts: 527
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yogesh Kumar Yadav wrote:
If I have a jar which is outside of my EAR and i want to get a handle or an instance of a bean from the outside jar ...
how can i have that ??? Is it the same as if I am working on a bean which is inside my EAR ....

I can add the outside jar and and then can configure the bean in my app-context.xml ?

I am little confused in this ...

Can anyone help ?


Consider using separate EAR file for that outside jar. And EJB client in EAR as remote client then your EJB in jar (in new EAR) should have remote home interface and parameters passed should be pass-by-value.
 
Vivek K Singh
Ranch Hand
Posts: 85
Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yogesh, Yes you can.

Simply add the jar file as an external library and create a bean like you will do for any other class. (If the class is present in classpath and you can instantiate it from code, then, you can do it from spring)
 
XiaoM Kevin
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Absolute yes! For example,now i am using the apache commons-dbcp.jar,i just add this jar to the library.And i can config
the class org.apache.commons.dbcp.BasicDataSource in spring xml file as thsi:
<!-- Commons DBCP -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="xxx.jdbc.Driver"/>
<property name="url" value="xxx"/>
<property name="username" value="xx"/>
<property name="password" value="xx"/>
<property name="initialSize" value="30"/>
<property name="maxActive" value="300"/>
<property name="testOnBorrow" value="true"/>
</bean>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic