previous next trail start tutorial home feedback openwings.org

Connector Generation

We use connectors primarily for protocol independence. Types of connectors presently available include:

  • Synchronous connectors
    • RMI
    • IIOP
  • Asynchronous connectors
    • OpenJMS

A synchronous connector is used when blocking communication is desired. In the HelloWorld example, the component using the service (HelloWorldUser) becomes a listener of HelloWorldProvider using the HelloWorldServiceSynchronous class and waits until the call returns before continuing. The connection achieved is a two step approach precipitated by the user. This approach is sometimes referred to as a "pull" action.

There are rules that must be applied for the construction of a synchronous interface:

  1. Throw java.rmi.RemoteException
  2. Have none, primitive type, or object parameters that are either serializable or remote object references.
  3. Return none, a primitive type, a serializable object, or a remote object

An asynchronous connector is used when non-blocking communication is desired. In the HelloWorld example, the component using the service (HelloWorldSubscriber) subscribes to a service using the interface (HelloWorldServiceAsynchronous) while the publisher (HelloWorldPublisher) publishes the service. Asynchronous connections are described as "push" connections - data is pushed through to the subscriber of this service. The connection achieved is unidirectional.

The following rules must be followed for asynchronous connections:

  1. Throw java.rmi.RemoteException
  2. Have none, primitive type, or object parameters that are either serializable or remote object references.
  3. Have no return value

Openwings uses the Java Messaging Service to provide asynchronous communication. Before you run asynchronous component applications, you will need to install the JMSClient and JMSServer components. These are provided for you in the Openwings demo component directory.

To generate and bundle your connectors we use an Ant build.xml file. Ant is discussed in more detail in the Component Compilation tutorial section. We have generated a build template file that you can copy and modify as needed (click here).  So, to generate and bundle an RMI connector, for example, use connector 1 in the build_template.xml file. The comments in the code specify that this is for RMI. A sample of the code is given below. Notice the line:

classname="com.gd.openwings.connector.synchronous.rmi.RMIConnectorBuilder" fork="yes"

This is exactly how HelloWorldServiceSynchronous is generated as a synchronous RMI connector. The code below was taken from the build.xml file for that component:

<!-- This target is building a specific connector -->
  <target name="connector1" depends="jar">
    <java classname="com.gd.openwings.connector.synchronous.rmi.RMIConnectorBuilder" fork="yes">
      <classpath>
        <pathelement location="${openwingsHome}/lib/ow_connector.jar" />
        <pathelement location="${openwingsHome}/lib/gd_connector.jar" />
        <pathelement location="${openwingsHome}/lib/gd_java.jar"/>
        <pathelement location="${targetJarFile}"/>
        <pathelement location="${targetClassPath}"/>
      </classpath>
      <arg value="ijs"/>
      <arg value="${connectorInterface1}"/>
      <arg value="${connectorJarFile1}"/>
      <arg value="connector1"/>
    </java>
  </target>

Here is the code to generate an  IIOP synchronous connection:

  <!-- This target is building a specific connector -->
  <target name="connector2" depends="jar">
    <java classname="com.gd.openwings.connector.synchronous.iiop.IIOPConnectorBuilder" fork="yes">
      <classpath>
        <pathelement location="${openwingsHome}/lib/ow_connector.jar" />
        <pathelement location="${openwingsHome}/lib/gd_connector.jar" />
        <pathelement location="${openwingsHome}/lib/gd_connector_iiop.jar" />
        <pathelement location="${openwingsHome}/lib/gd_java.jar"/>
        <pathelement location="${targetJarFile}"/>
        <pathelement location="${targetClassPath}"/>
      </classpath>
      <arg value="ijs"/>
      <arg value="${connectorInterface2}"/>
      <arg value="${connectorJarFile2}"/>
      <arg value="connector2"/>
    </java>
  </target>

Finally, for asynchronous connections, we presently use the JMS builder to build the connection. The code below was taken from the HelloWorldServiceAsync build.xml file:

  <!-- This target is building a specific connector; JMS asynch -->
  <target name="connector1" depends="jar">
    <property name="connectorJarFile"  value="${connectorJarFile1}"/>
    <java classname="com.gd.openwings.connector.asynchronous.openjms.broadcast.JMSConnectorBuilder" fork="yes">
      <classpath>
        <pathelement location="${targetJarFile}"/>
        <pathelement location="${targetClassPath}"/>
        <pathelement location="${openwingsHome}/lib/ow_connector.jar"/>
        <pathelement location="${openwingsHome}/lib/gd_connector.jar"/>
        <pathelement location="${openwingsHome}/lib/gd_java.jar"/>
      </classpath>
      <arg value="injs"/>
      <arg value="${connectorInterface1}"/>
      <arg value="${package}.HelloWorldServiceAsynchronousConnector"/>
      <arg value="${connectorJarFile1}"/>
      <arg value="connector1"/>
    </java>
  </target>

After you have modified your build.xml file, execute the following commands:

ant build
or
ant connector

Now you have successfully generated and bundled your connector.

Next: Using Policies

back to top

Copyright 2002, General Dynamics Decision Systems. All rights reserved.

previous next trail start tutorial home feedback openwings.org