previous next trail start tutorial home feedback openwings.org

Writing Hello World

2. HelloWorldPublisher

Source code: HelloWorldPublisher.java

The HelloWorldPublisher component will

  • Create a publisher of the service
    • get a reference to the component
    • publish the service
    • note: component services will take care of distributing the object

In the synchronous connection example, the server side (HelloWorldProvider) implemented the interface (HelloWorldServiceSynchronous). The user (HelloWorldUser) became a listener of HelloWorldProvider using the HelloWorldSynchronous class and waited until the call returned before continuing. This action is sometimes referred as a "pull" action.

With an asynchronous service, the client (HelloWorldSubscriber) implements the interface (HelloWorldServiceAsynchronous). The constructor gets a component from the componentFactory and simply publishes the asynchronous (event or messaging) service HelloWorldServiceAsynchronous. We don't have to distribute the object. The call:

ServiceResult result = component.publishService(HelloWorldServiceAsynchronous.class);

does that for you. In the Connector section of the Developing Components trail, asynchronous connections are described as "push" connections - data is pushed through to the subscriber of this service. In this example, it is done in the following line of code:

service.helloWorld(++count + " Hello World!");

Note: HelloWorldPublisher is a simple class that implements Thread. The use of Thread is not required.

Next: HelloWorldSubscriber

back to top

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

previous next trail start tutorial home feedback openwings.org