Results 1 to 3 of 3

Thread: lookup-method w/ annotations?

  1. #1
    Join Date
    Dec 2005
    Posts
    9

    Default lookup-method w/ annotations?

    Is there currently a way to do lookup method injection with annotations or some way to create/get a new prototype instance inside a singleton bean?

    something like this except with annotations

  2. #2

    Default

    All you need to do is create a default implementation and annotate it with @Scope("prototype")

    See: http://static.springframework.org/sp...scope-resolver

    If you also annotate it with @Component, then the only thing you need to add to your Spring context is <context:component-scan base-package="com.mycompany" /> and Spring will find and add your prototype implementation.

  3. #3
    Join Date
    Dec 2005
    Posts
    9

    Default

    Quote Originally Posted by jamestastic View Post
    All you need to do is create a default implementation and annotate it with @Scope("prototype")

    See: http://static.springframework.org/sp...scope-resolver

    If you also annotate it with @Component, then the only thing you need to add to your Spring context is <context:component-scan base-package="com.mycompany" /> and Spring will find and add your prototype implementation.
    That alone won't work. It would only get you 1 instance of prototype per singleton. Figured it out, have to configure the scope proxy, although the <context: scoped-proxy> attribute doesn't seem to proxy prototypes by default, only session/request.

Posting Permissions

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