Java Reference
In-Depth Information
3. Open a command prompt or shell terminal, and then change to the
wildfly-8.0.0.Final/
bin
directory.
4. You must start Wildfly manually before you can run the example. To do this, execute
standalone.sh
or
standalone.bat
, depending on whether you are using a Unix- or
Windows-based system.
5. Open another command prompt or shell terminal and change to the
ex14_1
directory
of the workbook example code.
6. Make sure your PATH is set up to include both the JDK and Maven, as described in
7. Perform the build and run the example by typing
maven install
.
As described before, the
pom.xml
file within the project is configured to use a special JBoss
plug-in so that it can deploy the WAR file from the example to the application server. After
the WAR is deployed, the client test code will be executed. Following the execution of the
test, the WAR will be undeployed from JBoss by Maven.
Example ex14_2: Spring and JAX-RS
There isn't much difference between the code of
ex14_1
and
ex14_2
. The Java classes are
basically the same, except all the EJB
@Stateless
annotations were removed from the JAX-
RS resource classes because the example is using Spring instead of EJB for its component
model.
Besides the removal of EJB metadata, the differences between the two projects are mainly
packaging and configuration. If you look through the
ex14_2
directory, you'll see that we're
back to using embedded Jetty. The
web.xml
file is a tiny bit different than the EJB example,
so let's take a look at that first:
src/main/webapp/WEB-INF/web.xml
<web-app>
<web-app>
<context-param>
<context-param>
<param-name>
<param-name>
spring-beans-file
</param-name>
</param-name>
<param-value>
<param-value>
META-INF/applicationContext.xml
</param-value>
</param-value>
</context-param>
</web-app>
</context-param>
</web-app>
This example follows the Spring integration conventions discussed in
Chapter 14
.
The
web.xml
file adds a
<context-param>
to point to the Spring XML file that holds all of the
example's Spring configuration. Let's look at this Spring XML file:
src/main/resources/applicationContext.xml