To build, package, and run the
simple
application, we can simply execute the
ant
command in the
examples/simple
directory. It runs the
build.xml
script, which further invokes the
examples/build-common.xml
script. The
compile
and
dist
tasks in the build script builds the application.
<target name="compile"> <mkdir dir="build"/> <javac destdir="build" debug="on" deprecation="on" optimize="on" classpathref="compile.classpath"> <src path="src"/> </javac> </target> <target name="dist" depends="compile"> <copy todir="build"> <fileset dir="src/resources"/> </copy> <mkdir dir="dist"/> <jar jarfile="dist/${ant.project.name}.beans" basedir="build"/> </target>
The
compile
target compiles the Java source files into class files under the
build
directory. Then, the
dist
target packages the class files and the
META-INF/jboss-beans.xml
file together in a JAR file named
example-simple.jar
in the
dist
directory.
In the next two sections, let's discuss how to run the newly created application both as a standalone Java SE application and as a service in the JBoss AS.
This just skims the surface of the Microcontainer, showing the most common usecases. Other more complicated examples can be found in the tests (available in the source code repository).