MPGENAPP-6. Add ejb template.
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114712 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c632de9a13
commit
f27dfc1dfb
@ -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:anoncvs@cvs.apache.org:/home/cvspublic:maven-plugins/genapp/</connection>
|
||||
<url>http://cvs.apache.org/viewcvs/maven-plugins/genapp/</url>
|
||||
@ -40,11 +41,16 @@
|
||||
<email>rhoegg@isisnetworks.net</email>
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>J<EFBFBD>rg Schaible</name>
|
||||
<name>Joerg Schaible</name>
|
||||
<id>joehni</id>
|
||||
<email>joerg.schaible@elsag-solutions.com</email>
|
||||
<organization>Elsag-Solutions AG</organization>
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>Archimedes Trajano</name>
|
||||
<id>trajano</id>
|
||||
<email>trajano@yahoo.com</email>
|
||||
</contributor>
|
||||
</contributors>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
target
|
||||
.classpath
|
||||
.project
|
||||
*.log
|
||||
build.xml
|
||||
build.properties
|
||||
Binary file not shown.
@ -0,0 +1,7 @@
|
||||
<?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>
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
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
|
||||
152
genapp/src/plugin-resources/ejb/template-resources/project.xml
Normal file
152
genapp/src/plugin-resources/ejb/template-resources/project.xml
Normal file
@ -0,0 +1,152 @@
|
||||
<?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:anoncvs@cvs.apache.org:/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>turbine-maven-dev@jakarta.apache.org</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>
|
||||
@ -0,0 +1,2 @@
|
||||
# Sample app properties.
|
||||
foo=bar
|
||||
@ -0,0 +1,12 @@
|
||||
<?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>@PACKAGE@.ExampleFacadeLocalHome</local-home>
|
||||
<local></local>
|
||||
<ejb-link>ExampleFacade</ejb-link>
|
||||
</ejb-local-ref>
|
||||
</web-app>
|
||||
@ -0,0 +1,70 @@
|
||||
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="trajano@yahoo.com">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();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,139 @@
|
||||
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="trajano@yahoo.com">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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package @PACKAGE@;
|
||||
|
||||
import org.apache.cactus.ServletTestCase;
|
||||
|
||||
/**
|
||||
* This tests the facade methods using the Cactus framework.
|
||||
*
|
||||
* @author <a href="trajano@yahoo.com">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));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package @PACKAGE@;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* This is a simple JUnit test case to ensure that the environment is okay.
|
||||
*
|
||||
* @author <a href="trajano@yahoo.com">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" );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
<?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>
|
||||
4
genapp/src/plugin-resources/ejb/template.properties
Normal file
4
genapp/src/plugin-resources/ejb/template.properties
Normal file
@ -0,0 +1,4 @@
|
||||
maven.genapp.repackage=java,test,test-cactus
|
||||
maven.genapp.filter=project.xml,src/conf/cactus-web.xml
|
||||
|
||||
maven.genapp.default.package=example.ejb
|
||||
Loading…
x
Reference in New Issue
Block a user