wood burning stoves*
The moose likes Spring and the fly likes Spring Contaniner object - how to get in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring Contaniner object - how to get in java" Watch "Spring Contaniner object - how to get in java" New topic
Author

Spring Contaniner object - how to get in java

Tanu Gulati
Ranch Hand

Joined: Oct 06, 2008
Posts: 113

hi ,
I have defined a class in spring-Config.xml as below
<bean id="testClass" class="com.test.TestClass" scope="session">
<aop:scoped-proxy />
</bean>

defining it in Spring-Config.xml make sure that spring will create an object of it and will use it. now while writing the code in my utility class. I also want to access this instance and use it.
can I get and the same instance which spring has created. if yes please let me know how to get this same instance in java.


thanks,


thanks
Tanu Gulati
Shasi Mitra
Ranch Hand

Joined: Nov 27, 2008
Posts: 101

Try this
http://blog.imaginea.com/making-a-spring-bean-applicationcontext-aware/
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6



Actually, that isn't necessary because you are using the <aop:scoped-proxy> tag.

Just create a bean for your utility class and inject it into the testClass, just like any other dependency injection.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring Contaniner object - how to get in java