This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
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

Win a copy of Elasticsearch in Action this week in the Big Data forum!
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

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 />

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.


Tanu Gulati
Shasi Mitra
Ranch Hand

Joined: Nov 27, 2008
Posts: 101

Try this
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17260

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.


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