facebook

How to access generated class from outside scafolded package

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #315233 Reply

    Greg Soulsby
    Member

    We are try to keep the proprietory classes apart from the “generated” directory, in the hope of simplifying re-scafolding.

    Can get access to our proprietory classes from the generated classes by updating /resources/…generated-service-context.xml to scan our directory. Then @Autowire picks up the prop classes from within the generated class. Cool.

    I cant get it to work the other way around – I want to @Autowire generated classes into my proprietory classes. But they are null to start with and I cant find how to initialise them.

    #315260 Reply

    jkennedy
    Member

    You should see both a service-context.xml and a generated-service-context.xml file. The generated one can be modified, but our design goal was to actually put the service-context.xml file there for you to modify leaving the generated one for us to modify, etc. You will notice if you look through the context files, and the web.xml file, that we load specific context files and then those context files import other context files. We left the “non generated” files for developers to modify by hand.

    Regarding the issue of not being able to Autowire our beans into your beans, there must be some issue with the order of the component scanning I think. One thing to try would be to add the autowire of your classes to the service-context.xml file. You could also try creating your own context file and then adding that context file to the list of context files that are being loaded in the web.xml file where it configures the Dispatch Servlet:
    org.springframework.web.servlet.DispatcherServlet

    If you can’t get it to work, please send me a copy of your project (or similar) to [email protected].

    I would need to know which of our objects (Services, DAOs) etc you are trying to Autowire and see where you are trying to add your component scan etc.

    Thanks,
    Jack

    #315596 Reply

    Greg Soulsby
    Member

    Jack,

    I see, separation as you have done is good.

    Re:

    One thing to try would be to add the autowire of your classes to the service-context.xml file.

    Can you tell me give me a hint as to what that would look like? And dont worry, it doesnt have to be subtle.

    Thanks

    #315612 Reply

    jkennedy
    Member

    P0rridge,
    Sorry, I should have been more clear.

    I was proposing that you try adding a line that component scans your package in the service-context.xml

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

    Thanks,
    Jack

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: How to access generated class from outside scafolded package

You must be logged in to post in the forum log in