JBoss Trading – Java EE 5 to Java EE 6 Migration Part V (Clean Up)

This is the final post in a series that covers the Java EE 5 to Java EE 6 migration of the JBoss Trading application (link).

This post covers both required and optional source code / configuration modifications for deployment, integration testing, and performance testing.


Performance Testing

If the packaging property is omitted from the JBoss AS (7) Maven plugin configuration, the default value is the project packaging property. If the value of the project packaging property is pom, the plugin goals are not executed. The packaging property is configured for the JBoss Trading Client Test Perf module as the value of the project packaging property is pom. It is configured for the remaining modules for consistency.

JBoss Trading Client Test Perf

  1. Update the JBoss AS (7) Maven plugin configuration.
    <configuration>
        <username>admin</username>
        <password>password</password>
        <targetDir>${project.build.directory}/dependency/</targetDir>
        <filename>trading-app.ear</filename>
        <packaging>ear</packaging>
    </configuration>

JBoss Trading EJB Client

  1. Update the JBoss AS (7) Maven plugin configuration.
    <configuration>
        <username>admin</username>
        <password>password</password>
        <targetDir>${project.build.directory}/dependency/</targetDir>
        <filename>trading-app.ear</filename>
        <packaging>ear</packaging>
    </configuration>

JBoss Trading REST Client

  1. Update the JBoss AS (7) Maven plugin configuration.
    <configuration>
        <username>admin</username>
        <password>password</password>
        <targetDir>${project.build.directory}/dependency/</targetDir>
        <filename>trading-app.ear</filename>
        <packaging>ear</packaging>
    </configuration>

JBoss Trading WS Client

  1. Update the JBoss AS (7) Maven plugin configuration.
    <configuration>
        <username>admin</username>
        <password>password</password>
        <targetDir>${project.build.directory}/dependency/</targetDir>
        <filename>trading-app.ear</filename>
        <packaging>ear</packaging>
    </configuration>

JBoss EAP 6 Apache Commons Beanutils Module

The META-INF/jboss-deployment-structure.xml file was created in the JBoss Trading Beans module, but a) it is only scanned by the test deployment and b) it was not created in the JBoss Trading App module.

Note: Setting export to true adds the JBoss EAP 6 module to the classpath of all of the modules in the EAR.

JBoss Trading App

  1. META-INF/jboss-deployment-structure.xml (create)
    <?xml version="1.0" encoding="UTF-8"?>
    <jboss-deployment-structure>
        <deployment>
            <dependencies>
                <module name="org.apache.commons.beanutils" export="true" />
            </dependencies>
        </deployment>
    </jboss-deployment-structure>

JBoss Trading Beans

  1. Update the Apache Commons Beanutils dependency.
    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>${commons-beanutils.version}</version>
        <scope>provided</scope>
    </dependency>
  2. META-INF/jboss-deployment-structure.xml (move)
    from src/main/resources to src/test/resources

Dependency Management

The JBoss Java EE 6 (bom) dependency is added to the JBoss Trading Parent module to simplify dependency management. The version numbers for several Java EE dependencies are no longer necessary. The Java EE dependencies that are not referenced by the JBoss Java EE 6 (bom) dependency are replaced with ones that are. Properties are added the JBoss Trading Parent module for the Arquillian dependency and the JBoss AS Arquillian dependency. In addition, the RESTEasy version property and the  SLF4J version property are updated to match the version of JBoss EAP 6 RESTEasy module and the JBoss EAP 6 SLF4J module.

The JBoss Nexus repository and plugin repository are no longer necessary as the required artifacts are pushed to the Maven Central repository.

Nor is a mirror of the old JBoss Maven repository required in the settings.xml file.

JBoss Trading Parent

  1. pom.xml (update)
    <properties>
        <arquillian-core.version>1.0.0.Final</arquillian-core.version>
        <arquillian.version>1.0.0.Final</arquillian.version>
        <arquillian-jbossas.version>1.0.0.CR3</arquillian-jbossas.version>
        <jboss-as-arq-container.version>7.1.1.Final</jboss-as-arq-container.version>
        <commons-beanutils.version>1.8.3</commons-beanutils.version>
        <cxf.version>2.5.1</cxf.version>
        <hibernate-annotations>3.4.0.GA</hibernate-annotations> 
        <jboss-as-client.version>5.1.0.GA</jboss-as-client.version> 
        <jboss-as-profileservice-client.version>6.0.0.Final</jboss-as-profileservice-client.version> 
        <jboss-ejb-api.version>3.0.0.GA</jboss-ejb-api.version> 
        <jboss-ejb3-ext-api.version>1.0.0</jboss-ejb3-ext-api.version> 
        <jboss-jms-api.version>1.1.0.GA</jboss-jms-api.version> 
        <resteasy.version>2.3.1.GA</resteasy.version> 
        <scannotation.version>1.0.2</scannotation.version>  
        <slf4j.version>1.6.1</slf4j.version> 
    </properties>
  2. Remove the JBoss Nexus repository and plugin repository.
    <repositories>
        <repository>
            <id>jboss</id>
            <name>JBoss Public Repository</name>
            <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>jboss</id>
            <name>JBoss Public Repository</name>
            <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
        </pluginRepository>
    </pluginRepositories>
  3. Add the JBoss Java EE 6 (bom) dependency.
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.spec</groupId>
                <artifactId>jboss-javaee-6.0</artifactId>
                <version>3.0.0.Final</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

JBoss Trading Beans

  1. Update the Arquillian dependency.
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-bom</artifactId>
                <version>${arquillian.version}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>
  2. Update the JBoss AS Arquillian dependency.
    <dependency>
        <groupId>org.jboss.as</groupId>
        <artifactId>jboss-as-arquillian-container-remote</artifactId>
        <version>${jboss-as-arq-container.version}</version>
    </dependency>
  3. Remove dependency versions.
    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <version>1.0-SP4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.1.Final</version>
        <scope>provided</scope>
    </dependency>
  4. Remove the JBoss Java EE EJB API & JMS API dependencies.
    <dependency>
        <groupId>org.jboss.javaee</groupId>
        <artifactId>jboss-ejb-api</artifactId>
        <version>${jboss-ejb-api.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.javaee</groupId>
        <artifactId>jboss-jms-api</artifactId>
        <version>${jboss-jms-api.version}</version>
        <scope>provided</scope>
    </dependency>
  5. Add the JBoss Java EE 6 EJB API and JMS API dependencies.
    <dependency>
        <groupId>org.jboss.spec.javax.ejb</groupId>
        <artifactId>jboss-ejb-api_3.1_spec</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.spec.javax.jms</groupId>
        <artifactId>jboss-jms-api_1.1_spec</artifactId>
        <scope>provided</scope>
    </dependency>

JBoss Trading EJB Client

  1. Remove the JBoss Java EE 6 (bom) dependency. (<dependencyManagement />)
    <dependency>
        <groupId>org.jboss.spec</groupId>
        <artifactId>jboss-javaee-6.0</artifactId>
        <version>3.0.0.Final</version>
        <scope>import</scope>
        <type>pom</type>
    </dependency>

JBoss Trading REST

  1. Remove dependency versions.
    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <version>1.0-SP4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.spec.javax.ws.rs</groupId>
        <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
        <version>1.0.1.Final</version>
        <scope>provided</scope>
    </dependency>

Interfaces

The objective is to ensure that a) the EJB, JAX-RS, and JAX-WS interfaces and / or implementations extend and / or implement the TradeManager interface and b) the client static factory methods return the class type rather than the TradeManager interface as the clients implement the TradeManager interface and the integration tests are executed with an instance of the class type.

JBoss Trading EJB Client

  1. TradingManagerClient.java (update)
    public static TradingManagerClient getInstance(String jndiName)

JBoss Trading REST

  1. TradingServices.java (update)
    public interface TradingServices extends TradingManager

JBoss Trading REST Client

  1. TradingServicesClient.java (update)
    public static TradingServicesClient getInstance(String baseUri)

JBoss Trading Web Services

  1. TradingServices.java (update)
    public class TradingServices implements TradingManager

Naming

The objective is for the interface and / or implementation class names to be TradingManager and TradingServices, the clients class names to be TradingManagerClient and TradingServicesClient, and the integration test class names to be TradingManagerClientIT and TradingServicesClientIT.

JBoss Trading API

  1. Rename TradeManager TradingManager.

JBoss Trading Beans

  1. Rename package.
    From: com.jboss.trading.services
    To: com.jboss.trading.ejb
  2. Rename package.
    From: com.jboss.trading.services.persistence
    To: com.jboss.trading.ejb.persistence
  3. Rename package.
    From: com.jboss.trading.services.persistence.factory
    To: com.jboss.trading.ejb.persistence.factory
  4. Rename package.
    From: com.jboss.trading.services.util
    To: com.jboss.trading.ejb.util
  5. Rename package.
    From: com.jboss.trading.services.test
    To: com.jboss.trading.ejb.test
  6. persistence.xml (update)
    <class>com.jboss.trading.ejb.persistence.LimitOrderEntity</class> 
    <class>com.jboss.trading.ejb.persistence.MarketOrderEntity</class> 
    <class>com.jboss.trading.ejb.persistence.StockEntity</class> 
    <class>com.jboss.trading.ejb.persistence.StockHolderEntity</class> 
  7. TradeManagerLocalIT.java (update)
    @Deployment
        public static JavaArchive createTestArchive() {
    
            return ShrinkWrap.create(
                    JavaArchive.class, "trading-services.jar")
                    .addPackage("com.jboss.trading.api")
                    .addPackage("com.jboss.trading.api.exception")
                    .addPackage("com.jboss.trading.api.model")
                    .addPackage("com.jboss.trading.ejb") 
                    .addPackage("com.jboss.trading.ejb.persistence") 
                    .addPackage("com.jboss.trading.ejb.persistence.factory") 
                    .addPackage("com.jboss.trading.ejb.util") 
                    .addPackage("com.jboss.trading.test")
                    .addAsResource("META-INF/beans.xml")
                    .addAsResource("META-INF/jboss-deployment-structure.xml")
                    .addAsResource("META-INF/persistence.xml")
                    .addAsResource("META-INF/trading-jms.xml")
                    .addAsResource("import.sql")
                    .addAsResource("test.properties");
        }
  8. Rename TradeManagerBean TradingManagerBean.
  9. Rename TradeManagerLocal TradingManagerLocal.
  10. Rename TradeManagerRemote TradingManagerRemote.
  11. Rename TradeManagerLocalIT TradingManagerLocalIT.
  12. Resources.java (update)
    @Produces
    @Named("TradingManagerBean")
    public TradingManager getTradingManager() {
    
        return tradingManager;
    }
  13. TradingManagerLocalIT.java (update)
    @Inject 
    @Named("TradingManagerBean")
    TradingManager tradingManager;

JBoss Trading EJB Client

  1. Rename package.
    From: com.jboss.trading.rmi.client
    To: com.jboss.trading.ejb.client
  2. Rename package.
    From: com.jboss.trading.rmi.client.test
    To: com.jboss.trading.ejb.client.tesr
  3. Rename TradeManagerClient TradingManagerClient.
  4. Rename TradeManagerClientIT TradingManagerClientIT.

JBoss Trading EJB Client Test Config

  1. pom.xml (update)
    <properties>
        <host>localhost</host>
        <port>4447</port>
        <jndi.name>ejb:trading-app/trading-beans//TradingManagerBean!com.jboss.trading.ejb.TradingManagerRemote</jndi.name>
    </properties>

JBoss Trading REST

  1. TradingServicesImpl.java (update)
    @Inject 
    @Named("TradingManagerBean") 
    TradingManager tradingManager;

JBoss Trading Rest Client

  1. Rename TradeManagerClient TradingServicesClient.
  2. Rename TradeManagerClientIT TradingServicesClientIT.

JBoss Trading Web Services

  1. TradingServices.java (update)
    @Inject 
    @Named("TradingManagerBean")
    TradingManager tradingManager;

JBoss Trading Client Test Distribution

The JMeter test plan is updated with the new class names.

Build & Test

mvn clean install -Plocalhost-remote

JBoss Trading – Java EE 5 to Java EE 6 Migration

  • Part I – CDI 1.0 & JAX-RS 1.1 (link)
  • Part II – JPA 2.0 & JAX-WS 2.2 (link)
  • Part III – Structure & Packaging (link)
  • Part IV – Deployment & Testing (link)
  • Part V – Clean Up
, , ,

About Shane K Johnson

Technical Marketing Manager, Red Hat Inc.

View all posts by Shane K Johnson

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 117 other followers

%d bloggers like this: