Changeset 3944 for TI01-discovery


Ignore:
Timestamp:
27/05/08 10:44:51 (11 years ago)
Author:
cbyrom
Message:

Restructure build file to cleanly separate client and service jar
generation - NB, the WSDL2JAVA operation generates its own xmlbeans code
and this is linked explicitly to the generated java code - so care
needs to be taken that the correct xmlbeans code is packaged up with
the java code -hence this separation.

Also, add stop/start tomcat targets and add deploy and reload targets
to allow build process to use these.

Move the test client to its own package and create targets to more
cleanly copy the code required for both the client and service jars

  • to ensure only what is needed is added to these.

Update documentation to include new build instructions and setting up
info.

Location:
TI01-discovery/trunk/ws-Discovery2
Files:
2 added
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • TI01-discovery/trunk/ws-Discovery2/readme.txt

    r3941 r3944  
    33 
    44NB, completing the build here assumes you have both apache axis2 and ant installed.  The AXIS2_HOME environment variable 
    5 should be set to point to the top level directory of the axis2 install. 
     5should be set to point to the top level directory of the axis2 install.  If you are deploying locally to tomcat, you need 
     6to set CATALINA_HOME to the home dir of the tomcat install.  Also, you may need to copy jdom.jar into your java jre/ext/lib dir 
     7to get the compile working. 
    68 
    7 The build file, \srcgen\buildDiscovery.xml, now includes targets to run the WSDL2Java code generation.  Running the build 
     9The build file, \srcgen\buildDiscovery.xml, now includes targets to run the WSDL2Java code generation and do all the setting up 
     10described in the original instructions below.  Options for building include: 
    811with no parameters, e.g.: 
    912 
    10 ant -f buildClient.xml 
     13ant -f buildClient.xml jar.client - build the test client jar 
     14ant -f buildClient.xml jar.server - build the server service jar 
     15ant -f buildClient.xml deploy.client - build the service jar and deploy it to a local tomcat install 
     16ant -f buildClient.xml deploy.client - build the service jar and deploy it to a local tomcat install + restart tomcat 
     17ant -f buildClient.xml - defaults to building the service jar 
    1118 
    12 will now build both the server and client archives and make the necessary changes to the files outlined below.  NB, to get 
    13 the DiscoveryService.wsdl file to be generated properly, you will likely have to temporarily rename the jsr file, as mentioned 
    14 below. 
     19NB, to get the DiscoveryService.wsdl file to be generated properly, you will likely have to temporarily rename the jsr  
     20file, as mentioned below.  Also note that the WSDL2JAVA operation generates its own unique version of xmlbeans which is then 
     21referenced by the generated code - as such you should be careful not to mix the xmlbeans code generated between doing client 
     22and service jar builds. 
    1523 
    1624Original, detailed instructions, are as follows (but you shouldn't have to use them!): 
  • TI01-discovery/trunk/ws-Discovery2/src/ndg/testclient/discovery/DiscoveryServiceClient.java

    r3940 r3944  
    1 package ndg.services.discovery; 
     1package ndg.testclient.discovery; 
    22 
    33import discoveryserviceapi.*; 
     
    3434public class DiscoveryServiceClient 
    3535{ 
     36        private static final String USAGE_STRING = "Usage : DiscoveryServiceClient string|helpers <term>"; 
     37         
    3638        public static void main(String[] args) 
    3739        { 
    3840                System.out.println("My DiscoveryService client"); 
     41                 
     42                if (args.length == 0) 
     43                { 
     44                        System.out.println(USAGE_STRING); 
     45                        return; 
     46                } 
    3947 
    4048                try 
    4149                { 
    42                         DiscoveryServiceClient client = new DiscoveryServiceClient("http://glue.badc.rl.ac.uk/axis2/services/DiscoveryService"); 
     50                        DiscoveryServiceClient client = new DiscoveryServiceClient("http://localhost/axis2/services/DiscoveryService"); 
    4351 
    4452                        // Method 1: request documents passed as strings 
    4553                        if ( args[0].equals("string") ) 
    4654                        { 
    47                                 System.out.println( "Trying a doSearch..." ); 
    4855                                String doSearchResult = client.doSearch( 
    4956                                        "<m:doSearch xmlns:m=\"urn:DiscoveryServiceAPI\"><m:term>*neodc*</m:term><m:termType>fullText</m:termType></m:doSearch>" 
     
    115122                        else 
    116123                        { 
    117                                 System.out.println("Usage : DiscoveryServiceClient string|helpers <term>"); 
     124                                System.out.println(USAGE_STRING); 
    118125                        } 
    119  
    120                          
    121                          
    122  
    123  
    124126                } 
    125127                catch (Exception e) 
     
    138140        public DiscoveryServiceClient(String uri) throws org.apache.axis2.AxisFault 
    139141        { 
     142                System.out.println("Initialising connection to endpoint: " + uri); 
    140143                _service = new DiscoveryServiceStub(null,uri); 
    141144        } 
     
    150153        ) throws java.rmi.RemoteException, org.apache.xmlbeans.XmlException 
    151154        { 
     155                System.out.println( "Trying a doSearch..." ); 
    152156                discoveryserviceapi.DoSearchDocument reqDoc= discoveryserviceapi.DoSearchDocument.Factory.parse( reqDocAsString ); 
     157                System.out.println("Got reqDoc: " + reqDoc.toString()); 
    153158                discoveryserviceapi.DoSearchReturnDocument resDoc= _service.doSearch( reqDoc ); 
     159                System.out.println("Got resDoc: " + resDoc.toString()); 
    154160                return resDoc.toString(); 
    155161        } 
  • TI01-discovery/trunk/ws-Discovery2/srcgen/buildDiscovery.xml

    r3939 r3944  
    1010        <property name="test" value="${build.base.dir}/test"/> 
    1111        <property name="build" value="${build.base.dir}/build"/> 
     12        <property name="jar.server" value="${build}/lib/${name}.aar"/> 
    1213        <property name="build.src" value="${build}/src"/> 
    1314        <property name="build.classes" value="${build}/classes"/> 
     
    1718        <property name="jars.ok" value=""/> 
    1819        <property name="src.nongen" value="../src"/> 
     20        <property name="src.nongen.server" value="../src/ndg/services"/> 
     21        <property name="src.nongen.client" value="../src/ndg/testclient"/> 
    1922        <property name="res.nongen" value="../resources"/> 
    2023        <property name="stubfile" value="${build.base.dir}/src/ndg/clients/discovery/DiscoveryServiceStub.java"/> 
    2124        <property name="skeletonfile" value="${build.base.dir}/src/ndg/services/discovery/DiscoveryServiceSkeleton.java"/> 
     25        <property name="tomcat.deploy.dir" value="${env.CATALINA_HOME}/webapps/axis2/WEB-INF/services/"/> 
     26         
    2227        <path id="axis2.class.path"> 
    2328                <pathelement path="${java.class.path}"/> 
     
    2833                <fileset dir="${resources}"> 
    2934                        <include name="*.jar"/> 
    30                         <!--<include name="xmlrpc-1.2-patched.jar"/> 
    31                         <include name="jdom.jar"/> 
    32                         <include name="jaxen-core.jar"/> 
    33                         <include name="jaxen-jdom.jar"/> 
    34                         <include name="saxpath.jar"/>--> 
    3535                </fileset> 
    3636        </path> 
    37         <target name="init"> 
     37         
     38        <target name="init" depends="clean"> 
    3839                <mkdir dir="${build}"/> 
    3940                <mkdir dir="${build.classes}"/> 
     
    4344        </target> 
    4445         
    45         <target name="wsdl2java.client" depends="pre.compile.test"> 
     46        <target name="wsdl2java.client" depends="init"> 
    4647                <echo message="Generating client side stubs from WSDL"/> 
    4748        <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"> 
     
    5859        </target>        
    5960         
    60         <target name="wsdl2java.server" depends="pre.compile.test"> 
     61        <target name="wsdl2java.server" depends="init"> 
    6162                <echo message="Generating server side stubs from WSDL"/> 
    6263        <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"> 
     
    100101        </target> 
    101102         
    102         <target name="generate.wsdl.stubs" depends="wsdl2java.client,fixchunking,wsdl2java.server"/> 
    103  
    104         <target name="compile.src" depends="pre.compile.test,generate.wsdl.stubs,copygen,copynongen" if="jars.ok"> 
     103        <target name="compile.src.server" depends="wsdl2java.server,pre.compile.test,copygen,copynongen.server,compile.src"/> 
     104        <target name="compile.src.client" depends="wsdl2java.client,fixchunking,pre.compile.test,copygen,copynongen.client,compile.src"/> 
     105        <target name="compile.src" depends="" if="jars.ok"> 
    105106                <javac debug="on" destdir="${build.classes}" srcdir="${build.src}"> 
    106107                        <classpath location="${lib}/${xbeans.packaged.jar.name}"/> 
     
    109110                <delete dir="${build.src}"/> 
    110111        </target> 
    111         <target name="compile.test" depends="compile.src" if="jars.ok"> 
     112        <target name="compile.test" depends="compile.src.client" if="jars.ok"> 
    112113                <javac debug="on" destdir="${build.classes}"> 
    113114                        <src path="${test}"/> 
     
    119120                <echo message="The class path is not set right!                                Please make sure the following classes are in the classpath                                1. XmlBeans                                2. Stax                                3. Axis2                 "/> 
    120121        </target> 
    121         <target name="jar.all" depends="jar.server, jar.client"/> 
    122         <target name="jar.server" depends="compile.src,echo.classpath.problem" if="jars.ok"> 
     122        <target name="jar.all" depends="jar.server"/> 
     123        <target name="jar.server" depends="compile.src.server,echo.classpath.problem" if="jars.ok"> 
    123124                <copy toDir="${build.classes}/META-INF"> 
    124125                        <fileset dir="${resources}"> 
     
    157158                <mkdir dir="${build}/repo/"/> 
    158159                <mkdir dir="${build}/repo/services"/> 
    159                 <copy file="${build}/lib/${name}.aar" toDir="${build}/repo/services/"/> 
     160                <copy file="${jar.server}" toDir="${build}/repo/services/"/> 
    160161        </target> 
    161162        <target depends="make.repo" name="start.server" if="jars.ok"> 
     
    187188                <delete dir="${src}"/> 
    188189        </target> 
    189         <target name="javadoc" depends="compile.src" description="Create Javadoc API documentation"> 
     190        <target name="javadoc" depends="compile.src.server" description="Create Javadoc API documentation"> 
    190191                <mkdir dir="${build}/docs/api"/> 
    191192                <mkdir dir="${build}/docs/api/resources"/> 
     
    201202                <echo message="JAVA_HOME = ${env.JAVA_HOME}"/> 
    202203                <echo message="AXIS_CLASSPATH = ${axis2.class.path}"/> 
    203                 <java classname="ndg.services.discovery.DiscoveryServiceClient" fork="true"> 
     204                <java classname="ndg.testclient.discovery.DiscoveryServiceClient" fork="true"> 
    204205                        <!-- <arg value="${build}/repo"/> --> 
    205206                        <classpath refid="axis2.class.path"/> 
    206207                        <classpath location="${lib}/${name}-test-client.jar"/> 
     208                        <sysproperty key="verbose" value="true"/> 
     209                        <arg value="string"/> 
     210                </java> 
     211        </target> 
     212        <target depends="" name="test.client" if="jars.ok"> 
     213                <echo message="JAVA_HOME = ${env.JAVA_HOME}"/> 
     214                <java classname="ndg.testclient.discovery.DiscoveryServiceClient" fork="true"> 
     215                        <!-- <arg value="${build}/repo"/> --> 
     216                        <classpath refid="axis2.class.path"/> 
     217                        <classpath location="${lib}/${name}-test-client.jar"/> 
     218                        <sysproperty key="verbose" value="true"/> 
     219                        <arg value="string"/> 
    207220                </java> 
    208221        </target> 
     
    210223                <!-- Copy auto-generated src to source tree --> 
    211224                <!-- NB. Overwrites even if files in toDir are newer --> 
    212                 <copy toDir="${build.src}" overwrite="true" verbose="true">  
     225                <copy toDir="${build.src}" overwrite="true">  
    213226                        <fileset dir="${src}"> 
    214227                                <include name="**/*.java"/> 
     
    217230                </copy> 
    218231    </target> 
    219     <target name="copynongen"> 
     232    <target name="copynongen.server" depends="copy.resource"> 
    220233                <!-- Copy non-auto-generated src to source tree --> 
    221234                <!-- NB. Overwrites even if files in toDir are newer --> 
    222235                <copy toDir="${build.src}" overwrite="true" verbose="true">  
    223                         <fileset dir="${src.nongen}"> 
     236                        <fileset dir="${src.nongen.server}"> 
    224237                                <include name="**/*.java"/> 
    225238                                <include name="**/*.html"/> 
    226239                        </fileset> 
    227240                </copy> 
     241   </target> 
     242        <target name="copy.resource"> 
    228243                <copy toDir="${resources}" overwrite="true" verbose="true"> 
    229244                        <fileset dir="${res.nongen}"> 
     
    233248                        </fileset> 
    234249                </copy> 
    235    </target> 
     250        </target> 
     251 
     252        <target name="copynongen.client" depends="copy.resource"> 
     253                <!-- Copy non-auto-generated src to source tree --> 
     254                <!-- NB. Overwrites even if files in toDir are newer --> 
     255                <copy toDir="${build.src}" overwrite="true" verbose="true">  
     256                        <fileset dir="${src.nongen.client}"> 
     257                                <include name="**/*.java"/> 
     258                                <include name="**/*.html"/> 
     259                        </fileset> 
     260                </copy> 
     261                <copy toDir="${resources}" overwrite="true" verbose="true"> 
     262                        <fileset dir="${res.nongen}"> 
     263                                <!-- <include name="**/*.xq"/> --> 
     264                                <!-- <include name="**/*.properties"/> --> 
     265                                <include name="**/*.jar"/> 
     266                        </fileset> 
     267                </copy> 
     268           </target> 
    236269   <target name="fixchunking"> 
    237270                <echo message="Changing content of ${stubfile} to switch off http tranfer chunking"/>  
     
    240273                        replace="_serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service);_serviceClient.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, false);"/> 
    241274   </target> 
     275         
     276        <target name="deploy.server" depends="jar.server"> 
     277                <copy file="${jar.server}" toDir="${tomcat.deploy.dir}" overwrite="true" verbose="true" /> 
     278        </target> 
     279 
     280        <target name="reload" depends="deploy.server, tomcat-start" /> 
     281         
     282        <target name="tomcat-start" depends="tomcat-stop"> 
     283            <java jar="${env.CATALINA_HOME}/bin/bootstrap.jar" fork="true"> 
     284                <jvmarg value="-Dcatalina.home=${env.CATALINA_HOME}"/> 
     285            </java> 
     286        </target> 
     287 
     288        <target name="tomcat-stop"> 
     289            <java jar="${env.CATALINA_HOME}/bin/bootstrap.jar" fork="true"> 
     290                <jvmarg value="-Dcatalina.home=${env.CATALINA_HOME}"/> 
     291                <arg line="stop"/> 
     292            </java> 
     293        </target> 
     294 
    242295</project> 
Note: See TracChangeset for help on using the changeset viewer.