Sun GlassFish Mobility Platform 1.1 Developer's Guide for Enterprise Connectors

Using NetBeans IDE to Create a JAX-RS Enterprise Connector

The simplest way to create a JAX-RS Enterprise Connector is to use NetBeans IDE 6.5 with the Maven plugin and the Maven archetypes for Sun GlassFish Mobility Platform.

ProcedureTo Install the Maven Plugin

Before You Begin

If you do not already have NetBeans IDE 6.5, go to http://www.netbeans.org/ to download and install it.

On the NetBeans IDE download page, select Java as the bundle to download. This bundle includes Java SE, Web, Java EE, and Java ME. When you install NetBeans IDE, click Customize to install only some of the components. Deselect all of the listed runtimes, since you are using the Sun GlassFish Mobility Platform version of Sun GlassFish Enterprise Server.

  1. Start NetBeans IDE.

  2. From the Tools menu, select Plugins.

  3. In the Plugins dialog, click the Available Plugins tab, then type Maven in the Search field.

  4. Select the checkbox for the Maven plugin, then click the Install button.

  5. Follow the instructions in the NetBeans IDE Installer wizard.

  6. After the wizard returns, click Close in the Plugins dialog.

  7. Choose Windows->Other->Maven Repository Browser.

  8. In the Maven Repository Browser tree, right-click the Java.net Repository node and select Update Index.

ProcedureTo Create a Maven Project for a JAX-RS Enterprise Connector

  1. In NetBeans IDE, click the Projects tab.

  2. Choose File->New Project.

  3. In the New Project dialog, select Maven from the Categories tree.

  4. Select Maven Project from the Projects list, then click Next.

  5. On the Maven Archetype page, expand Archetypes from the remote Maven Repositories node.

  6. From the list, select MEP Connector Archetype (JAX-RS), then click Next.

  7. On the Name and Location page, modify any default values you wish to, then click Finish.

    The new project appears in the Projects tab. The default project name is mavenproject1 (war).

  8. Under mavenproject1, expand the Source Packages node.

  9. Expand the com.mycompany.mavenproject1 node.

    Two class files appear, named MyBusinessObjectsResource.java and MyBusinessObjectResource.java. These classes correspond to the container-item pattern familiar to JAX-RS programmers.

Next Steps

To create the Enterprise Connector, you add code to these files and define your business object.

ProcedureTo View and Build the MusicDB JAX-RS Connector Project

  1. In NetBeans IDE, select File -> Open Project.

  2. In the Open Project window, navigate to sgmp-client-1_1_01-fcs-b02/samples/secure-musicdb/src/connector/jaxrs/musicdb-ws-3.1.39 and click Open Project.

    The musicdb-ws project appears in the Projects tab. The source files are under the Source Packages node.

    If the project has a red exclamation point next to it, right click the project and choose Show and Resolve Problems. In the window that appears, click the Download Libraries button. After a short delay, thewindow disappears and the red exclamation point no longer appears next to the project.

  3. Right-click the project and choose Build to build the project.

    The first time you build a project using the Maven plugin, the build takes a long time while Maven downloads a large number of libraries.