previous next trail start tutorial home feedback openwings.org

Writing HelloWorld

Openwings HelloWorld Demos

The next few sections will provide details about the actual code used in the demo applications as well as an introduction to some key concepts. The demo applications are:

  1. HelloWorld Synchronous
    • HelloWorldServiceSync_im
      • HelloWorldServiceSynchronous.java - This interface defines the synchronous version of helloworld. A service user invokes this method on the service provider to get the hello string.
    • HelloWorldProvider_im
      • HelloWorldProvider.java - is a very simple example of a service provider. This component implements the HelloWorldServiceSynchronous interface.
    • HelloWorldSimpleUser_im
    • HelloWorldUser_im
      • HelloWorldUser.java - This class also uses a HelloWorldServiceSynchronous service. This implementation will attach to all available providers and periodically request their hello message. This shows a simple example of a service user.

  2. HelloWorld Asynchronous
    • HelloWorldServiceAsync_im
      • HelloWorldServiceAsynchronous.java - This interface defines the asynchronous version of helloworld. A service publisher pushes out data by invoking this method. A service subscriber receives this data by implementing this interface.
    • HelloWorldPublisher_im
      • HelloWorldPublisher.java - This class implements a simple service publisher. When run, this class will send a numbered helloworld message every few seconds.
    • HelloWorldSubscriber_im
      • HelloWorldSubscriber.java - implements a HelloWorldServiceAsynchronous interface making it available to listen for hello world events.

While we discuss the Java code we will also be introducing key concepts. The information we will be going through is listed below:

  1. Writing helloworld synchronous
  2. Writing helloworld asynchronous
  3. Component compilation
  4. Deployment
  5. Various ways to run a component

These topics are discussed again in more detail in the Developing Components tutorial trail.

Openwings Interfaces

Before we discuss the details of constructing HelloWorld components, it will be helpful to introduce the notion of the interfaces and how they are used in Openwings.

Interfaces allow us to declare the nature of a service without specifying the implementation. Think of an interface as a contract that has methods, fields, and comments. The implementor of the interface can define the specific semantic behavior of the interface. For example, if the user of the interface does not comply with interface constraints, checks can be used to raise exceptions when the contract is broken.

Details of these interfaces are provided in the Defining Service Contracts portion of this tutorial. There is also a nice definition of interfaces found here. For now, however, just be aware that there are several types of interfaces. The HelloWorld demo provides good examples of asynchronous and synchronous service interfaces.

The control of interfaces is perhaps the most important part of defining and maintaining a software design before, during, and after implementation. To facilitate this, interfaces are defined in their own packages. As you peruse the HelloWorld component code, observe how packages are declared and imported.

Next: HelloWorldSynchronous

back to top

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

previous next trail start tutorial home feedback openwings.org