Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: Example @Resource

  1. #11
    Join Date
    Dec 2006
    Posts
    26

    Default Example @Resource

    Originally it was not there on my first try. It was left out, but things did not work so I put it there thinking that it would change something (or to see what it would do). I had the problem either way (with or without it).

    I thought I had commented that out (or removed) before posting (will check and verify) but even without it, I still see the problems.

  2. #12
    Join Date
    May 2007
    Location
    Saint Petersburg, Russian Federation
    Posts
    1,189

    Default

    Quote Originally Posted by jgooroo View Post
    Originally it was not there on my first try. It was left out, but things did not work so I put it there thinking that it would change something (or to see what it would do). I had the problem either way (with or without it).

    I thought I had commented that out (or removed) before posting (will check and verify) but even without it, I still see the problems.
    Ok, the next step is to get the problem reproduced when the @Component is removed.

  3. #13
    Join Date
    Dec 2006
    Posts
    26

    Default Example @Resource

    OK, so I removed the @Component from MyManagerImpl.java. I have breakpoints set at the call to SpringInit.init() where my debugger stops first, and also inside that method where, if I hit F9 (using IntelliJ), it should stop next.

    I also set a breakpoint in MyManagerImpl.setInjectedOne() and a breakpoint inside the method MyManagerImpl.afterPropertiesSet().

    I hit the first two breakpoints but I never hit the setter or afterPropertiesSet. It goes off into Spring IoC land and never comes back. I have try/catch everywhere but no exception.

    not sure what is going on, and I can't analyze it. Are my expectations correct that I should be able to hit a break point inside the setter and inside afterPropertiesSet() ?

  4. #14
    Join Date
    May 2007
    Location
    Saint Petersburg, Russian Federation
    Posts
    1,189

    Default

    Quote Originally Posted by jgooroo View Post
    OK, so I removed the @Component from MyManagerImpl.java. I have breakpoints set at the call to SpringInit.init() where my debugger stops first, and also inside that method where, if I hit F9 (using IntelliJ), it should stop next.

    I also set a breakpoint in MyManagerImpl.setInjectedOne() and a breakpoint inside the method MyManagerImpl.afterPropertiesSet().

    I hit the first two breakpoints but I never hit the setter or afterPropertiesSet. It goes off into Spring IoC land and never comes back. I have try/catch everywhere but no exception.

    not sure what is going on, and I can't analyze it. Are my expectations correct that I should be able to hit a break point inside the setter and inside afterPropertiesSet() ?
    The next quest for you is to understand why you don't have a permanent context construction but don't have MyManagerImpl methods called as well when @Component is removed.

    May be it's somehow related to the annotation presence?

  5. #15
    Join Date
    Dec 2006
    Posts
    26

    Default Example @Resource

    yes, I am attempting to use IoC annotation style, so I put annotations there as directed in the initial response to my post.

  6. #16
    Join Date
    May 2007
    Location
    Saint Petersburg, Russian Federation
    Posts
    1,189

    Default

    Quote Originally Posted by jgooroo View Post
    yes, I am attempting to use IoC annotation style, so I put annotations there as directed in the initial response to my post.
    Cool! Does the answer you provided address test-case behavior change?

  7. #17
    Join Date
    Dec 2006
    Posts
    26

    Default

    I'm really not sure.

    I want to write an application using Spring IoC irrespective of any test concerns (except that the code I write will be testable and that I can achieve full code coverage from my tests).

    With annotation style, are there annotations I need to add to address test behaviours (with maven, Junit, or other) ?

  8. #18
    Join Date
    Dec 2006
    Posts
    26

    Default Example @Resource

    Also with Spring IoC Annotation style, how does the code (context init or other features) behave differently if it is under test as compared to running under production?

    If IoC behaves differently under one scenario vs the other, then we may not want to use it, as we would not be able to access (or test) how it would run in a production environment.

  9. #19
    Join Date
    Dec 2006
    Posts
    26

    Default Example @Resource

    I must say I am quite confused. I have went over the documentation, but can not find an end to end example that explains what each annotation does and what each config option (in xml) is actually doing.

    I have tried numerous things but because the 2.5 documentation is not clear as to what is needed and how to do this, I would simply like to ask:


    => Does anyone have an end to end example (please post .zip file with test) for using the @Resource annotation?

    because:

    => I can not seem to get it to work and I have looked over all the documentation that is available to me.


    thanks

  10. #20
    Join Date
    May 2007
    Location
    Saint Petersburg, Russian Federation
    Posts
    1,189

    Default

    Quote Originally Posted by jgooroo View Post
    I must say I am quite confused. I have went over the documentation, but can not find an end to end example that explains what each annotation does and what each config option (in xml) is actually doing.

    I have tried numerous things but because the 2.5 documentation is not clear as to what is needed and how to do this, I would simply like to ask:


    => Does anyone have an end to end example (please post .zip file with test) for using the @Resource annotation?

    because:

    => I can not seem to get it to work and I have looked over all the documentation that is available to me.


    thanks
    I can say that it's rather strange to use config facilities if you don't understand what they provide and how they work.

    The documentation is very clear about the purpose of all features you used. E.g. @Component - 3.12. Classpath scanning for managed components

Posting Permissions

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