Author: Timo Laitinen
Date: 2004-10-02
JICE Concept and philosophy
Contents
1. Component based application construction model
1. 1. Application initialization in standard Java
1. 2. Playing with Lego blocks
1. 3. Application construction model in JICE
2. JIC file visualizes the structure of the application
3. Configuration of unexpected properties
3. 1. Parametrization of a Java class
3. 2. Parametrization in Java property files
3. 3. Parametrization in JICE
4. Attributes are used for meta-data
5. Laborous to create, easy to modify
6. Disadvantages
6. 1. A new XML format needs to be learned
6. 2. JIC Language is for Java programmers
6. 3. No security or information hiding
6. 4. Performance overhead
1. Component based application construction model
The term application refers here to a graph of Java objects. It can be a Java desktop application, an applet, a servlet or a part of an application. The construction or initialization of an application refers to the process where the objects of the application are created and where the state of the objects is set.
1. 1. Application initialization in standard Java
Standard Java tools don't specify how an application is Typically, the code that initializes the application is scattered across many application classes. Inside a class the initalization logic is probably placed in the constructor or into some init method, but there is no normally central location that would specify the structure of the application.
Some information that is likely to be changed very often is put in configuration files. The most popular configuration files are still probably Java properties files.
1. 2. Playing with Lego blocks
Lego blocks are simple components that, when attached to another Lego blocks, can form more complex structures. Almost any kind of a toy can be built from a set of elementary building blocks, which has made Lego technology popular amongst children in many generations.
Here is a format description of the process of constructing a toy with Lego blocks.
-
Instructions list detailed step-by-step procedures that are needed to create a toy. The instructions specify the kind of Lego blocks needed and how they are attached.
- Of course, most children don't always follow the official instructions but create the toys by using their imagination. But if you by a Lego set, it will contain instructions on how to create the toys that you see in the cover of the set.
- There is a storage of available Lego blocks. The construction requires that the storage contains the required blocks.
- The child follows the instructions and builds the toy:
- the required blocks must be picked out of the storage
- the blocks must be attached to each other.
- When all the instructions have been applied, the toy is finished. The toy consists of a set of inidividual Lego blocks. The toy may be used in several ways:
- The child that constructed or some other child it may play with it.
- The toy can be merged into a bigger whole: a toy-car may be used together with other cars to create a scene of a car-race.
- etc.
1. 3. Application construction model in JICE
JICE copies the toy construction model of the Lego world and uses it to construct Java applications. Here is an overview of the process:
Similarities to the Lego process are obvious. Here is a explanation of the details:
- The instructions are put into a JIC file that specifies the kind of Java instances needed and how they are combined together.
- In addition to the JIC file, some runtime parameters can be provided.
- Classpath specifies what kind of Java classes are available and therefore specifies the kind of Java objects that can be created. A succesful construction requires that the classpath contains required classes.
- JIC Engine follows the instructions, creates the required Java objects and combines them as required.
- When all the instructions have been applied, the Java application is initialized. The application is a graph of Java objects i.e. a Java object that has references to other Java objects. The application may be used in several ways:
- It could be used as is, for example if the application is a standalone desktop application.
- The application could be a part of a bigger whole: a component in some application, etc.
- etc.
2. JIC file visualizes the structure of the application
If the application initialization logic is scattered among many Java classes, it is difficult to understand the structure of the application.
Tools like UML can be used for visualizing the relationships of the types (classes) but it doesn't provide information on the objects (instances).
JICE makes it possible to put most, if not all, of the application initialization logic into a centralized location. The configuration written in JIC Language describes instances, not classes. The mapping from the XML format to the Java objects is also direct, i.e. the XML tree corresponds very closely to the Java object tree.
Therefore the XML tree in the JIC file provides at least some kind of a visualization of the structure of the application.
3. Configuration of unexpected properties
Any property can be configured - not just those that were expected to be configured.
This advantage is evident especially when comparing JICE with the use of Java properties files.
3. 1. Parametrization of a Java class
When a Java class is written, the author of the class must provide some ways to parametrize the behaviour of the instances of the class. This means that the author adds various kinds of constructors and setXXX-methods into the class. The decisions of the author can limit the ways how the objects of the class can be parametrized.
3. 2. Parametrization in Java property files
If the application is to be configured with Java properties, the author of the configuration system must decide what properties of the Java class in question can be configured with the properties file. This is a second decision that can limit the the ways how the objects of the class can be parametrized. Probably only the most critical properties can be configured first. Support for the configuration of other properties is added as the application matures. The support for a new property must always be coded into the application.
3. 3. Parametrization in JICE
JICE can call any method of an object that is specified in a JIC file. The programmer doesn't have to make the second limiting decision as in the case with Java properties files.
The configuration of properties that were not expected to be changed doesn't require a code-change. Only re-configuration.
4. Attributes are used for meta-data
JIC Language uses attributes only describing meta-data and put all actual data-values into elemens and cdata sections. All Java-specific details are put into attributes. Elements visualize the structure of the Java-application and all the actual data values are put into cdata-sections.
Here is a short JIC file that creates a javax.swing.JFrame
, sets a few of its properties and puts a javax.swing.JLabel
inside the JFrame.
<jframe xmlns="http://www.jicengine.org/jic/1.0" action="this.show()" class="javax.swing.JFrame" parameters="title">
<title>This is a JFrame</title>
<contentPane instance="PARENT.getContentPane()">
<label action="add(this)" class="javax.swing.JLabel" parameters="text">
<text>This is a JLabel</text>
<opaque type="boolean">false</opaque>
</label>
<opaque type="boolean">true</opaque>
<background type="color">200,90,90</background>
</contentPane>
<size class="java.awt.Dimension" parameters="w,h">
<w type="int">300</w>
<h type="int">300</h>
</size>
</jframe>
If all the attributes are stripped, all the Java specific details disappear, and the content is almost readable to a non-programmer.
<jframe xmlns="http://www.jicengine.org/jic/1.0">
<title>This is a JFrame</title>
<contentPane>
<label>
<text>This is a JLabel</text>
<opaque>false</opaque>
</label>
<opaque>true</opaque>
<background>200,90,90</background>
</contentPane>
<size>
<w>300</w>
<h>300</h>
</size>
</jframe>
5. Laborous to create, easy to modify
JIC Language is quite verbose, as is XML content in general.
On the other hand, the format tries to be as clear as possible. The idea is, that ones the JIC file has been written, the values of individual properties should be easy to change. All the objects or values can be given a name, so it should be easy to locate the correct spot.
6. Disadvantages
6. 1. A new XML format needs to be learned
XML data is typically is very verbose and data in JIC Language format is relatively self-describing, so a person should be able to do minor changes into a JIC file that already exists. Anyone wanting to create a new configuration with JICE must however learn JIC Language.
6. 2. JIC Language is for Java programmers
JIC Language code is too close to Java programming that a non-programmer won't probably understand a thing. If an XML configuration format suitable for non-programmers is needed, JICE is not the solution. (unless XML data in a non-programmer friendly format is transformed in to JIC Language code with e.g. XSLT.)
6. 3. No security or information hiding
There is no way to guarantee that a JIC Language code doesn't contain malicuous instructions. JIC Language code close to Java code. Don't accept if you can't trust the author.
JIC Language code doesn't hide the internals of the Java application that is being configured. If you want to hide something, you have to hide the JIC files also.
6. 4. Performance overhead
Of course, the information expressed in XML must first be parsed. The Java instructions in a JIC file are executed through the reflection API, which is not as fast as plain Java code.