catch (NamingException e)
{
e.printStackTrace();
}
}
}
这个类用来测试我们发布的计数器EJB。首先通过ctx = new InitialContext();得到上下文,然后通过lookup查找计数器,然后给计数器加10,显示当前的计数器信息。
jndi.properties
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost
EJB 3.0开发指南之无状态会话Bean(3)
时间:2009-11-27 天极
这个文件配置了JNDI操作所需的属性,因为我们是测试本机的EJB服务,所以不必修改上面的属性。
Build.xml
<project name="kuaff_ejb3_tutorial" default="ejbjar" basedir=".">
<property environment="env"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="jboss.home" value="${env.JBOSS_HOME}"/>
<property name="build.dir" value="${basedir}/build"/>
<property name="build.classes.dir" value="${build.dir}/classes"/>
<path id="classpath">
<fileset dir="${jboss.home}/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${jboss.home}/server/all/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${jboss.home}/server/all/deploy/ejb3.deployer">
<include name="*.jar"/>
</fileset>
<fileset dir="${jboss.home}/server/all/deploy/jboss-aop.deployer">
<include name="*.jar"/>
</fileset>
<pathelement location="${build.classes.dir}"/>
<pathelement location="${basedir}"/>
</path>
<property name="build.classpath" refid="classpath"/>
<target name="prepare">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes.dir}"/>
</target>
<target name="compile" depends="prepare">
<javac srcdir="${src.dir}"
destdir="${build.classes.dir}"
debug="on"
deprecation="on"
optimize="off"
includes="**">
<classpath refid="classpath"/>
</javac>
</target>
<target name="ejbjar" depends="compile">
<jar jarfile="build/StatelessSample.ejb3">
<fileset dir="${build.classes.dir}">
<include name="**/*.class"/>
</fileset>
</jar>
<copy file="build/StatelessSample.ejb3" todir="${jboss.home}/server/all/deploy"/>
</target>
<target name="run" depends="ejbjar">
<java classname="com.kuaff.ejb3.stateless.Client" fork="yes" dir=".">
<classpath refid="classpath"/>
</java>
</target>
<target name="clean.db">
<delete dir="${jboss.home}/server/all/data/hypersonic"/>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
<delete file="${jboss.home}/server/all/deploy/StatelessSample.ejb3"/>
</target>
|