Announcement Announcement Module
Collapse
No announcement yet.
how to inject a prototype into a sigleton with annotations. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to inject a prototype into a sigleton with annotations.

    I have a "singleton" bean and i have a "session" bean. I need to autowire the "session" bean into the "singleton" bean. I know how to do this using the XML configuration. I don't know how to do the same using annotations (similar to using aop-proxy). I am using spring 2.5.6.SEC01.

    Both the beans are annotated appropriately.

    Please let me know how can i do this or point me to appropriate document that explains it.

    Thanks
    Srikanth
    Last edited by smadarapu; May 24th, 2010, 07:06 PM.

  • #2
    FYI:
    I have marked my prototype bean with @Scope("session"), @Service annotations.

    In my singleton service (which is marked with @Service annotation) has a setter, that takes the parameter of type of the session bean, and has been marked with @Autowired annotation.
    Last edited by smadarapu; May 24th, 2010, 07:06 PM.

    Comment


    • #3
      can anybody answer if it is possible or not?

      Comment


      • #4
        I know with Spring 3 you can use either:

        Code:
        @Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.INTERFACES)
        or:

        Code:
        @Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
        INTERFACES works if the bean implements an interface, and creates a JDK dynamic proxy. TARGET_CLASS will work without the bean implementing an interface, and creates a CGLIB proxy.

        I don't know if this will work with Spring 2.5.6.

        Comment

        Working...
        X