Results 1 to 5 of 5

Thread: Generate beans definition XML from annotations?

  1. #1
    Join Date
    Feb 2008
    Posts
    20

    Default Generate beans definition XML from annotations?

    I have an existing Spring application configured with annotations (@Serive, @Autowired, etc.). The XML configuration uses <context:component-scan /> and <context:annotation-config /> to load the application's bean definitions.

    Is there a tool that can export this annotation configuration in the XML format? This could be an Ant task, IDE plug-in, or most anything else. I've considered doing the work manually too, but having an automated tool would be quite helpful.

    Thanks!

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    No there isn't AFAIK... And why would you want it?
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Feb 2008
    Posts
    20

    Default

    I have a corner case scenario where I'm starting a Spring ApplicationContext inside of a JPPF task (http://www.jppf.org/) and the annotation component scan isn't working due to the JPPF environment limitations. However, my normal run scenario is Tomcat 7 and the annotations obviously work fine there. I was hoping to either always generate the XML configuration from my current annotation configuration, or generate it once to then maintain it (and remove my annotations).

    I wrote a crude annotation processor that creates the <bean> XML configuration for use in my JPPF task. I can then use my existing <context:annotation-config /> to autowire the beans.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    I don't know the framework but you shouldn't instantiate a new application context each time you need one... You should create a single one and reuse that throughout your program execution.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Feb 2008
    Posts
    20

    Default

    JPPF is a parallelization framework that allows you to perform Java tasks on remote hosts in a cluster. In my case, I'm attempting to execute my Spring application on a remote host. So I cannot share the same context instance across hosts and have to create a new one.

Posting Permissions

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