Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: @ScopedProxy or annotation equivalent of <aop:scoped-proxy/>

  1. #1
    Join Date
    Aug 2007
    Posts
    3

    Default @ScopedProxy or annotation equivalent of <aop:scoped-proxy/>

    Are there any plans to introduce an Java annotation equivalent of the <aop:scoped-proxy/> at some point?

  2. #2
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    It seems to exist but only as part of Spring Java Config.

    Joerg
    This post can contain insufficient information.

  3. #3
    Join Date
    Aug 2007
    Posts
    3

    Default

    Yes, I found that too. However it's not really what I was looking for. That would require me to write a separate Java class similar to using the separate XML based configuration. I don't see the advantage. When you write the annotations directly into the original class it keeps everything in one place so it's simpler.

  4. #4
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    Quote Originally Posted by jdhwpgmbca View Post
    That would require me to write a separate Java class similar to using the separate XML based configuration.
    I can't follow you. Why could you not just add the annotation to the actual to-be-proxied class?

    Joerg
    This post can contain insufficient information.

  5. #5
    Join Date
    Dec 2005
    Location
    Croatia
    Posts
    192

    Default

    I too am interested in this.

    Quote Originally Posted by Jörg Heinicke View Post
    Why could you not just add the annotation to the actual to-be-proxied class?
    Spring Java Config annotations cannot be used in this way, they are used only as a part of java class that represents the whole java configuration, as opposed to xml config.

    So, we need something like @ScopedProxy that works on individual beans, together with @Component and @Scope.

  6. #6
    Join Date
    Dec 2005
    Location
    Croatia
    Posts
    192

    Default

    After some digging I found the solution. You define component-scan definition like this:
    HTML Code:
    <context:component-scan base-package="your.package" scoped-proxy="interfaces"/>
    All scoped beans will then be automaticaly proxied. It seems that the default value of "scoped-proxy" attribute is "no", which would mean no proxies would be created.

    The possible values for "scoped-proxy" attribute are: "no", "interfaces" and "targetClass".


    Regards,
    Igor.

  7. #7
    Join Date
    Aug 2007
    Posts
    3

    Default

    <context:component-scan base-package="your.package" scoped-proxy="interfaces"/>

    Thanks, that works for me. I do like the @ScopedProxy annotation idea better though. This works but you need to be careful to keep your proxied classes separate in some way from your non-proxied ones - probably a different package.
    Last edited by jdhwpgmbca; Nov 22nd, 2007 at 09:40 PM.

  8. #8

    Default scoped-proxy="interfaces" creates 'standard JDK proxies'

    Don't forget that scoped-proxy="interfaces" creates 'standard JDK proxies'

    This is different from the default for "<aop:scoped-proxy/>" which creates CGLIB based proxies.

    As a result your scoped bean needs to implement an interface and all your collaborators have to reference the interface.

    http://static.springframework.org/sp...ection-proxies

  9. #9
    Join Date
    Oct 2007
    Posts
    142

    Question @scope and jsp

    Hi

    When you place a bean in the session using the @scope.
    How do you access to it in the jsp page ?

    I would like to kwon if a value is store in the http session and how the get the name of the object in the session

    Regards

  10. #10
    Join Date
    Jul 2012
    Posts
    4

    Default

    what sense does it make to use request/session-scoped beans without <aop:scoped-proxy/>? Shouldn't Spring either activate that as a default or throw an exception? I currently have "request" scoped beans running that get passed from request to request.... (Spring 3.0.7)

Posting Permissions

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