Java/EJB3/Ear File — различия между версиями

Материал из Java эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 09:50, 1 июня 2010

Ear file and war file

EJB Tutorial from JBoss: ant script for EJB packaging

   <source lang="java">

File: build.xml <?xml version="1.0"?>


<project name="JBoss" default="ejbjar" basedir=".">

  <property file="../local.properties"/>  <property environment="env"/>
  <property name="src.dir" value="${basedir}/src"/>
  <property name="jboss.home" value="${env.JBOSS_HOME}"/>   <property name="jboss.server.config" value="default"/>
  <property name="build.dir" value="${basedir}/build"/>
  <property name="build.classes.dir" value="${build.dir}/classes"/>
  
  <path id="classpath">
     
     <pathelement location="${basedir}"/>
     <fileset dir="${jboss.home}/lib">
        <include name="**/*.jar"/>
     </fileset>
     <fileset dir="${jboss.home}/server/${jboss.server.config}/lib">
        <include name="**/*.jar"/>
     </fileset>
     <fileset dir="${jboss.home}/server/${jboss.server.config}/deploy/ejb3.deployer">
        <include name="*.jar"/>
     </fileset>
     <fileset dir="${jboss.home}/server/${jboss.server.config}/deploy/jboss-aop-jdk50.deployer">
        <include name="*.jar"/>
     </fileset>
     <pathelement location="${build.classes.dir}"/>
  </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/tutorial.jar">
        <fileset dir="${build.classes.dir}">
           <include name="org/jboss/tutorial/packaging/bean/Session*.class"/>
        </fileset>
     </jar>
     <jar jarfile="build/em1.jar">
        <fileset dir="${build.classes.dir}">
           <include name="org/jboss/tutorial/packaging/bean/Entity1.class"/>
        </fileset>
        <fileset dir="resources/em1">
           <include name="META-INF/persistence.xml"/>
        </fileset>
     </jar>
     <jar jarfile="build/em2.jar">
        <fileset dir="${build.classes.dir}">
           <include name="org/jboss/tutorial/packaging/bean/Entity2.class"/>
        </fileset>
        <fileset dir="resources/em2">
           <include name="META-INF/persistence.xml"/>
        </fileset>
     </jar>
     <zip zipfile="build/tutorial.ear">
        <zipfileset dir="resources" prefix="META-INF">
           <include name="application.xml"/>
        </zipfileset>
        <zipfileset dir="build">
           <include name="tutorial.jar"/>
        </zipfileset>
        <zipfileset dir="build">
           <include name="em1.jar"/>
        </zipfileset>
        <zipfileset dir="build">
           <include name="em2.jar"/>
        </zipfileset>
     </zip>
     <copy file="build/tutorial.ear" todir="${jboss.home}/server/${jboss.server.config}/deploy"/>
  </target>
  <target name="run" depends="ejbjar">
     <java classname="org.jboss.tutorial.packaging.client.Client" fork="yes" dir=".">
        <classpath refid="classpath"/>
     </java>
  </target>



  <target name="clean.db">
     <delete dir="${jboss.home}/server/${jboss.server.config}/data/hypersonic"/>
  </target>
  <target name="clean">
     <delete dir="${build.dir}"/>
     <delete file="${jboss.home}/server/${jboss.server.config}/deploy/tutorial.ear"/>
  </target>

</project>


      </source>
   
  
 
  



EJB Tutorial from JBoss: create ear file

   <source lang="java">

File: build.xml <?xml version="1.0"?>


<project name="JBoss" default="ejbjar" basedir=".">

  <property file="../local.properties"/>  <property environment="env"/>
  <property name="src.dir" value="${basedir}/src"/>
  <property name="jboss.home" value="${env.JBOSS_HOME}"/>   <property name="jboss.server.config" value="default"/>
  <property name="build.dir" value="${basedir}/build"/>
  <property name="build.classes.dir" value="${build.dir}/classes"/>
  
  <path id="classpath">
     
     <pathelement location="${basedir}"/>
     <fileset dir="${jboss.home}/lib">
        <include name="**/*.jar"/>
     </fileset>
     <fileset dir="${jboss.home}/server/${jboss.server.config}/lib">
        <include name="**/*.jar"/>
     </fileset>
     <fileset dir="${jboss.home}/server/${jboss.server.config}/deploy/ejb3.deployer">
        <include name="*.jar"/>
     </fileset>
     <fileset dir="${jboss.home}/server/${jboss.server.config}/deploy/jboss-aop-jdk50.deployer">
        <include name="*.jar"/>
     </fileset>
     <pathelement location="${build.classes.dir}"/>
  </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/tutorial.jar">
        <fileset dir="${build.classes.dir}">
           <include name="org/jboss/tutorial/ear/bean/*.class"/>
        </fileset>
     </jar>
     <zip zipfile="build/tutorial.war">
        <zipfileset dir="${build.classes.dir}" prefix="WEB-INF/classes">
           <include name="org/jboss/tutorial/ear/servlet/*.class"/>
        </zipfileset>
        <zipfileset dir=".">
           <include name="calculator.jsp"/>
        </zipfileset>
        <zipfileset dir="resources" prefix="WEB-INF">
           <include name="web.xml"/>
           <include name="jboss-web.xml"/>
        </zipfileset>
     </zip>
     <zip zipfile="build/tutorial.ear">
        <zipfileset dir="build">
           <include name="tutorial.war"/>
        </zipfileset>
        <zipfileset dir="resources" prefix="META-INF">
           <include name="application.xml"/>
        </zipfileset>
        <zipfileset dir="build">
           <include name="tutorial.jar"/>
        </zipfileset>
     </zip>
     <copy file="build/tutorial.ear" todir="${jboss.home}/server/${jboss.server.config}/deploy"/>
  </target>
  
  
  
  <target name="clean.db">
     <delete dir="${jboss.home}/server/${jboss.server.config}/data/hypersonic"/>
  </target>
  <target name="clean">
     <delete dir="${build.dir}"/>
     <delete file="${jboss.home}/server/${jboss.server.config}/deploy/tutorial.ear"/>
  </target>

</project>


      </source>
   
  
 
  



lottery annotation ear