Axis2 WSDL2Java Generated Source

I’m not a fan of storing generated code under source control.

I don’t store anything under source control but the WSDL and my implementation source files. I let the build generate my skeleton each time and I always generate an interface. I have a custom implementation for my service living outside of the generated source tree and keep this under source control. This implementation implements the generated interface. I then muck with the services.xml post build to point to my own service impl. I use xmltask (http://www.oopsconsultancy.com/software/xmltask/) to do the dirty work of adding necessary attributes and elements to the services.xml document. Seems to work out ok..

Here is a snap from an ant build:

<target name="gen" description="Generates source" depends="check,conf,init">
  <echo>=============================================================================== = Generate Source
  ===============================================================================</echo>
  <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true" classpathref="CLASSPATH.COMMON">
    <arg line="-uri ${wsdl.uri}" />
    <arg line="-d adb" />
    <arg line="-ss" />
    <arg line="-sd" />
    <arg line="-ssi" />
    <arg line="-o ${gen}" />
  </java>
</target>
<target name="build" description="Compiles" depends="check,conf,init,gen">
  <echo>=============================================================================== = Build
  ===============================================================================</echo>
  <!-- do build stuff -->
  <javac fork="true" memoryInitialSize="256m" memoryMaximumSize="256m" debug="on" destdir="${classes}" srcdir="${src}">
    <classpath>
      <pathelement path="../dist/core.jar" />
      <path refid="CLASSPATH.WL" />
      <path refid="CLASSPATH.PROJECT" />
    </classpath>
  </javac>
  <!--
Now that the compile has finished, a little post processing is necessary
on the generated services.xml to configure the web service with the necessary
life cylce listeners as well as setting the services TCCL
(thread context class loader).
-->
  <xmltask source="${gen}/resources/services.xml" dest="${gen}/resources/services.xml">
    <!-- replace the service impl -->
    <replace path="/serviceGroup/service/parameter[@name='ServiceClass']/text()">
      <![CDATA[ com.foo.bar.MyServiceImpl ]]>
</replace>
    <!-- set the service thread context class loader param -->
    <insert path="/serviceGroup/service">
      <![CDATA[
<parameter name="ServiceTCCL">composite</parameter>
]]>
</insert>
    <!-- set the service lifecycle impl -->
    <attr path="/serviceGroup/service" attr="class" value="com.foo.bar.MyServiceLifeCycleListener" />
    <attr path="/serivceGroup/service" attr="scope" value="application" />
  </xmltask>
</target>