ejb 3+jboss+antの初日
3188 ワード
try {
InitialContext ctx = new InitialContext();
HelloWord hello = (HelloWord) ctx.lookup("HelloWordImpl/remote");
System.out.println(hello.say());
System.out.println(hello.getClass().getName());
} catch (Exception e) {
System.out.println(e.getMessage());
}
Ant構成の説明:
<?xml version="1.0" encoding="UTF-8"?>
<!-- hello "." build.xml -->
<project name="hello" basedir=".">
<!-- , src.dir, , src -->
<property name="src.dir" value="${basedir}\src" />
<!-- , env-->
<property environment="env" />
<!-- , JBOSS HOME , JBOSS_HOME , , : , , -->
<property name="jboss.home" value="${env.JBOSS_HOME}" />
<!-- JBOSS default all -->
<property name="jboss.server.config" value="default" />
<!-- build.xml build -->
<property name="build.dir" value="${basedir}\build" />
<!-- -->
<path id="build.classpath">
<!-- jboss client jar -->
<fileset dir="${jboss.home}/client">
<include name="*.jar" />
</fileset>
<!-- .class -->
<pathelement location="${build.dir}" />
</path>
<!-- , , -->
<target name="prepare">
<delete dir="${build.dir}" />
<mkdir dir="${build.dir}" />
</target>
<!-- , javac , prepare -->
<target name="compile" depends="prepare" description=" ">
<javac srcdir="${src.dir}" destdir="${build.dir}">
<!-- build.classpath ID -->
<classpath refid="build.classpath" />
</javac>
</target>
<!-- , jar , -->
<target name="ejbjar" depends="compile" description=" ejb ">
<!--jar build.xml ,jar -->
<jar jarfile="${basedir}\${ant.project.name}.jar">
<!-- jar .class -->
<fileset dir="${build.dir}">
<include name="**/*.class" />
</fileset>
</jar>
</target>
<!-- , -->
<target name="deploy" depends="ejbjar" description=" ejb">
<!-- jar jboss default deploy -->
<copy file="${basedir}\${ant.project.name}.jar" todir="${jboss.home}\server\${jboss.server.config}\deploy" />
</target>
<!-- EJB -->
<target name="undeploy" description=" ejb">
<!-- jboss default deploy jar -->
<delete file="${jboss.home}/server/${jboss.server.config}/deploy/${ant.project.name}.jar" />
</target>
</project>