Results 1 to 4 of 4

Thread: how to inject a prototype into a sigleton with annotations.

  1. #1

    Default how to inject a session 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 at 06:06 PM.

  2. #2

    Default

    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 at 06:06 PM.

  3. #3

    Default

    can anybody answer if it is possible or not?

  4. #4

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •