Application Structure

Java code generation

gx makes it easy to get started writing the application by generating classes for you, based on the configuration file. We can do this by running the following command.

Currently, gx gen all only supports pure Java projects. For others, files will have to be created manually.

$> cd my-wordcount
$> gx gen all -M
Running gx gen all with options:
  Path: .
 Force: false
Modify: true
Config: ./app.yaml

[INFO] Generating Constants
[INFO] Upserting class Constants
[SUCCESS] Generated classes and methods

Optional: If you have the tree utility installed on your machine, you can then visualize the application structure.

$> tree
├── app.yaml
├── pom.xml
└── src
    └── main
        └── java
            └── org
                └── sample
                    └── wordcount

Along with the action handler classes; a constants class, a client class, and the project build file have also been generated. contains an example for pushing an event to a topic. For WordCount, you will modify this file to read sentences from a text file and push them as events into the line_topic. contains variables for actions, subscriptions tables, and topics.

In the next step, you will modify these generated files with the business logic for WordCount.

Last updated