Skip to content
November 26, 2010 / jkeznikl

SOFA-J HOWTO: Good practices

1. What is a code bundle and how do I use it?

Code bundle in SOFA 2 is a package containing source code. Every SOFA 2 element (interface type, architecture etc.) has its own implicit code bundle in which the associated code (Java interface, Java class implementing the component architecture etc.) is stored. A developer can also define his own code bundles which would contain additional source code.

Every code bundle (including the implicit ones of the interface types and architectures) can define its dependencies on other bundles (like in OSGi). Upon compilation and instantiation of the particular code bundle, the dependent bundles will be automatically added to the classpath.

2. How to share code between components?

A component implementation is part of the component architecture definition and is stored in the associated code bundle. To share code between several components (i.e. architectures, i.e. code bundles) the shared code has to be put in a standalone (user-defined) code bundle and all the component architectures should define dependency on this shared bundle.

3. Inheritance of component architectures

Inheritance of the component architectures as component model elements is not possible in SOFA 2. To allow inheritance of the component implementation, the best way is to put the common ancestor implementation in the shared standalone code bundle and define a dependency on this shared bundle in both component architectures.

It is also possible to define a dependency on the implicit code bundle of the parent component. In that case, the code bundle name would be like this: {full name of the architecture}.code.

4. Common SOFA build system issues

The SOFA 2 project uses the Apache Ivy dependency resolver. It uses a local cashe for all resolved and downloaded packages. It is possible that the Ivy cache becomes inconsistent, in which case it can lead to weird compilation and runtime errors. A simple solution is to clear the Ivy cache (by deleting the .ivy2 directory in the user’s home directory) and let Ivy download all required packages again and build the cache from scratch.

5. Connector generator issues during deployment

The SOFA connector generator (congen), which is used to automatically generate code for connection of the individual components, uses the connector cache to store the generated connectors. The cashe is stored in the temp directory. In Windows it is usualy in the Documents and Settings{username}Local SettingsTempsofa2-conrep-{username} directory. If you are experiencing some errors during connector instantiation, It could help to delete this connector cache.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: