Generating Java code from an assembly file

With SCA, one can easily make errors by mispelling an element name (e.g. a service name) or by making incompatible interfaces (e.g. in a wire).
A convenient solution to avoid these errors when starting from zero, is to create a complete composite and then to generate the Java code skeleton of your SCA application. SCA Tools now provides such a feature.

To generate Java code from an assembly file:

  1. Start by creating a composite using the composite editors (most likely the SCA Designer).
  2. Fill in all the element properties (interface class names, etc...).
    You should get warnings indicating that these classes were not found in the class path.

    A complete composite file

  3. Then, right-click on your composite and select SCA > Generate Java Skeleton.

    Generate the code

  4. In the dialog which appears, select the output source folder and the Java files to generate.

    Select the output folder

  5. The Java code skeleton is then generated. It declares the types with the right class hierarchy, the SCA annotations, the references and the properties.

    The code after generation

  6. Complete the Java artifacts by adding the service operations in the interfaces and by implementing them in the implementations.

Sample generated code

Here is a sample file, generated with this method.

/*
 * Generated from WeatherApplication.composite on 05/26/09 at 16:28:12.
 */
 
package weather.impl;
 
import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
import org.toto2.Toto2;
import simpleweather.interfaces.SimpleWeatherService_PortType;
import weather.interfaces.GlobalWeatherService;
 
@Service( interfaces={Toto2.class, GlobalWeatherService.class})
public class GlobalWeatherImpl implements Toto2, GlobalWeatherService {
 
	//
	// Properties
	@Property
	public Object pouf24;	// TODO: replace "Object" by the right type.
 
	@Property
	public Object pouf23;	// TODO: replace "Object" by the right type.
 
 
	//
	// References
	private SimpleWeatherService_PortType simpleWeatherReference;
 
	@Reference
	public void setSimpleWeatherReference( SimpleWeatherService_PortType simpleWeatherReference ) {
		this.simpleWeatherReference = simpleWeatherReference;
	}
 
	// TODO: define the service implementation.
}

Known limitations