Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

SCA/Components/SCA Java Run and Debug

Run and Debug SCA Java projects


Goals

Generally, to deploy an SCA Java project on a platform (e.g. Apache Tuscany), the libraries of this platform must be added to the classpath of the project, and then a main application must be written to deploy a composite on this runtime. The disadvantages of this method is the SCA project is coupled to a precise runtime through these dependencies. Therefore, the project classpath must be modified to test the deployment on another version of this runtime, or another runtime.


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 introduced 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.

SCA Java Run and Debug scaLaunchConfigurations.gif


Such a configuration has some particular elements.
It defines 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.


The classpath mandatory includes the runtime libraries and the SCA project classpath.

SCA Java Run and Debug scaLaunchClasspath.gif


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 Java Run and Debug scaLaunchArguments.gif


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.


SCA Java Run and Debug masterLaunchConfigurationPrefs.gif


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).


Creating a new master launch configuration simply consists in giving it a name.

SCA Java Run and Debug newMasterLaunch.gif


Once created, some properties have been initialized automatically. The classpath contains one entry to the org.eclipse.stp.sca.deployment 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.

SCA Java Run and Debug masterLaunchClasspathPrefs.gif


The arguments line is also pre-filled with ${composite_name}. When a concrete configuration is created from the master launch configuration, this variable is replaced by the name of the composite to deploy.

SCA Java Run and Debug masterLaunchMainPrefs.gif


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, saving modifications is done by clicking OK or Apply, and Cancel is used to to cancel them.


Run / Debug an SCA application

Run / Debug here means launch a configuration (in run or debug mode). An SCA Java project can be launched by right-clicking on the composite to deploy and selecting Run as > SCA application.

SCA Java Run and Debug runAs.gif


If there is only one master launch configuration, this one will be automatically instantiated for this composite and saved. If there are several ones, a selection dialog shows up with a list of configurations.

SCA Java Run and Debug runAsOnThisPlatform.gif


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.


SCA Java Run and Debug runAsOnThisPlatformConsole.gif


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, one could easily imagine run scripts or automate tests through this Run as action.

Back to the top