Waza Channel Generator Tutorial

Copyright © 2016-2017 Wazalogic. All rights reserved.

A call-channel is an interface-specific channel. Processes can call and accept services on the call-channel. These services are specified by a custom-defined interface. The channel implementation is based on this interface and it provides this interface by its channel-ends. The channel-ends are used by the processes to pass messages over the channel. Generics are useful to create data-channels, but generics are unsuitable for creating call-channels. A call-channel class must be created for every interface. Furthermore, the call-channel class is accompanied by other interface-specific classes that are required to enhance communication, i.e. unbuffered, buffered and conditional communication. In order to simplify and to automate the creation of call-channel classes, we have created the Waza Channel Generator tool.

The Waza Channel Generator (WazaCG) is a tiny tool for generating call-channel classes for various programming languages. It is simple to use. The WazaCG tool inputs a Java interface and it generates multiple files. The WazaCG tool is a command-prompt application.

Latest Update: March 3, 2017.

Introduction

Example

Suppose we have created the following interface in Java. It is saved in MyInterface.java.
[java] public interface MyInterface {
/**
* Perform doThis with a value.
*
* @param value
* The Value.
*/
public void doThis(int value);

/**
* Perform doThat.
*/
public void doThat();
}
[/java]

Listing 1. Interface that is buffered channel ready.

The command to generate the channel classes is:

java -jar ./WazaCG.jar -l java -n MyInterface -i MyInterface

The WazaCG options are:

-l java Specifies the java language. If not specified then it takes Java as the default language.
-n MyInterface Specifies the prefix for the channel name. If not specified then it takes the interface name(s) as the prefix. See -i.
-i MyInterface Specifies one or more interfaces on which the channel is based. Extensions (.java) do not have to be specified. This option is mandatory.

The following files are generated:

  • MyInterfaceChannel.java
  • MyInterfaceUnbufferedChannel.java
  • MyInterfaceBufferedChannel.java
  • MyInterfaceAccept.java
  • MyInterfaceAcceptGuard.java
  • MyInterfaceAcceptOption.java

These are small files that you need to add to your project.

The interface in Listing 1 can be used for unbuffered and buffered channels. An interface that specifies one or more services with return types cannot be used with buffered channels. See for example Listing 2.
[java] public interface MyInterface {
/**
* Perform doThis with a value.
*
* @param value
* The Value.
*/
public void doThis(int value);

/**
* Perform doThat.
*/
public void doThat();
/**
* Peform a calculation.
*
* @param x
* A value.
* @param y
* A value.
* @return The result.
*/
public int doCalc(float x, double y);
}
[/java]

Listing 2. Interface that is not buffered channel ready.

The service doCalc() returns an integer value. Therefore, WazaCG tool will not generate MyInterfaceBufferedChannel.java.