-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BeanManagerProvider quickstart added
- Loading branch information
Showing
21 changed files
with
1,340 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,5 @@ bin | |
.clover | ||
*.swp | ||
!/wicket-war/src/main/resources/META-INF/MANIFEST.MF | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
deltaspike-beanmanagerprovider: Shows how to use DeltaSpike BeanManagerProvider to access CDI in a EntityListener | ||
====================================================== | ||
Author: Rafael Benevides | ||
Level: Intermediate | ||
Technologies: CDI, Deltaspike, JPA, JSF | ||
Summary: Shows how to use DeltaSpike BeanManagerProvider to access CDI in a EntityListener | ||
Prerequisites: | ||
Target Product: WFK | ||
|
||
What is it? | ||
----------- | ||
|
||
This project demonstrates the use of DeltaSpike's BeanManagerProvider. | ||
|
||
`BeanmanagerProvider` provides access to the `BeanManager` by registering the current `BeanManager` during the startup. This is really handy if you like to access CDI functionality from places where no CDI based injection is available. If a simple but manual bean-lookup is needed, it's easier to use the `BeanProvider` instead. | ||
|
||
This projects uses an EntityListener to create audit records. EntityListeners aren't managed by CDI, so you can't inject dependencies. In this project we used `BeanManagerProvider` to get a reference to a Stateless EJB that is responsible to persist the audit records. | ||
|
||
|
||
System requirements | ||
------------------- | ||
|
||
All you need to build this project is Java 6.0 (Java SDK 1.6) or better, Maven 3.0 or better. | ||
|
||
The application this project produces is designed to be run on JBoss Enterprise Application Platform 6 or JBoss AS 7. | ||
|
||
|
||
Configure Maven | ||
--------------- | ||
|
||
If you have not yet done so, you must [Configure Maven](../README.md#mavenconfiguration) before testing the quickstarts. | ||
|
||
|
||
Start JBoss Enterprise Application Platform 6 or JBoss AS 7 | ||
------------------------- | ||
|
||
1. Open a command line and navigate to the root of the JBoss server directory. | ||
2. The following shows the command line to start the server with the web profile: | ||
|
||
For Linux: JBOSS_HOME/bin/standalone.sh | ||
For Windows: JBOSS_HOME\bin\standalone.bat | ||
|
||
|
||
Build and Deploy the Quickstart | ||
------------------------- | ||
|
||
_NOTE: The following build command assumes you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See [Build and Deploy the Quickstarts](../README.md#buildanddeploy) for complete instructions and additional options._ | ||
|
||
1. Make sure you have started the JBoss Server as described above. | ||
2. Open a command line and navigate to the root directory of this quickstart. | ||
3. Type this command to build and deploy the archive: | ||
|
||
mvn clean package jboss-as:deploy | ||
4. This will deploy `target/jboss-as-deltaspike-beanmanagerprovider.war` to the running instance of the server. | ||
|
||
Access the application | ||
--------------------- | ||
|
||
Access the running application in a browser at the following URL: <http://localhost:8080/jboss-as-deltaspike-beanmanagerprovider> | ||
|
||
You are presented with a simple form to insert, edit, or remove contacts. | ||
|
||
- To insert a new contact, click the `New Contact` button. Complete the form fields and then click the `Save` button. | ||
- To modify an existing contact, find the name in the *All Contacts* table and click the `Select for edit` button. The *Contacts* form fields are populated with the contact data. Modify the data and then click the `Save` button. | ||
- To remove a contact, find the name in the *All Contacts* table and click the `Remove` button. A dialog appears asking 'Do you want to remove this record?'. Click the `OK` button to remove the contact. | ||
|
||
When you insert a contact, notice that both the *All Contacts* and *Audit Records* tables are updated. | ||
When you edit a contact, notice that the *Audit Records* table is updated with the new contact data. | ||
|
||
Continue to insert, edit, or remove contacts to see registration of audit records. | ||
|
||
_NOTE: To fire the update audit, you must change one of the contact fields_ | ||
|
||
Undeploy the Archive | ||
-------------------- | ||
|
||
1. Make sure you have started the JBoss Server as described above. | ||
2. Open a command line and navigate to the root directory of this quickstart. | ||
3. When you are finished testing, type this command to undeploy the archive: | ||
|
||
mvn jboss-as:undeploy | ||
|
||
Run the Quickstart in JBoss Developer Studio or Eclipse | ||
------------------------------------- | ||
|
||
You can also start the server and deploy the quickstarts from Eclipse using JBoss tools. For more information, see [Use JBoss Developer Studio or Eclipse to Run the Quickstarts](../README.md#useeclipse) | ||
|
||
Debug the Application | ||
------------------------------------ | ||
|
||
If you want to debug the source code or look at the Javadocs of any library in the project, run either of the following commands to pull them into your local repository. The IDE should then detect them. | ||
|
||
mvn dependency:sources | ||
mvn dependency:resolve -Dclassifier=javadoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
<?xml version="1.0"?> | ||
<!-- JBoss, Home of Professional Open Source Copyright 2012, Red Hat, Inc. | ||
and/or its affiliates, and individual contributors by the @authors tag. See | ||
the copyright.txt in the distribution for a full listing of individual contributors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required | ||
by applicable law or agreed to in writing, software distributed under the | ||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
OF ANY KIND, either express or implied. See the License for the specific | ||
language governing permissions and limitations under the License. --> | ||
<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> | ||
|
||
<groupId>org.jboss.as.quickstarts</groupId> | ||
<artifactId>jboss-as-deltaspike-beanmanagerprovider</artifactId> | ||
<version>7.1.2-SNAPSHOT</version> | ||
<packaging>war</packaging> | ||
<name>JBoss AS Quickstarts: DeltaSpike Beanmanagerprovider</name> | ||
<description>DeltaSpike Beanmanagerprovider: shows how to use DeltaSpike BeanManagerProvider to access CDI in a EntityListener</description> | ||
|
||
<url>http://jboss.org/jbossas</url> | ||
<licenses> | ||
<license> | ||
<name>Apache License, Version 2.0</name> | ||
<distribution>repo</distribution> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url> | ||
</license> | ||
</licenses> | ||
|
||
<properties> | ||
<!-- Explicitly declaring the source encoding eliminates the following | ||
message: --> | ||
<!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered | ||
resources, i.e. build is platform dependent! --> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
|
||
<!-- JBoss dependency versions --> | ||
<version.org.jboss.as.plugins.maven.plugin>7.3.Final</version.org.jboss.as.plugins.maven.plugin> | ||
<version.org.jboss.bom>1.0.3.Final</version.org.jboss.bom> | ||
|
||
<!-- other plugin versions --> | ||
<version.compiler.plugin>2.3.1</version.compiler.plugin> | ||
<version.war.plugin>2.1.1</version.war.plugin> | ||
|
||
<!-- maven-compiler-plugin --> | ||
<maven.compiler.target>1.6</maven.compiler.target> | ||
<maven.compiler.source>1.6</maven.compiler.source> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<!-- Define the version of JBoss' Java EE 6 APIs we want to import. | ||
Any dependencies from org.jboss.spec will have their version defined by this | ||
BOM --> | ||
<!-- 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 of artifacts. Here we use the jboss-javaee-6.0-with-hibernate stack | ||
(you can read this as the JBoss stack of the Java EE 6 APIs with Hibernate) | ||
and jboss-javaee-6.0-with-deltaspike with extras from the DeltaSpike project. | ||
You can actually use this stack 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-hibernate</artifactId> | ||
<version>${version.org.jboss.bom}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.bom</groupId> | ||
<artifactId>jboss-javaee-6.0-with-deltaspike</artifactId> | ||
<version>${version.org.jboss.bom}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
|
||
<!-- Import the CDI API, we use provided scope as the API is included | ||
in JBoss AS 7 --> | ||
<dependency> | ||
<groupId>javax.enterprise</groupId> | ||
<artifactId>cdi-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Import the Common Annotations API (JSR-250), we use provided | ||
scope as the API is included in JBoss AS 7 --> | ||
<dependency> | ||
<groupId>org.jboss.spec.javax.annotation</groupId> | ||
<artifactId>jboss-annotations-api_1.1_spec</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Import the JSF API, we use provided scope as the API is included | ||
in JBoss AS 7 --> | ||
<dependency> | ||
<groupId>org.jboss.spec.javax.faces</groupId> | ||
<artifactId>jboss-jsf-api_2.1_spec</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Import the JPA API, we use provided scope as the API is included | ||
in JBoss AS 7 --> | ||
<dependency> | ||
<groupId>org.hibernate.javax.persistence</groupId> | ||
<artifactId>hibernate-jpa-2.0-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Import the JPA API, we use provided scope as the API is included | ||
in JBoss AS 7 --> | ||
<dependency> | ||
<groupId>org.jboss.spec.javax.transaction</groupId> | ||
<artifactId>jboss-transaction-api_1.1_spec</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Import the EJB API, we use provided scope as the API is included | ||
in JBoss AS 7 --> | ||
<dependency> | ||
<groupId>org.jboss.spec.javax.ejb</groupId> | ||
<artifactId>jboss-ejb-api_3.1_spec</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Import the Hibernate Validator API, we use provided scope as | ||
the API is included in JBoss AS 7 --> | ||
<dependency> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>hibernate-validator</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Deltaspike API. we use compile scope as we need its API --> | ||
<dependency> | ||
<groupId>org.apache.deltaspike.core</groupId> | ||
<artifactId>deltaspike-core-api</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
|
||
<!-- Deltaspike Impl. we use runtime scope as we its implementation | ||
dependencies only on runtime --> | ||
<dependency> | ||
<groupId>org.apache.deltaspike.core</groupId> | ||
<artifactId>deltaspike-core-impl</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<!-- Set the name of the war, used as the context root when the app | ||
is deployed --> | ||
<finalName>${project.artifactId}</finalName> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>${version.war.plugin}</version> | ||
<configuration> | ||
<!-- Java EE 6 doesn't require web.xml, Maven needs to | ||
catch up! --> | ||
<failOnMissingWebXml>false</failOnMissingWebXml> | ||
</configuration> | ||
</plugin> | ||
<!-- JBoss AS plugin to deploy war --> | ||
<plugin> | ||
<groupId>org.jboss.as.plugins</groupId> | ||
<artifactId>jboss-as-maven-plugin</artifactId> | ||
<version>${version.org.jboss.as.plugins.maven.plugin}</version> | ||
</plugin> | ||
<!-- Compiler plugin enforces Java 1.6 compatibility and activates | ||
annotation processors --> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${version.compiler.plugin}</version> | ||
<configuration> | ||
<source>${maven.compiler.source}</source> | ||
<target>${maven.compiler.target}</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> | ||
|
Oops, something went wrong.