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

Building, Deploying, and Configuring a JAX-RS Enterprise Connector

Once you have used NetBeans IDE to create a JAX-RS Enterprise Connector, build it by right-clicking the project and choosing Build.

To deploy the Enterprise Connector, use the Sun GlassFish Enterprise Server Administration Console. You must also configure a connector connection pool and a connector resource for the Enterprise Connector.

By default, the MusicDB JAX-RS Enterprise Connector is deployed in an installed version of Sun GlassFish Mobility Platform. However, it is not configured. If you would like to use this connector, you must undeploy the deployed connector and deploy the version you opened and built in To View and Build the MusicDB JAX-RS Connector Project.

Deploying and configuring an Enterprise Connector involves the following tasks:

ProcedureTo Start the Sun GlassFish Enterprise Server and Database

  1. In NetBeans IDE, click the Services tab.

  2. Right-click the Servers node and choose Add Server.

    The Add Server Instance dialog opens.

  3. On the Choose Server page, select GlassFish V2 and click Next.

  4. On the Platform Folder Location page, click Browse and navigate to the location of the Enterprise Server, then click Choose.

    The Enterprise Server location appears in the Platform Location field.

  5. Click Next.

    The Domain Admin Login Info appears.

  6. Verify that the Admin Username is correct, and type the administrator password in the Admin Password field.

    The default password is adminpass.

  7. Click Finish.

    GlassFish V2 appears under the Servers node.

  8. If the Enterprise Server is not already running, right-click GlassFish V2 and choose Start.

  9. Expand the Databases node.

  10. If your database (either MySQL or Oracle) is not running, right-click the database and choose Start.

    If the database does not start, you may have to edit the database properties to specify your password.

ProcedureTo Deploy an Enterprise Connector

  1. Log in to the Enterprise Server Administration Console.

    1. In a browser, type the Administration Console URL (usually http://localhost:4848/).

    2. Type the administrator username and password (usually admin and adminpass).

    3. Click the Login button.

  2. In the navigation tree, expand the Applications node.

  3. Under the Applications node, select the Web Applications node.

    The Web Applications page opens.

  4. (Optional) If you plan to deploy the MusicDB JAX-RS Enterprise Connector, select musicdb-ws and click the Undeploy button.

  5. Click the Deploy button.

    The Deploy Enterprise Applications/Modules page opens.

  6. On the Deploy Enterprise Applications/Modules page, verify that Packaged File to be Uploaded to the Server is selected, then click Browse.

  7. In the file chooser, navigate to the location of the WAR file and click Open.

    The WAR file is normally in the directory NetBeansProjects/project-name/target. On a Windows system, the NetBeansProjects directory is under My Documents.

    The new musicdb-ws project is in the directory sgmp-client-1_1_01-fcs-b02/samples/secure-musicdb/src/connector/jaxrs/musicdb-ws-3.1.39/target.

  8. If necessary, change the Application Name and Context Root by removing the version part of the WAR file name.

  9. Click OK.

    The deployed Enterprise Connector appears in the Web Applications table.

Next Steps

Next, use the Enterprise Server Administration Console to configure the Enterprise Connector.

ProcedureTo Create a Connector Connection Pool for the Enterprise Connector

  1. In the navigation tree, expand the Resources node.

  2. Under the Resources node, expand the Connectors node.

  3. Select Connector Connection Pools.

    The Connector Connection Pools page opens.

  4. Click the New button.

    The New Connector Connection Pool (Step 1 of 2) page opens.

  5. In the Name field, type mep/connector-name, where connector-name is the name of your Enterprise Connector.

    For MusicDB, the name should be mep/musicdb-ws.

  6. From the Resource Adapter drop-down list, select ds-jcr-connector-jaxrs, the JAX-RS connector bridge.

    The connection definition, javax.resource.spi.ManagedConnectionFactory, is filled in automatically.

  7. Click Next.

    The New Connector Connection Pool (Step 2 of 2) page opens.

  8. Click Finish to accept the default settings.

    The new connector connection pool appears in the Connector Connection Pools table.

Next Steps

Next, you must create a connector resource for the Enterprise Connector.

ProcedureTo Create a Connector Resource for the Enterprise Connector

  1. Under the Connectors Node, select the Connector Resources node.

    The Connector Resources page opens.

  2. Click New.

    The New Connector Resource page opens.

  3. In the JNDI Name field, type mep/connector-name, where connector-name is the name of your Enterprise Connector.

    For MusicDB, the name should be mep/musicdb-ws.

  4. From the Pool Name drop-down list, select mep/connector-name, the connection pool you created.

    For MusicDB, the name should be mep/musicdb-ws.

  5. Click OK.

    The new connector resource appears in the Connector Resources table.

ProcedureTo Verify that an Enterprise Connector Is Deployed

  1. In your browser, open the URL for the business objects, using this syntax:


    http://server:port/context-root/resources/businessObjects
    

    For example, for the MusicDB Enterprise Connector, you would specify the following for a locally running Enterprise Server:


    http://localhost:8080/musicdb-ws/resources/albums
    

    Specifying this URL is equivalent to invoking the getBusinessObjects method.

  2. Verify the content of the page that opens.

    If the Enterprise Connector is running, an XML document opens in your browser, containing a businessObjects element that encloses zero or more businessObject elements. Each businessObject element contains a name field and a binary representation.

ProcedureTo Configure the Enterprise Connector on Sun GlassFish Mobility Platform

Add and configure the JAX-RS Enterprise Connector as a local Enterprise Connector using the Sun GlassFish Mobility Platform Administration Console.

You can also configure the Enterprise Connector as a remote Enterprise Connector if you deploy it on a remote system. For instructions, see To Create and Activate a New Enterprise Connector in Sun GlassFish Mobility Platform 1.1 Administration Guide and To Configure a Remote Enterprise Connector in Sun GlassFish Mobility Platform 1.1 Administration Guide.

  1. Log in to the Sun GlassFish Mobility Platform Administration Console.

    1. In a browser, type the Administration Console URL (usually http://localhost:8080/sync/admin).

    2. Type the username and password (the default values are admin and syncpass).

    3. Click the Login button.

  2. Click the Connectors tab.

  3. In the Name field of the Local Enterprise Connectors panel, type the name of the Enterprise Connector (for example, MusicDbRS).

  4. Click Add.

    The new Enterprise Connector appears in the list of repositories. The Active checkbox is selected by default, indicating that the Enterprise Connector has been activated.

    A new sub-tab for the Enterprise Connector appears. You can now configure the new Enterprise Connector.

  5. Click the sub-tab for the connector.

  6. In the Local Enterprise Connector Settings panel, type the JNDI name of the connector resource you created in To Create a Connector Resource for the Enterprise Connector (for example, mep/musicdb-ws) and click Save.

  7. In the Local Enterprise Connector Properties panel, specify a value for the uri property.

    For the MusicDB connector, this value is http://localhost:8080/musicdb-ws/resources/albums.

  8. (Optional) If you are configuring the MusicDB Enterprise Connector, in the same panel, specify a value of true for the useTimestamps property.

    If you do not set the property, or if you set it to false, the MusicDB connector will use digests instead of timestamps to determine whether a business object has been updated since the last synchronization.

  9. Click Save in the Local Enterprise Connector Properties panel.

Next Steps

You can now perform synchronizations using the Enterprise Connector.