File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes New to Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "New to Spring" Watch "New to Spring" New topic
Author

New to Spring

Yogesh Kumar Yadav
Greenhorn

Joined: Jan 09, 2010
Posts: 7
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

Joined: Oct 31, 2000
Posts: 527
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.

SCJP 1.5, SCEA, ICED (287,484,486)
Vivek K Singh
Ranch Hand

Joined: Dec 22, 2009
Posts: 85

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)


SCJP 6
XiaoM Kevin
Greenhorn

Joined: Dec 29, 2009
Posts: 2
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>
 
Don't get me started about those stupid light bulbs.
 
subject: New to Spring
 
Similar Threads
DI with beans from an ejb-jar
Reading property files
Unable to deploy ear :NoClassDefFoundError
Third party place for EJB.
Can we keep style sheet outside the ear?