Skip to content

Commit

Permalink
Various work on wicket-ear
Browse files Browse the repository at this point in the history
* Split out wicket-war from wicket-ear branches
* Remove whitespace
* Use standard groupId and artifactId
* Remove custom ear packaging
* Default is skip for jboss-as plugin
* Move all dependencyManagement to parent
* Add deployable datasources
* Generate application.xml
* Use JBoss Java EE APIs exclusively
* Remove redundant Local suffix from ContactDao
* Use fields for JPA annotations
* Don't use synthetic ID for equality and hash code, well known anti-pattern
* Use CDI not EJB injections into Wicket (promote modern approaches)
* Improve comments
  • Loading branch information
pmuir committed Mar 26, 2012
1 parent c6872a0 commit d39d3f3
Show file tree
Hide file tree
Showing 34 changed files with 399 additions and 1,121 deletions.
25 changes: 18 additions & 7 deletions wicket-ear/README.md
Expand Up @@ -3,8 +3,6 @@ wicket-ear: Wicket Framework used in a WAR inside an EAR.

Author: Ondrej Zizka <ozizka@redhat.com>



What is it?
-----------

Expand All @@ -24,7 +22,6 @@ This is an EAR version, with the following structure:
** `ear`: Packages the EJB JAR and WAR into an EAR. Creates an `.ear` file.



System requirements
-------------------

Expand All @@ -39,7 +36,6 @@ Configure Maven
If you have not yet done so, you must [Configure Maven](../README.html/#mavenconfiguration) before testing the quickstarts.



Start the JBoss Server
----------------------

Expand All @@ -49,14 +45,29 @@ Start the JBoss Server
Build and Deploy the Quickstart
-------------------------------

* Running server is required before deploying.
* To build and deploy the quickstart, follow the instruction here: [Build and Deploy the Quickstarts](../README.html/#buildanddeploy)
1. Make sure your server is running.
2. Open a command line and navigate to the root of the kitchensink-ear quickstart directory.
3. Type the following in the command line:
For JBoss Enterprise Application Platform 6, Maven user settings NOT configured:

mvn clean package jboss-as:deploy -s PATH_TO_QUICKSTARTS/example-settings.xml

For JBoss AS 7 or JBoss Enterprise Application Platform 6, Maven user settings configured:

mvn clean package jboss-as:deploy

4. This will build and deploy `ear/target/jboss-as-kitchensink-ear.ear`.
5. To undeploy the application, run this command:

mvn jboss-as:undeploy

You can also use Eclipse to start the JBoss Enterprise Application Platform 6 or JBoss AS 7 server and deploy the project. See the <a href="https://docs.jboss.org/author/display/AS71/Getting+Started+Developing+Applications+Guide" title="Getting Started Developing Applications Guide">Getting Started Developing Applications Guide</a> for more information.


Access the application (For quickstarts that have a UI component)
----------------------

Access the running application in a browser at the following URL: [http://localhost:8080/jboss-as-wicket-ear](http://localhost:8080/jboss-as-wicket-ear)
Access the running application in a browser at <http://localhost:8080/jboss-as-wicket-ear-web>

* You will see a page with a table listing user entities. Initially, this table is empty.
* By clicking a link, you can add more users.
Expand Down
69 changes: 33 additions & 36 deletions wicket-ear/ear/pom.xml
@@ -1,76 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jboss.as.quickstart.wicket-ear</groupId>
<artifactId>as7-quickstart-wicket-ear-parent</artifactId>
<groupId>org.jboss.as.quickstarts</groupId>
<artifactId>jboss-as-wicket-ear-parent</artifactId>
<version>7.1.1-SNAPSHOT</version>
</parent>
<artifactId>as7-quickstart-wicket-ear-ear</artifactId>

<artifactId>jboss-as-wicket-ear-ear</artifactId>
<packaging>ear</packaging>

<name>JBoss AS Quickstarts: Wicket EAR: EAR package</name>


<dependencies>

<!-- EJB JAR module. -->
<dependency>
<groupId>org.jboss.as.quickstarts</groupId>
<artifactId>jboss-as-wicket-ear-ejb</artifactId>
<type>ejb</type>
<groupId>${project.groupId}</groupId>
<artifactId>as7-quickstart-wicket-ear-ejb</artifactId>
<version>${project.version}</version>
</dependency>

<!-- WAR module. -->
<dependency>
<groupId>org.jboss.as.quickstarts</groupId>
<artifactId>jboss-as-wicket-ear-war</artifactId>
<type>war</type>
<groupId>${project.groupId}</groupId>
<artifactId>as7-quickstart-wicket-ear-war</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>



<build>
<plugins>

<!-- EAR archive creation. -->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.6</version>
<configuration>
<!-- Tell Maven we are using Java EE 6 -->
<version>6</version>
<!-- Use Java EE ear libraries as needed. Java EE ear
libraries are in easy way to package any libraries needed in the ear, and
automatically have any modules (EJB-JARs and WARs) use them -->
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>as7-quickstart-wicket-ear-war</artifactId>
<bundleFileName>as7-quickstart-wicket-ear.war</bundleFileName>
<contextRoot>/jboss-as-wicket-ear</contextRoot>
</webModule>
<ejbModule>
<groupId>${project.groupId}</groupId>
<artifactId>as7-quickstart-wicket-ear-ejb</artifactId>
<bundleFileName>as7-quickstart-wicket-ear-ejb.jar</bundleFileName>
</ejbModule>
<!-- Default context root of the web app is /jboss-as-wicket-ear-web.
If a custom context root is needed, uncomment the following snippet to register
our War as a web module and set the contextRoot property -->
<!-- <webModule> -->
<!-- <groupId>org.jboss.as.quickstarts</groupId> -->
<!-- <artifactId>jboss-as-wicket-ear-web</artifactId> -->
<!-- <contextRoot>/jboss-as-wicket</contextRoot> -->
<!-- </webModule> -->
</modules>
</configuration>
</plugin>
<!-- Skip JBoss AS plugin - only applicable for the EAR package. -->

<!-- Enable JBoss AS plugin - only applicable for the EAR package. -->
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.1.0.Final</version>
<configuration>
<skip>false</skip>
</configuration>
</plugin>

</plugins>
</build>

</project>
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is an unmanaged datasource. It should be used for proofs of concept
or testing only. It uses H2, an in memory database that ships with JBoss
AS. -->
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<!-- The datasource is bound into JNDI at this location. We reference
this in META-INF/persistence.xml -->
<datasource jndi-name="java:jboss/datasources/WicketEarQuickstartDS"
pool-name="wicket-ear-quickstart" enabled="true"
use-java-context="true">
<connection-url>jdbc:h2:mem:wicket-ear-quickstart;DB_CLOSE_DELAY=-1</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
</datasources>

18 changes: 0 additions & 18 deletions wicket-ear/ear/src/main/resources/application.xml

This file was deleted.

87 changes: 14 additions & 73 deletions wicket-ear/ejb/pom.xml
@@ -1,71 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jboss.as.quickstart.wicket-ear</groupId>
<artifactId>as7-quickstart-wicket-ear-parent</artifactId>
<groupId>org.jboss.as.quickstarts</groupId>
<artifactId>jboss-as-wicket-ear-parent</artifactId>
<version>7.1.1-SNAPSHOT</version>
</parent>
<artifactId>as7-quickstart-wicket-ear-ejb</artifactId>

<artifactId>jboss-as-wicket-ear-ejb</artifactId>
<packaging>ejb</packaging>

<name>JBoss AS Quickstarts: Wicket EAR: EJB JAR</name>


<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Define the version of JBoss' Java EE 6 APIs and Tools we want to import.
Alternatively, use version 1.0.0.M5-redhat-1 which is a release certified to work with JBoss EAP 6.
It requires you have access to the JBoss EAP 6 maven repository.
-->
<jboss.bom.version>1.0.0.M5</jboss.bom.version>
</properties>

<dependencyManagement>
<dependencies>
<!--
Java EE 6 API.
JBoss distributes a complete set of Java EE 6 APIs including a Bill of Materials (BOM).
A BOM specifies the versions of a "stack" (or a collection) of artifacts.
We use this here so that we always get the correct versions.
* jboss-javaee-6.0-with-tools is a JBoss stack of the Java EE 6 APIs with extra tools, such as Arquillian for testing.
* jboss-javaee-6.0-with-hibernate is a JBoss stack of the Java EE 6 APIs with extras from the Hibernate family of projects.
* jboss-javaee-6.0 stack is a JBoss stack of the Java EE 6 APIs.
You can actually use it with any version of JBoss AS that implements Java EE 6, not just JBoss AS 7.
-->
<dependency>
<groupId>org.jboss.bom</groupId>
<artifactId>jboss-javaee-6.0-with-tools</artifactId>
<version>${jboss.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.bom</groupId>
<artifactId>jboss-javaee-6.0-with-hibernate</artifactId>
<version>${jboss.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>3.0.0.Beta1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<name>JBoss AS Quickstarts: Wicket EAR: EJB JAR</name>

<dependencies>

<!-- "provided" scope used for API's included in JBoss AS 7. -->

<!-- Import the Common Annotations API (JSR-250). -->
<dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
Expand All @@ -80,20 +32,19 @@
<scope>provided</scope>
</dependency>

<!-- Import the JPA API. -->
<!-- Import the JPA API. -->
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<scope>provided</scope>
</dependency>

</dependencies>


<build>
<plugins>

<!-- EJB archive creation. -->
<!-- Configure the maven-ejb-plugin to use EJB 3.1 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
Expand All @@ -102,18 +53,8 @@
<ejbVersion>3.1</ejbVersion>
</configuration>
</plugin>

<!-- Skip JBoss AS plugin - only applicable for the EAR package. -->
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.1.0.Final</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>


</plugins>
</build>

</project>
Expand Up @@ -27,7 +27,7 @@
* @author Filippo Diotalevi
*/
@Local
public interface ContactDaoLocal {
public interface ContactDao {

/**
* Returns the currently available contacts
Expand Down
Expand Up @@ -28,7 +28,7 @@
* A bean which manages Contact entities.
*/
@Stateless
public class ContactDaoBean implements ContactDaoLocal {
public class ContactDaoBean implements ContactDao {

@PersistenceContext
private EntityManager em;
Expand Down

0 comments on commit d39d3f3

Please sign in to comment.