evenisse    2004/02/20 06:17:44

  Modified:    genapp   project.xml
  Added:       genapp/src/plugin-resources/ejb/template-resources
                        .cvsignore build.properties.jboss maven.xml
                        project.properties project.xml
               genapp/src/plugin-resources/ejb/template-resources/src/conf
                        app.properties cactus-web.xml
               genapp/src/plugin-resources/ejb/template-resources/src/java
                        ExampleBean.java ExampleFacadeBean.java
               genapp/src/plugin-resources/ejb/template-resources/src/test-cactus
                        SanityWithCactus.java
               genapp/src/plugin-resources/ejb/template-resources/src/test
                        SanityTest.java
               genapp/src/plugin-resources/ejb/template-resources/src/webapp/WEB-INF
                        web.xml
               genapp/src/plugin-resources/ejb template.properties
  Log:
  MPGENAPP-6. Add ejb template.
  
  Revision  Changes    Path
  1.17      +8 -2      maven-plugins/genapp/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/genapp/project.xml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- project.xml       29 Dec 2003 04:38:05 -0000      1.16
  +++ project.xml       20 Feb 2004 14:17:43 -0000      1.17
  @@ -1,4 +1,4 @@
  -<?xml version="1.0" encoding="UTF-8"?>
  +<?xml version="1.0" encoding="ISO-8859-1"?>
   
   <project>
     <extend>../project.xml</extend>
  @@ -9,6 +9,7 @@
     <shortDescription>A collection of example projects showing how to use maven in 
different situations</shortDescription>
     <url>http://maven.apache.org/reference/plugins/genapp/</url>
     <siteDirectory>/www/maven.apache.org/reference/plugins/genapp/</siteDirectory>
  +  
<issueTrackingUrl>http://jira.codehaus.org/BrowseProject.jspa?id=10334</issueTrackingUrl>
     <repository>
       <connection>scm:cvs:pserver:[EMAIL 
PROTECTED]:/home/cvspublic:maven-plugins/genapp/</connection>
       <url>http://cvs.apache.org/viewcvs/maven-plugins/genapp/</url>
  @@ -40,10 +41,15 @@
         <email>[EMAIL PROTECTED]</email>
       </contributor>
       <contributor>
  -      <name>J�rg Schaible</name>
  +      <name>Joerg Schaible</name>
         <id>joehni</id>
         <email>[EMAIL PROTECTED]</email>
         <organization>Elsag-Solutions AG</organization>
  +    </contributor>
  +    <contributor>
  +      <name>Archimedes Trajano</name>
  +      <id>trajano</id>
  +      <email>[EMAIL PROTECTED]</email>
       </contributor>
     </contributors>
     <dependencies>
  
  
  
  1.1                  
maven-plugins/genapp/src/plugin-resources/ejb/template-resources/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  target
  .classpath
  .project
  *.log
  build.xml
  build.properties
  
  
  
  1.1                  
maven-plugins/genapp/src/plugin-resources/ejb/template-resources/build.properties.jboss
  
        <<Binary file>>
  
  
  1.1                  
maven-plugins/genapp/src/plugin-resources/ejb/template-resources/maven.xml
  
  Index: maven.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <project xmlns:j="jelly:core" xmlns:ant="jelly:ant" default="ejb">
    <preGoal name="java:compile">
        <attainGoal name="xdoclet:ejbdoclet" />
    </preGoal>
  </project>
  
  
  
  
  1.1                  
maven-plugins/genapp/src/plugin-resources/ejb/template-resources/project.properties
  
  Index: project.properties
  ===================================================================
  maven.xdoc.date=left
  maven.ejb.src=target/xdoclet/ejb
  maven.eclipse.classpath.include=target/xdoclet/ejbdoclet,src/test-cactus
  maven.xdoclet.ejbdoclet.utilobject.0.cacheHomes=true
  maven.xdoclet.ejbdoclet.utilobject.0.includeGUID=true
  maven.xdoclet.ejbdoclet.dataobject.0=true
  maven.xdoclet.ejbdoclet.entityfacade.0=true
  maven.xdoclet.ejbdoclet.valueobject.0=true
  maven.xdoclet.ejbdoclet.deploymentdescriptor.0.validateXML=true
  cactus.src.mergewebxml = src/conf/cactus-web.xml
  
  
  
  1.1                  
maven-plugins/genapp/src/plugin-resources/ejb/template-resources/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <project>
    <!-- the version of maven's project object model -->
  
    <pomVersion>3</pomVersion>
    <!-- a unique name for this project -->
  
    <id>@ID@</id>
    <groupId>@ID@</groupId>
    <!-- a short but descriptive name for the project -->
  
    <name>@NAME@</name>
    <!-- The version of the project under development, e.g.
         1.1, 1.2, 2.0-SNAPSHOT -->
  
    <currentVersion>1.0</currentVersion>
    <!-- details about the organization that 'owns' the project -->
  
    <organization>
      <name>Apache Software Foundation</name>
      <url>http://www.apache.org/</url>
      <logo>http://maven.apache.org/images/jakarta-logo-blue.gif</logo>
    </organization>
    <!-- the year the project started -->
  
    <inceptionYear>2004</inceptionYear>
    <package>@PACKAGE@</package>
    <logo>http://maven.apache.org/images/maven.jpg</logo>
    <description>A collection of example projects showing how to use maven in 
different situations</description>
    <!-- a short description of what the project does -->
  
    <shortDescription>How to use maven in different situations</shortDescription>
    <!-- the project home page -->
  
    <url>http://maven.apache.org/reference/plugins/examples/</url>
    
<issueTrackingUrl>http://nagoya.apache.org/scarab/servlet/scarab/</issueTrackingUrl>
    <siteAddress>jakarta.apache.org</siteAddress>
    <siteDirectory>/www/maven.apache.org/reference/plugins/examples/</siteDirectory>
    <distributionDirectory>/www/maven.apache.org/builds/</distributionDirectory>
    <!-- the version control repository and http url for online access
         the connection element has the form:
         scm:<system>:<system specific connection string> -->
  
    <repository>
      <connection>scm:cvs:pserver:[EMAIL 
PROTECTED]:/home/cvspublic:maven-plugins/examples</connection>
      <url>http://cvs.apache.org/viewcvs/maven-plugins/examples/</url>
    </repository>
    <!-- any mailing lists for the project -->
  
    <mailingLists/>
    <!-- who the developers are for the project -->
  
    <developers>
    </developers>
    <!-- jar files the project is dependent on -->
  
    <dependencies>
      <dependency>
        <id>junit</id>
        <version>3.8.1</version>
      </dependency>
      <dependency>
        <id>ejb</id>
        <version>2.1</version>
      </dependency>
      <dependency>
        <id>xdoclet</id>
        <version>1.2</version>
      </dependency>
      <dependency>
        <groupId>xdoclet</groupId>
        <artifactId>xdoclet-ejb-module</artifactId>
        <version>1.2</version>
        <url>http://xdoclet.sf.net/</url>
      </dependency>
      <dependency>
        <groupId>xjavadoc</groupId>
        <artifactId>xjavadoc</artifactId>
        <version>1.0.2</version>
        <url>http://xdoclet.sf.net/</url>
      </dependency>
      <dependency>
        <groupId>xdoclet</groupId>
        <artifactId>xdoclet-jmx-module</artifactId>
        <version>1.2</version>
        <url>http://xdoclet.sf.net/</url>
      </dependency>
      <dependency>
        <groupId>xdoclet</groupId>
        <artifactId>xdoclet-web-module</artifactId>
        <version>1.2</version>
        <url>http://xdoclet.sf.net/</url>
      </dependency>
      <dependency>
        <groupId>xdoclet</groupId>
        <artifactId>xdoclet-jboss-module</artifactId>
        <version>1.2</version>
        <url>http://xdoclet.sf.net/</url>
      </dependency>
  
       <dependency>
        <groupId>jboss</groupId>
        <artifactId>jboss-j2ee</artifactId>
        <version>3.2.1</version>
      </dependency>
      
       <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.0.3</version>
        <properties>
          <ejb.bundle>true</ejb.bundle>
        </properties>
      </dependency>
      
       <dependency>
        <groupId>cactus</groupId>
        <artifactId>cactus</artifactId>
        <version>13-1.6dev-20040115</version>
      </dependency>
      
      <dependency>
        <groupId>jboss</groupId>
        <artifactId>jbossall-client</artifactId>
        <version>3.2.1</version>
      </dependency>
    </dependencies>
    <!-- build information for the project -->
  
    <build>
      <nagEmailAddress>[EMAIL PROTECTED]</nagEmailAddress>
      <sourceDirectory>src/java</sourceDirectory>
      <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
      <unitTest>
        <includes>
          <include>**/*Test.java</include>
        </includes>
        <excludes>
          <exclude>**/NaughtyTest.java</exclude>
        </excludes>
      </unitTest>
      <resources>
        <resource>
          <directory>src/conf</directory>
          <includes>
            <include>*.properties</include>
          </includes>
        </resource>
      </resources>
    </build>
  </project>
  
  
  
  1.1                  
maven-plugins/genapp/src/plugin-resources/ejb/template-resources/src/conf/app.properties
  
  Index: app.properties
  ===================================================================
  # Sample app properties.
  foo=bar
  
  
  
  1.1                  
maven-plugins/genapp/src/plugin-resources/ejb/template-resources/src/conf/cactus-web.xml
  
  Index: cactus-web.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
"http://java.sun.com/dtd/web-app_2_3.dtd";>
  
  <web-app>
     <ejb-local-ref>
        <ejb-ref-name>ejb/ExampleFacadeLocal</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <local-home>@[EMAIL PROTECTED]</local-home>
        <local></local>
        <ejb-link>ExampleFacade</ejb-link>
     </ejb-local-ref>
  </web-app>
  
  
  1.1                  
maven-plugins/genapp/src/plugin-resources/ejb/template-resources/src/java/ExampleBean.java
  
  Index: ExampleBean.java
  ===================================================================
  package @PACKAGE@;
  
  import javax.ejb.CreateException;
  import javax.ejb.EntityBean;
  
  /**
   * This is a example of a CMP entity bean.
   * @ejb.bean
   *     name="Example"
   *     cmp-version="2.x"
   *     primkey-field="id"
   * @ejb.transaction
   *     type="Required"
   * @ejb.finder
   *     signature="Example findByName(java.lang.String name)"
   *     query="SELECT DISTINCT e.id FROM Example AS e WHERE e.name = ?1"
   *
   * @author <a href="[EMAIL PROTECTED]">Archimedes Trajano</a>
   * @version $Id: ExampleBean.java,v 1.1 2004/02/20 14:17:44 evenisse Exp $
   */
  public abstract class ExampleBean implements EntityBean {
      /**
       * The primary key of the table is a number which the developer has to
       * guarantee to be unique.
       * @ejb.pk-field
       * @ejb.interface-method
       * @ejb.persistence
       *
       * @return an integer representing an ID on the keys table
       */
      public abstract Integer getId();
  
      /**
       * This sets the primary key value.  Not an actual interface method, but
       * needed during bean creation.
       * @param id the new primary key value
       */
      public abstract void setId(final Integer id);
  
      /**
       * Name is a field value, you can change or add on more fields as needed.
       * @ejb.persistence
       * @ejb.interface-method
       * @return the name
       */
      public abstract String getName();
  
      /**
       * Sets the name field
       * @ejb.interface-method
       * @param name new name
       */
      public abstract void setName(final String name);
  
      /**
       * The required EJB Creation method
       * @ejb.create-method
       * @param id a unique ID for the primary key
       * @param name the value associated with the key
       * @throws CreateException thrown when there is a problem creating 
       * @return the primary key
       */
      public Integer ejbCreate(final Integer id, final String name)
          throws CreateException {
          setName(name);
          setId(id);
  
          return getId();
      }
  }
  
  
  
  1.1                  
maven-plugins/genapp/src/plugin-resources/ejb/template-resources/src/java/ExampleFacadeBean.java
  
  Index: ExampleFacadeBean.java
  ===================================================================
  package @PACKAGE@;
  
  import java.math.BigInteger;
  import javax.ejb.CreateException;
  import javax.ejb.EJBException;
  import javax.ejb.FinderException;
  import javax.ejb.SessionBean;
  import javax.naming.NamingException;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /**
   * This is a example of a stateless session bean facade to the entity bean.
   *
   * @ejb.bean
   *     name="ExampleFacade"
   * @ejb.transaction
   *     type="Required"
   *
   * @ejb.ejb-ref
   *     ejb-name="Example"
   *     view-type="local"
   *
   * @author <a href="[EMAIL PROTECTED]">Archimedes Trajano</a>
   * @version $Id: ExampleFacadeBean.java,v 1.1 2004/02/20 14:17:44 evenisse Exp $
   */
  public abstract class ExampleFacadeBean implements SessionBean {
      /**
       * Log object
       */
      private Log log = LogFactory.getLog(this.getClass());
  
      /**
       * The required EJB Creation method
       * @ejb.create-method
       *
       * @throws CreateException
       *                    thrown when there is a problem creating the object
       */
      public void ejbCreate()
          throws CreateException {
      }
  
      /**
       * This gets the name of the specified entity.
       *
       * @ejb.interface-method
       * @param id
       *                   Primary key of the entity
       * @return value of the "name" field
       * @throws EJBException
       *                    thrown if there is a problem when getting the entity 
       *                    value.  There will be a root exception in the 
       *                    exception.
       */
      public final String getName(final Integer id)
          throws EJBException {
          try {
              ExampleLocal entity = 
                ExampleUtil.getLocalHome().findByPrimaryKey(id);
              return entity.getName();
          } catch (FinderException e) {
              throw new EJBException(e);
          } catch (NamingException e) {
              throw new EJBException(e);
          }
      }
  
      /**
       * This sets the name of the specified entity.  Creates a new one if
       * needed.
       *
       * @ejb.interface-method
       * @param id
       *                   Primary key of the entity
       * @param name
       *                   Value of the name field
       * @throws EJBException
       *                    thrown if there is a problem when getting the entity 
       *                    value.  There will be a root exception in the 
       *                    exception.
       */
      public final void setName(final Integer id, final String name)
          throws EJBException {
          try {
              try {
                  ExampleLocal entity = 
ExampleUtil.getLocalHome().findByPrimaryKey(id);
                  entity.setName(name);
              } catch (FinderException e) {
                  ExampleLocal entity = ExampleUtil.getLocalHome().create(id, name);
              }
          } catch (CreateException e) {
              throw new EJBException(e);
          } catch (NamingException e) {
              throw new EJBException(e);
          }
      }
  
      /**
       * This gets the primary key id based on the value of the name field.
       * Creates a new one if needed.
       *
       * @ejb.interface-method
       * @param name
       *                   Value of the name field
       * @return the primary key
       * @throws EJBException
       *                    thrown if there is a problem when getting the entity 
       *                    value.  There will be a root exception in the 
       *                    exception.
       */
      public Integer getId(final String name)
          throws EJBException {
          try {
              ExampleLocalHome home = ExampleUtil.getLocalHome();
              ExampleLocal entity = null;
  
              try {
                  entity = home.findByPrimaryKey((Integer) (home
                                                                                       
 .findByName(name)
                                                                                       
 .getPrimaryKey()));
              } catch (FinderException e) {
                  log.debug("Creating a new key set named " + name);
  
                  final int hexadecimalRadix = 16;
  
                  entity = home.create(new Integer(
                              new BigInteger(ExampleFacadeUtil.generateGUID(this),
                                  hexadecimalRadix).intValue()), name);
              }
  
              return entity.getId();
          } catch (CreateException e) {
              throw new EJBException(e);
          } catch (NamingException e) {
              throw new EJBException(e);
          }
      }
  }
  
  
  
  1.1                  
maven-plugins/genapp/src/plugin-resources/ejb/template-resources/src/test-cactus/SanityWithCactus.java
  
  Index: SanityWithCactus.java
  ===================================================================
  package @PACKAGE@;
  
  import org.apache.cactus.ServletTestCase;
  
  /**
   * This tests the facade methods using the Cactus framework.
   *
   * @author <a href="[EMAIL PROTECTED]">Archimedes Trajano</a>
   * @version $Id: SanityWithCactus.java,v 1.1 2004/02/20 14:17:44 evenisse Exp $
   */
  public class SanityWithCactus extends ServletTestCase {
  
      public void testGetLocalHome() throws Exception {
          ExampleFacadeUtil.getLocalHome();
      }
  
      public void testGetFacade() throws Exception {
          ExampleFacadeUtil.getLocalHome().create();
      }
  
      public void testSetName() throws Exception {
          ExampleFacadeLocal facade = ExampleFacadeUtil.getLocalHome().create();
          Integer id = facade.getId("Foo");
          assertEquals("Foo", facade.getName(id));
          facade.setName(id,  "Bar");
          assertEquals(id,facade.getId("Bar"));
          assertEquals("Bar", facade.getName(id));
          facade.setName(id,  "Foo");
          assertEquals("Foo", facade.getName(id));
      }
  }
  
  
  
  1.1                  
maven-plugins/genapp/src/plugin-resources/ejb/template-resources/src/test/SanityTest.java
  
  Index: SanityTest.java
  ===================================================================
  package @PACKAGE@;
  
  import junit.framework.TestCase;
  
  /**
   * This is a simple JUnit test case to ensure that the environment is okay.
   *
   * @author <a href="[EMAIL PROTECTED]">Archimedes Trajano</a>
   * @version $Id: SanityTest.java,v 1.1 2004/02/20 14:17:44 evenisse Exp $
   */
  public class SanityTest extends TestCase {
    public void testSanity() {
      assertEquals( "test", "test" );
    }
  }
  
  
  
  1.1                  
maven-plugins/genapp/src/plugin-resources/ejb/template-resources/src/webapp/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
"http://java.sun.com/dtd/web-app_2_3.dtd";>
  
  <web-app >
  </web-app>
  
  
  1.1                  
maven-plugins/genapp/src/plugin-resources/ejb/template.properties
  
  Index: template.properties
  ===================================================================
  maven.genapp.repackage=java,test,test-cactus
  maven.genapp.filter=project.xml,src/conf/cactus-web.xml
  
  maven.genapp.default.package=example.ejb
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to