springxdoclet

Xdoclet @spring.bean not generating configuration file properly


I'm stuck using Spring 2.0.8 at the moment (still awaiting sign-off on the upgrade) as I cannot use annotations I though I would use xdoclet to generate the beans config file for a large number of beans I will be writing in the future.

However, when I run my ant target it creates the xml file but it does not contain any bean tags.

My ant script looks like this:

<taskdef name="springdoclet" classname="xdoclet.modules.spring.SpringDocletTask">
    <classpath refid="springdoclet.classpath"/>
</taskdef>

<taskdef name="doclet" classname="xdoclet.DocletTask">
    <classpath refid="springdoclet.classpath"/>
</taskdef>

<target name="generate-spring-wiring">
    <springdoclet destdir="${resource.dir}" excludedtags="@version,@author,@todo">
        <fileset dir="${global.src.dir}"/>
        <springxml destinationfile="spring-wiring.xml"/>
    </springdoclet>

</target>

The resulting xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE beans PUBLIC
"-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">

<beans
default-autowire="no"
default-lazy-init="false"
default-dependency-check="none"
>

<!--
 To include additional bean definitions for Spring in the generated
 application context file, add a file to your XDoclet merge directory
  called spring-beans.xml that contains the <bean></bean> markup.
-->

</beans>

As you can see no beans have been set up.

My bean classes all inherit from a parent class which is in the same source directory. The MasterBean has been set up as follows:

/**
 *
 *@spring.bean id="master"
 */
 abstract public class Master implements Rule {

 ..
 ..
 }

And a sample child class (in the same package is set up as follows:

/**
*
* @spring.bean id="G27"
*/
public class Global27_IncorrectFormTypeForCA extends Master {

Is this something to do with the fact that my classes extend a superclass? Or am I simply setting it up incorrectly. The documentation on this is virtually non-existent so any help would be gratefully recieved.

Thanks


Solution

  • I had some problems with XDoclet and the fileset subtask, if I set the dir attribute to deep (like src/java/my/pacakge/some/package) it wouldn't work, setting it to src/java worked fine.

    I know XDoclet can generate Spring beans from classes with a superclass. All my project's beans extend some other class, but their superclass is not bean itself, i.e. no @spring.bean and they are all generated correctly. I am not sure if that's a problem, but since your Master class is abstract, does it need to be defined as a Spring bean? Spring does have the concept of an abstract bean, but it is not same as an abstract Java class.