SCA/Components/SCA Java Run and Debug

From Eclipsepedia

Revision as of 05:39, 17 April 2009 by (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Generally, when you want to deploy an SCA Java project on a platform (e.g. Apache Tuscany), you have to add the libraries of this platform to the classpath of the project, and then write a main application to deploy your composite on this runtime. The disadvantages of this method is that your project is coupled to a precise runtime through these dependencies. If you want to test the deployment on another version of this runtime, or another runtime, you have to modify the project classpath every time.

Given that SCA Tools now provide the SCA Java annotations, the runtime libraries are only useful for deployment.
To avoid all of this, SCA Tools introduce run and debug configurations.
Meaning that the project is on one side, the runtime on another, and both are bound inside a configuration. This configuration can be launched either in run mode, or in debug mode. The debug mode can be used to debug the SCA project (the Java code) or the SCA platform.

Master and concrete launch configurations

An SCA launch configuration looks like a Java launch configuration.
It has a main tab, an argument tab and so on.

Such a configuration has some particular elements.
The classpath mandatory includes the runtime libraries and the SCA project classpath.

It also define a main class to call. This main class will be delegated the task to perform (e.g. deploy the composite on the runtime). This main class can be either defined in a library contributed by the user, or be one of the main classes provided by SCA Tools. Currently, there is one main class to deploy on Apache Tuscany 1.x and one for OW2 FraSCAti. We expect some others to be added later on.

Eventually, the configuration needs arguments. Usually, it is the composite file name. It could be the composite file path. And there could be other arguments as well.

SCA run configurations are listed in the SCA category in the Run > Run configurations... menu. SCA debug configurations are listed in the SCA category in the Run > Debug configurations... menu.

These configurations are "concrete" configurations. That is to say they are already executable. A simple way to create one is to right click on the SCA category, select New and configure this new launch configuration. Set the classpath, the arguments, the main class... To ease the creation of such configurations, and avoid to set specify everytime which runtime to use, SCA tools introduce the concept of master launch configurations. Master launch configurations are "abstract" launch configurations. They are not directly executable, but concrete ones can be created from them when a composite file is specified.

Master launch configurations are defined by the user in the SCA preference pages.
To create one, go into Window > Preferences > SCA Tools > Run / Debug.
The master launch configurations are listed in the top table. The bottom tabs are used to specify the properties of a master launch configuration (main class, classpath, arguments). Some other tabs may be added later, depending on the needs (e.g. which JRE to use).

When you create a new master launch configuration, you simply give it a name.
Once created, some properties have been initialized automatically. The classpath contains one entry to the plug-in, which contains main classes to run SCA applications on Apache Tuscany and OW2 FraSCAti. It's up to the user then, to add the libraries for the runtime he wants. The arguments line is also pre-filled with ${composite_name}. When you instantiate a master launch configuration (to create a concrete one), this variable will be replaced by the name of the composite to deploy.

There are two pre-defined SCA variables:

  • ${composite_name} will be replaced by the composite file name.
  • ${composite_path} will be replaced by the composite file path.

They may be completed later with new ones or/and the usual Java ones. As usual with Eclipse preferences, you have to click OK or Apply to save your modifications in the page, or Cancel to cancel them.

Run / Debug your SCA application

Once you have at least one master launch configuration, and that you have an SCA Java project to run, you can simply launch it by right-clicking on the composite to deploy and selecting Run as > SCA application.
If you only defined one master launch configuration, this one will be automatically instantiated for this composite and saved. If you have several ones, a selection dialog shows up and expect you to select the one to instantiate.

What happens after the Run as depends on the main class that was chosen.
If a user uses the main classes provided by SCA Tools, it simply deploys the composite. It's up to the user to write the client to call its application. Or he has to write its own main to deploy the application and then call the services.

What it means also, is that the called main method may not be related to a runtime. It could be to perform another action on the composite (e.g. parsing or transformation). Even if obviously, this is not what we recommend regarding the use of this feature (SCA Tools already support parsing and transformation of composites). But it illustrates the flexibility of this mechanism. Thus, you could easily imagine run scripts or automate tests through this Run as action.