From ca84ed7ff0f7ada503390df8e0a01cd5a5ac1d5b Mon Sep 17 00:00:00 2001 From: Lukasz Rzeszotarski Date: Sun, 31 Jul 2016 18:36:03 +0200 Subject: [PATCH] BAEL-150 Introduction to DeltaSpike --- deltaspike/.cheatsheet.xml | 695 ------------------------------------- deltaspike/.factorypath | 5 - deltaspike/README.md | 98 ------ 3 files changed, 798 deletions(-) delete mode 100644 deltaspike/.cheatsheet.xml delete mode 100644 deltaspike/.factorypath delete mode 100644 deltaspike/README.md diff --git a/deltaspike/.cheatsheet.xml b/deltaspike/.cheatsheet.xml deleted file mode 100644 index 1d42a4099a..0000000000 --- a/deltaspike/.cheatsheet.xml +++ /dev/null @@ -1,695 +0,0 @@ - - - - - -This quickstart shows off all the new features of Java EE 7, and makes a great starting point for your project. -

-Bean Validation 1.1 -

-Bean Validation is an update specification for Java EE 7, inspired by Hibernate Validator. It allows application developers to specify constraints once (often in their domain model), and have them applied in all layers of the application, protecting data and giving useful feedback to users. -

-JAX-RS: The Java API for RESTful Web Services -

-JAX-RS is an update specification for Java EE 7. It allows application developers to easily expose Java services as RESTful web services. -
-
- - - The baeldung-jee7-seed application shows off a number of Java EE technologies such as CDI, JSF, EJB, JTA, JAX-RS and Arquillian. - It does this by providing a member registration database, available via JSF and JAX-RS. -

-As usual, let's start by looking at the necessary deployment descriptors. -By now, we're very used to seeing beans.xml and faces-config.xml in WEB-INF/ -(which can be found in the src/main/webapp directory of the example). -Notice that, once again, we don't need a web.xml. -There are two configuration files in WEB-INF/classes/META-INF -(which can be found in the src/main/resources directory of the example) — persistence.xml, -which sets up JPA, and import.sql which Hibernate, the JPA provider in WildFly, -will use to load the initial users into the application when the application starts. -We discussed both of these files in detail in The greeter example in depth, and these are largely the same. -
- -
- - - - Next, let's take a look at the JSF view the user sees. As usual, we use a template to provide the sidebar and footer. This one lives in WEB-INF/templates/default.xhtml: - - - - - - - - - - - - - - - - - - - That leaves the main page, index.xhtml, in which we place the content unique to the main page: - - - - - - - - - - - - - - - - - - - - - - - - Next, let's take a look at the Member entity, before we look at how the application is wired together: - - - - - - - - - - - - - - - - - - - - - - Let's take a look at MemberRepository, which is responsible for interactions with the persistence layer: - - - - - - - - - - - - - - - - - - - Next, let's take a look at MemberListProducer, which is responsible for building the list of members, ordered by name. It uses JPA 2 criteria to do this. - - - - - - - - - - - - - - - - - - - - Let's now look at MemberRegistration, the class that allows us to create new members from the JSF page - - - - - - - - - - - - - - - - Now, let's take a look at the Resources class, which provides resources such as the entity manager. CDI recommends using "resource producers", as we do in this example, to alias resources to CDI beans, allowing for a consistent style throughout our application: - - - - - - - - - - - - - - - - - - Of course, we need to allow JSF to interact with the services. The MemberController class is responsible for this: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Before we wrap up our tour of the baeldung-jee7-seed example application, - let's take a look at how the JAX-RS endpoints are created. Firstly, {JaxRSActivator}}, - which extends Application and is annotated with @ApplicationPath, - is the Java EE 6 no XML approach to activating JAX-RS. - - - - - - - - - - The real work goes in MemberResourceRESTService, which produces the endpoint: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Right-click the project and select Run As > Run On Server or click on the "Click to Perform" link below. - - - - - - - If you've been following along with the Test Driven Development craze of the past few years, - you're probably getting a bit nervous by now, wondering how on earth you are going to test your application. - Lucky for you, the Arquillian project is here to help! -

- Arquillian provides all the boiler plate for running your test inside WildFly, - allowing you to concentrate on testing your application. - In order to do that, it utilizes Shrinkwrap, a fluent API for defining packaging, - to create an archive to deploy. - We'll go through the testcase, and how you configure Arquillian in just a moment, - but first let's run the test. - -
-
- - - Arquillian defines two modes, managed and remote. - The managed mode will take care of starting and stopping the server for you, - while the remote mode connects to an already running server. -

- The following action starts the test in the remote mode because you have started the server in the previous step. -
- Right-click the project, select Properties>Maven and - enter arq-jbossas-remote to the Active Maven Profile field. - After that, right-click the project and select Run As>JUnit test. -
- - - -
- - - - So far so good, the test is running. But what does the test look like? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - As you can see, Arquillian has lived up to the promise - the test case is focused on what to test - (the @Deployment method) and how to test (the @Test method). - It's also worth noting that this isn't a simplistic unit test - this is a fully fledged integration - test that uses the database. -

- Now, let's look at how we configure Arquillian. - First of all, let's take a look at arquillian.xml in src/test/resources. -
- - - -
- - - - Now, we need to look at how we select between containers in the pom.xml: - - - - - - - - - - - - And that's it! As you can see Arquillian delivers simple and true testing. - You can concentrate on writing your test functionality, and run your tests in the same environment in which you will run your application. -

- Arquillian also offers other containers, allowing you to run your tests against Weld Embedded (super fast, but your enterprise services are mocked), GlassFish, and more. -

- More info on Arquillian you can find on the Arquillian project page. -
- -
- - - - What we didn't tell you about the baeldung-jee7-seed quickstart is that it is generated from a Maven archetype. - Using this archetype offers you the perfect opportunity to generate your own project. -

- In order to perform that, you should select Help>JBoss Central and click the Java EE Web Project wizard. -
- You will get a brand new project with the same functionality as baeldung-jee7-seed, - but customized with your details. -
-
- -
diff --git a/deltaspike/.factorypath b/deltaspike/.factorypath deleted file mode 100644 index 16e422aead..0000000000 --- a/deltaspike/.factorypath +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/deltaspike/README.md b/deltaspike/README.md deleted file mode 100644 index 098da30877..0000000000 --- a/deltaspike/README.md +++ /dev/null @@ -1,98 +0,0 @@ -baeldung-jee7-seed: Assortment of technologies including Arquillian -======================== -Author: Pete Muir -Level: Intermediate -Technologies: CDI, JSF, JPA, EJB, JPA, JAX-RS, BV -Summary: An example that incorporates multiple technologies -Target Project: WildFly -Source: - -What is it? ------------ - -This is your project! It is a sample, deployable Maven 3 project to help you get your foot in the door developing with Java EE 7 on JBoss WildFly. - -This project is setup to allow you to create a compliant Java EE 7 application using JSF 2.2, CDI 1.1, EJB 3.3, JPA 2.1 and Bean Validation 1.1. It includes a persistence unit and some sample persistence and transaction code to introduce you to database access in enterprise Java. - -There is a tutorial for this quickstart in the [Getting Started Developing Applications Guide](https://github.com/wildfly/quickstart/guide/baeldung-jee7-seed/). - -System requirements -------------------- - -All you need to build this project is Java 7.0 (Java SDK 1.7) or better, Maven 3.1 or better. - -The application this project produces is designed to be run on JBoss WildFly. - - -Configure Maven ---------------- - -If you have not yet done so, you must [Configure Maven](https://github.com/jboss-developer/jboss-developer-shared-resources/blob/master/guides/CONFIGURE_MAVEN.md) before testing the quickstarts. - - -Start JBoss WildFly with the Web Profile -------------------------- - -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](https://github.com/jboss-developer/jboss-eap-quickstarts#build-and-deploy-the-quickstarts) 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 wildfly:deploy - -4. This will deploy `target/baeldung-jee7-seed.war` to the running instance of the server. - - -Access the application ---------------------- - -The application will be running at the following URL: . - - -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 wildfly:undeploy - - -Run the Arquillian Tests -------------------------- - -This quickstart provides Arquillian tests. By default, these tests are configured to be skipped as Arquillian tests require the use of a container. - -_NOTE: The following commands assume you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See [Run the Arquillian Tests](https://github.com/jboss-developer/jboss-developer-shared-resources/blob/master/guides/RUN_ARQUILLIAN_TESTS.md) 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 the following command to run the test goal with the following profile activated: - - mvn clean test -Parq-wildfly-remote - - -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](https://github.com/jboss-developer/jboss-developer-shared-resources/blob/master/guides/USE_JBDS.md) - - -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