Mik Arber is a software architect and a HMI expert for one of the largest European defence company. He works on near-real time software and systems architectures. He had experience on Electronic warfare, Martime patrol, Intelligence and air traffic management systems. He also uses his graphical knowledge to create highly responsive and interactive HMI, which display high amount of data at high frequencies. He has 17 years of software professional experience, during he worked in Internet domain for Ericsson and in industrial sector for Alstom. He created the open source project C³ : "http://c3.capcaval.org" and laFabrique : "http://lafabrique.capcaval.org". He is one of the two FinistJUG founder, look at "http://finistjug.fr". During his spare time, he loves drawing cartoons and creating illustrations. As a complement to graphical art, he enjoys a lot photography. Some of his digital work can be seen, on his blog, at "http://miksblog.capcaval.org" and for french reader "http://100pcpc.com". Mik has posted 2 posts at DZone. You can read more from them at their website. View Full User Profile

Control your software application with C³

  • submit to reddit
is a Java library providing a component abstraction capacity, as its main feature. The use of components and a component model is highly recommended to structure your software. Before defining your software’s component structure, you need to define what the users of your application will be able to do and how they will be able to do it. In order to enable this definition, provides an Application class, whose presentation and description is the subject of this article.

An application can be seen as a black box, created by a “coder” and used by a “user”. Their needs are different. The coder wants to write the simplest program that renders the requested functions. The user wants to be able to configure the application easily and to have access to a decent documentation. A very simple example is used throughout this article, the famous “HelloWorld” application, whose functionality is simply to perform greetings. Let us see together what might provide for such an application.


 Application class provides the following features :

- application state-machine : the software coder can benefit from the simple C³ application state machine. Let’s us start with only two states “Running” and “Closed”. By sub-classing the abstract Application class, the compiler will force you to implement the events. At run-time, your events will be called before each state change,

- application property : the application shall be configurable by the software user with Java properties (other configuration type might be added in future version). The annotation called @AppProperty handles simply this functionality in a declarative manner and C³ does the plumbing for you.

- generic help with auto-documented mechanism : no plumbing code needs to be added to display the application name, the “about” information and the properties. C³ discovers automatically all the application features and displays them, when the software user adds the “-help” parameter to its software launch command.





Application annotation

C³ provides an application annotation mechanism in which the version can be set and an “about” text added. This information will be accessible to the software user.


@AppInformation (version="1.0", about="This a Hello world application with C³")
public class HelloWorldApplication extends Application {


Application state machine

 For our simple example, C³ provides an application state-machine with only two states: “Running” and “Closed”. Just before reaching one of the two states, C³ will notify you with the corresponding event: notifyApplicationToBeRun or notifyApplicationToBeClosed.
The first event is called when all AppProperties are ready, and when the components are created. A future paper will focus on components. Basically, this event has to be used to configure and to start your application.
The second event is called when the application is stopped. C³ detects, for you, that your application is closing and notifies this. The Event can be used to properly close resources such as a socket, a database, a file, etc.


@AppInformation (version="1.0", about="This a Hello world application with C³")
public class HelloWorldApplication extends Application {
    public void notifyApplicationToBeRun(String applicationDescrition, String componentsDescription) {
        System.out.println("Application started");
    public void notifyApplicationToBeClosed() {
        System.out.println("bye bye, application closed");

AppProperty annotation

Java language provides system property that can be set either on Java command line with “-D” prefix or by loading a property file. A property is a key/value pair, where each value is accessed through the associated key.

C³ provides annotations in order to automatically link a property to your class application member. The principle is basic, by being declarative. This way the code is more functional and less technical. What you have to do is to add, as class member, the needed configuration inside your application class. For instance, let’s say that an application needs to be configured with a name to greet. All you have to do is to add, inside your own Application’s sub class, a member like :

String name = "World";

The above piece of code can be read as: this is a property called “name” and its default value is “world”. Automatically the “name” system property is available to configure your application.

Min and max value can be added for some numerical properties

@AppProperty(comment = "primitive value", min = 3, max = 7)
int intValue1 = 5;

Application member types supported are listed in the following table :


Extra types can be easily added by implementing the generic interface ObjectFactoryFromStringValue which shall return the defined generic type from a string. When the factory is written just add it with the following method at your application creation.

public void addNewObjectFactory(Class objectFactoryType, ObjectFactoryFromStringValue factory)




Application command line

C³ provides default command parameters such as the keyword “-help”, “-h”, “–help” or “–h”. When called with one of this parameters, C³ writes on the system output :

  • the application name of the application,
  • “about” information,
  • version of the application
  • the list of properties, with their types.

You can either use your own code typed from the samples or download the ready to use classes

At http://c3.capcaval.org/download.html download :

  • C3.jar
  • HelloWorldApplication.zip

Unzip the file, and go inside the root directory. You need to run with a Java7 jre. After launch the following command line :

java -cp .:./c3.jar c3sample.HelloWorldApplication

 with the following result

Application started
Hello World!
bye bye, application closed

line 1 : application first state
line 2 : greetings with the default value
line 3 : application last state

In order to know the available application properties used the -help parameter as follows :

Application Name : HelloWorldApplication
Version : 1.0
About : This a Hello world application with C³
The available properties are :
    comment : Application which salute anyone.
    type : String

line 2 : application name
line 3 : application version
line 4 : application information
line 7-9 : description of the “name” property


Configure your application

Of course the default value, “world” in our case can be changed by using the “name” property. Just type the following command line:

java -cp .:./c3.jar -Dname="Uzy" c3sample.HelloWorldApplication

The result should be :

Application started
Hello Uzy!
bye bye, application closed

line 1 : application first state
line 2 : greetings with the configured value
line 3 : application last state

The original article is available at "http://miksblog.capcaval.org/2012/01/control-your-software-application-with_c3/".you can also download the pdf version, here.
Thanks to Laurent, Yannick and Olivier for their review.

applicationBlackBox.png220.36 KB
cody.png35.09 KB
tableautype.png47.72 KB
uzy.png41.98 KB
basicApplicationState.png79.39 KB
Published at DZone with permission of its author, Mik Arber.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Christophe Hunt... replied on Tue, 2012/02/07 - 3:06am

Good article.

What I like with C3 is explicit contracting. That something missing in OSGI, in OSGI event for exemple, where all is keyed by String and contained in Map or Properties. Explicit contracting is something we have in CCM and SCA and I like them too.

C3 is lightweight and easy to use. For small, full Java and not distributed development, I prefer it to SCA: there is not XML in C3 to describe the component.

Thanks Mik for that good job. 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.