| By Murali Kashaboina, Geeth Narayanan | Article Rating: |
|
| September 1, 2007 05:00 AM EDT | Reads: |
25,679 |
Packaging and Installing 'Connector' Artifacts
With the current implementation of the plug-in, the plug-in won't
automatically create a separate JAR file for the module classes. If the
JAR file for the current classes is created separately, there's an
option to include the JAR in the final RAR file. Note that the
packaging type for the current module is 'rar' and so no separate JAR
file is created for the 'connector' classes. This means that we'll have
to explicitly add a separate plug-in to create the JAR file. This is
very simple to do just by adding 'maven-jar-plugin'
to the POM file. Note that the JAR plug-in should be put before the RAR
plug-in since the plug-ins are executed in the order they appear in the
POM file. The plug-in configuration added to the POM file is in Listing 2.
Note that by default both plug-ins get executed during the 'package' phase of the Maven lifecycle. To deploy the 'connector' RAR artifact to the local repository, right-click on the module's POM file in Eclipse and then in the 'Run As' options, select 'Maven2 install.' Maven will execute the configured plug-ins to build both JAR and RAR files in the 'target' build directory and will copy over the primary artifact, the RAR file, to the local repository along with the POM information.
Attaching Additional Artifacts
Sometimes, you may have to deploy additional artifacts to the Maven repository. For example, in the case of 'connector' module, we can attach the JAR file as an artifact along with the primary RAR artifact. This is fairly easy to do by using 'build-helper-maven-plugin' from the 'org.codehaus.mojo' plug-in group. The snippet below shows the configuration for the plug-in to attach the JAR file as an additional artifact.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/${project.build.finalName}.jar</file>
<type>jar</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
Please refer to the plug-in documentation at http://mojo.codehaus.org/build-helper-maven-plugin/index.html for additional information. After adding 'build-helper-maven-plugin' to the POM file, redeploy the 'connector' to the Maven repository and you should see the JAR file along with the RAR file deployed in the local repository as shown in Figure 7.
Setting Up an 'ejb' Module
We'll move on to create
an 'ejb' module with a default Maven project. To do this, go to the
'EmployeeInfo' directory on the command prompt and execute the
following Maven command:
mvn archetype:create -DgroupId=com.somecompany -DartifactId=ejb -Dversion=1.0
Refresh the 'EmployeeInfo' project in Eclipse and update the Maven source directories. Delete the sample Java class and its JUnit Test case. As in the case earlier, we'll use Maven's project inheritance model as described before and remove redundant version, group, and common dependency information from the 'ejb' POM file. Since this module will yield an EJB artifact, we'll change the packaging type to 'ejb' in the POM.
The 'ejb' module provides a stateless session bean that internally invokes the JCA connector to retrieve the Employee info XML object. This implies that the 'ejb' module will have dependencies on both 'xmlBinding' and 'connector' artifacts. However, since the 'connector' module already depends on the 'xmlBinding' module, it's sufficient to include dependency on the 'connector' artifact alone since Maven will transitively resolve dependencies and thereby transparently include dependency on the 'xmlBinding' artifact. Note that this module also needs compile-time EJB specification classes and classes from the J2EE connector specification as the Session bean refers to some of J2EE connector classes internally. We'll add dependencies on 'geronimo-spec-ejb-1.0-M1.jar' and 'geronimo-spec-j2ee-connector-1.0-M1.jar' with a scope value of 'provided.'
Finally, we'll add 'maven-ejb-plugin,' which gets executed during the 'package' phase and can build both the EJB JAR and EJB client JAR. Note that any client module that invokes an EJB can only include an EJB client JAR artifact as a dependency without dependency on the actual EJB JAR. This type of dependency inclusion will be shown later. Generating an EJB client JAR can be done by setting the 'generateClient' plug-in configuration element to true. Note that the contents of the EJB client JAR file can be customized using 'clientIncludes' and 'clientExcludes' plug-in configuration elements. By default, the plug-in excludes the following from the EJB client JAR.
- **/*Bean.class
- **/*CMP.class
- **/*Session.class
- **/package.html
The 'ejb-jar.xml' file and application server-specific EJB descriptor file should be put under the 'src/main/resources/META-INF' directory. The 'maven-ejb-plugin' by default picks them up from that location while building the EJB archive file. We'll add the necessary EJB source files for this module as shown in Figure 8. Please download and review the source code to understand the implementation.
The 'GetEmployeeInfoRemote' interface defines the business method 'getEmployeeInfo (String employeeId).' The 'GetEmployeeInfoBean' is the stateless session bean class that provides a concrete implementation for 'getEmployeeInfo' method as shown below.
public Employee getEmployeeInfo(String employeeId) throws Exception {
Employee employee = null;
try {
ConnectionFactory connectionFactory = getConnectionFactory();
Connection connection = connectionFactory.getConnection();
RecordFactory recordFactory = connectionFactory.getRecordFactory();
MappedRecord input = recordFactory.createMappedRecord("EmployeeInfoInput");
input.put(EmployeeInfoCCIRecordFactory.EMPLOYEE_ID_INPUT, employeeId);
MappedRecord output = recordFactory.createMappedRecord("EmployeeInfoOutput");
Interaction interaction = connection.createInteraction();
interaction.execute(null, input, output);
employee = (Employee) output.get(EmployeeInfoCCIRecordFactory.EMPLOYEE_RESULT);
} catch (Exception e) {
throw e;
}
return employee;
}
Published September 1, 2007 Reads 25,679
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Murali Kashaboina
Murali Kashaboina is a lead architect at Ecommerce Technology, United Airlines, Inc. He has more than 10 years of enterprise software development experience utilizing a broad range of technologies, including JEE, CORBA, Tuxedo, and Web services. Murali previously published articles in WLDJ and SilverStream Developer Center. He has master’s degree in mechanical engineering from the University of Dayton, Ohio.
More Stories By Geeth Narayanan
Geeth Narayanan is a senior architect at Ecommerce Technology, United Airlines, Inc. He has 10 years of experience in the IT industry, specializing in solutions using Java EE technologies. Geeth has master's degree in electrical engineering from the University of Toledo, Ohio.
![]() |
Aladin SOHAILI 10/06/07 04:38:08 PM EDT | |||
Any link to download source files ? |
||||
![]() |
Bob Arnold 09/11/07 02:34:39 PM EDT | |||
Regarding: "It's time to add connector implementation Java classes. The source files that we developed for the connector are shown in Figure 4. Please specify the download link for the source code referred to. |
||||
![]() |
vinny 09/04/07 08:40:13 AM EDT | |||
Where is the link to download source files for connector EmployeeInfoCCIConnection?? |
||||
![]() |
Magne 09/04/07 03:25:58 AM EDT | |||
It was with great interest I read these articles. -magne |
||||
![]() |
Duty Editor 08/31/07 01:16:44 PM EDT | |||
The Links to Parts I and II are to be found at the foot of the final page. -Duty Editor |
||||
![]() |
Jim 08/31/07 11:51:57 AM EDT | |||
Next time you write part 3 of a three-part series, please include clickable links to the first two parts right there at the top. |
||||
- Kindle 2 vs Nook
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Windows 7 – Microsoft’s First Step to the Cloud
- Ulitzer Provides a Powerful Social Journalism Platform
- Jill Tummler Singer, Deputy CIO of CIA, Keynotes at GovIT Expo
- Open Source Mobile Cloud Sync and Push Email
- Kindle 2 vs Nook
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- US Post Office Hops a Ride on NetSuite’s Cloud
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Building a Drag-and-Drop Shopping Cart with AJAX
- What Is AJAX?
- Google Maps! AJAX-Style Web Development Using ASP.NET
- Flashback to January 2006: Exclusive SYS-CON.TV Interviews on "OpenAjax Alliance" Announcement
- AJAXWorld Conference & Expo to Take Place October 2-4, 2006, at the Santa Clara Convention Center, California
- AJAX Sponsor Webcasts Are Now Available at AJAXWorld Website
- How and Why AJAX, Not Java, Became the Favored Technology for Rich Internet Applications
- "Real-World AJAX" One-Day Seminar Arrives in Silicon Valley
- AJAXWorld University Announces AJAX Developer Bootcamp
- AJAX Support In JadeLiquid WebRenderer v3.1
- Where Are RIA Technologies Headed in 2008?
- Struts Validations Framework Using AJAX






































