Apama 10.15.4 | Developing Apama Applications | Developing Apama Applications in Java | Developing and Deploying JMon Applications | Creating deployment descriptor files | Generating deployment descriptor files from annotations
 
Generating deployment descriptor files from annotations
There are two utilities that you can use to generate the deployment descriptor file from annotations in your source files:
*com.apama.jmon.annotation.DirectoryProcessor — This utility processes a directory and generates the deployment descriptor file, which you must add to your application's JAR file.
*com.apama.jmon.annotation.JarProcessor — This utility processes an application's JAR file and adds the deployment descriptor file to that JAR file.
You can execute these utilities from the command line or from a Java build file.
The DirectoryProcessor utility takes three optional arguments:
*-r indicates that you want to recursively process the .class files in each directory and subdirectory in the specified directory. The default is that the utility processes only the .class files that are in the specified directory.
*-d specifies the directory that contains the .class files you want to process. The default is that the utility processes any .class files in the current working directory.
*-o specifies the file in which to store the output. The default is that output goes to stdout. In the JMon application JAR file, the name of the deployment descriptor file must always be jmon-jar.xml.
After you generate the deployment descriptor file, you must place it in the META-INF directory of your development directory. For example, you can execute the DirectoryProcessor utility from the command line as follows:
cd src
javac -classpath
$APAMA_CORRELATOR_HOME/lib/ap-correlator-extension-api.jar
*.java
java -DAPAMA_LOG_LEVEL=WARN -classpath
$APAMA_CORRELATOR_HOME/lib/ap-correlator-extension-api.jar
com.apama.jmon.annotation.DirectoryProcessor -r -d ./src -o
./src/META-INF/jmon-jar.xml
jar -cf ../simple-jmon.jar META-INF/jmon-jar.xml *.class
The JarProcessor utility takes one required argument, which is the name of the JAR file to operate on. To execute the JarProcessor utility from a Java build file, you can define something like the following:
<!--Target to process the annotations in the JMon application classes
    to produce jmon-jar.xml -- the deployment descriptor file.
-->
<target name="process-jar" depends="jar">
  <echo message=
    "Process annotations in jar file: ${process-jar-file}" />
  <java jvm="java"
    classname="com.apama.jmon.annotation.JarProcessor" dir="."
    fork="yes">
    <classpath>
      <fileset dir="${lib-dir}">
        <patternset refid="libs" />
      </fileset>
    </classpath>
    <jvmarg value="-DAPAMA_LOG_LEVEL=WARN" />
    <arg value="${process-jar-file}" />
  </java>
</target>
 
<target name="process" depends="jar">
  <antcall target="process-jar">
    <param name="process-jar-file" value="${jar-file}" />
  </antcall>
</target>