Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring Contaniner object - how to get in java

 
Tanu Gulati
Ranch Hand
Posts: 113
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Shasi Mitra
Ranch Hand
Posts: 101
Flex Java Spring
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic