diff --git a/genapp/project.xml b/genapp/project.xml index 4233fbfc..7527afab 100644 --- a/genapp/project.xml +++ b/genapp/project.xml @@ -1,4 +1,4 @@ - + ../project.xml @@ -9,6 +9,7 @@ A collection of example projects showing how to use maven in different situations http://maven.apache.org/reference/plugins/genapp/ /www/maven.apache.org/reference/plugins/genapp/ + http://jira.codehaus.org/BrowseProject.jspa?id=10334 scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-plugins/genapp/ http://cvs.apache.org/viewcvs/maven-plugins/genapp/ @@ -40,11 +41,16 @@ rhoegg@isisnetworks.net - J�rg Schaible + Joerg Schaible joehni joerg.schaible@elsag-solutions.com Elsag-Solutions AG + + Archimedes Trajano + trajano + trajano@yahoo.com + diff --git a/genapp/src/plugin-resources/ejb/template-resources/.cvsignore b/genapp/src/plugin-resources/ejb/template-resources/.cvsignore new file mode 100644 index 00000000..0bc9c34e --- /dev/null +++ b/genapp/src/plugin-resources/ejb/template-resources/.cvsignore @@ -0,0 +1,6 @@ +target +.classpath +.project +*.log +build.xml +build.properties diff --git a/genapp/src/plugin-resources/ejb/template-resources/build.properties.jboss b/genapp/src/plugin-resources/ejb/template-resources/build.properties.jboss new file mode 100644 index 00000000..4bdc9a3a Binary files /dev/null and b/genapp/src/plugin-resources/ejb/template-resources/build.properties.jboss differ diff --git a/genapp/src/plugin-resources/ejb/template-resources/maven.xml b/genapp/src/plugin-resources/ejb/template-resources/maven.xml new file mode 100644 index 00000000..0d3b6d3c --- /dev/null +++ b/genapp/src/plugin-resources/ejb/template-resources/maven.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/genapp/src/plugin-resources/ejb/template-resources/project.properties b/genapp/src/plugin-resources/ejb/template-resources/project.properties new file mode 100644 index 00000000..a5e48f60 --- /dev/null +++ b/genapp/src/plugin-resources/ejb/template-resources/project.properties @@ -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 diff --git a/genapp/src/plugin-resources/ejb/template-resources/project.xml b/genapp/src/plugin-resources/ejb/template-resources/project.xml new file mode 100644 index 00000000..876e8c05 --- /dev/null +++ b/genapp/src/plugin-resources/ejb/template-resources/project.xml @@ -0,0 +1,152 @@ + + + + + + 3 + + + @ID@ + @ID@ + + + @NAME@ + + + 1.0 + + + + Apache Software Foundation + http://www.apache.org/ + http://maven.apache.org/images/jakarta-logo-blue.gif + + + + 2004 + @PACKAGE@ + http://maven.apache.org/images/maven.jpg + A collection of example projects showing how to use maven in different situations + + + How to use maven in different situations + + + http://maven.apache.org/reference/plugins/examples/ + http://nagoya.apache.org/scarab/servlet/scarab/ + jakarta.apache.org + /www/maven.apache.org/reference/plugins/examples/ + /www/maven.apache.org/builds/ + + + + scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-plugins/examples + http://cvs.apache.org/viewcvs/maven-plugins/examples/ + + + + + + + + + + + + + junit + 3.8.1 + + + ejb + 2.1 + + + xdoclet + 1.2 + + + xdoclet + xdoclet-ejb-module + 1.2 + http://xdoclet.sf.net/ + + + xjavadoc + xjavadoc + 1.0.2 + http://xdoclet.sf.net/ + + + xdoclet + xdoclet-jmx-module + 1.2 + http://xdoclet.sf.net/ + + + xdoclet + xdoclet-web-module + 1.2 + http://xdoclet.sf.net/ + + + xdoclet + xdoclet-jboss-module + 1.2 + http://xdoclet.sf.net/ + + + + jboss + jboss-j2ee + 3.2.1 + + + + commons-logging + commons-logging + 1.0.3 + + true + + + + + cactus + cactus + 13-1.6dev-20040115 + + + + jboss + jbossall-client + 3.2.1 + + + + + + turbine-maven-dev@jakarta.apache.org + src/java + src/test + + + **/*Test.java + + + **/NaughtyTest.java + + + + + src/conf + + *.properties + + + + + diff --git a/genapp/src/plugin-resources/ejb/template-resources/src/conf/app.properties b/genapp/src/plugin-resources/ejb/template-resources/src/conf/app.properties new file mode 100644 index 00000000..f2429655 --- /dev/null +++ b/genapp/src/plugin-resources/ejb/template-resources/src/conf/app.properties @@ -0,0 +1,2 @@ +# Sample app properties. +foo=bar diff --git a/genapp/src/plugin-resources/ejb/template-resources/src/conf/cactus-web.xml b/genapp/src/plugin-resources/ejb/template-resources/src/conf/cactus-web.xml new file mode 100644 index 00000000..9dd80e85 --- /dev/null +++ b/genapp/src/plugin-resources/ejb/template-resources/src/conf/cactus-web.xml @@ -0,0 +1,12 @@ + + + + + + ejb/ExampleFacadeLocal + Session + @PACKAGE@.ExampleFacadeLocalHome + + ExampleFacade + + \ No newline at end of file diff --git a/genapp/src/plugin-resources/ejb/template-resources/src/java/ExampleBean.java b/genapp/src/plugin-resources/ejb/template-resources/src/java/ExampleBean.java new file mode 100644 index 00000000..555afcc4 --- /dev/null +++ b/genapp/src/plugin-resources/ejb/template-resources/src/java/ExampleBean.java @@ -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 Archimedes Trajano + * @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(); + } +} diff --git a/genapp/src/plugin-resources/ejb/template-resources/src/java/ExampleFacadeBean.java b/genapp/src/plugin-resources/ejb/template-resources/src/java/ExampleFacadeBean.java new file mode 100644 index 00000000..1ac31f93 --- /dev/null +++ b/genapp/src/plugin-resources/ejb/template-resources/src/java/ExampleFacadeBean.java @@ -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 Archimedes Trajano + * @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); + } + } +} diff --git a/genapp/src/plugin-resources/ejb/template-resources/src/test-cactus/SanityWithCactus.java b/genapp/src/plugin-resources/ejb/template-resources/src/test-cactus/SanityWithCactus.java new file mode 100644 index 00000000..5fae31c2 --- /dev/null +++ b/genapp/src/plugin-resources/ejb/template-resources/src/test-cactus/SanityWithCactus.java @@ -0,0 +1,31 @@ +package @PACKAGE@; + +import org.apache.cactus.ServletTestCase; + +/** + * This tests the facade methods using the Cactus framework. + * + * @author Archimedes Trajano + * @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)); + } +} diff --git a/genapp/src/plugin-resources/ejb/template-resources/src/test/SanityTest.java b/genapp/src/plugin-resources/ejb/template-resources/src/test/SanityTest.java new file mode 100644 index 00000000..f5dae5d8 --- /dev/null +++ b/genapp/src/plugin-resources/ejb/template-resources/src/test/SanityTest.java @@ -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 Archimedes Trajano + * @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" ); + } +} diff --git a/genapp/src/plugin-resources/ejb/template-resources/src/webapp/WEB-INF/web.xml b/genapp/src/plugin-resources/ejb/template-resources/src/webapp/WEB-INF/web.xml new file mode 100644 index 00000000..bd4dabf3 --- /dev/null +++ b/genapp/src/plugin-resources/ejb/template-resources/src/webapp/WEB-INF/web.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/genapp/src/plugin-resources/ejb/template.properties b/genapp/src/plugin-resources/ejb/template.properties new file mode 100644 index 00000000..9e1455e4 --- /dev/null +++ b/genapp/src/plugin-resources/ejb/template.properties @@ -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