Running and debugging SCA applications on your own Java runtime

To run or debug an SCA Java project on your own Java runtime, you must:

Writing a launcher class for an SCA composite

Simply write a Java program and package it into a jar file.
This program will be in charge of deploying (or performing an action) on a composite file. It will be called by Eclipse when a user selects the "Run as..." action on a composite with your runtime.

As an example, the org.eclipse.stp.sca.deployment plug-in provides two classes with a main method to deploy a composite on Apache Tuscany and OW2 FraSCAti. These main methods only expect the composite file name as an argument.

Here is the main method for the Apache Tuscany launcher.

public static void main( String[] args ) throws Exception {
 
	if( args.length != 1 )
		throw new IllegalArgumentException( 
			"<Usage>\n\tTuscanyMain1x.main( new String[] { <compositeFileName> });" ); //$NON-NLS-1$
 
	Object scaDomain = null;
	Class<?> scaDomainClass = null;
	try {
		System.out.println( "Deploying " + args[ 0 ] + "..." ); //$NON-NLS-1$ //$NON-NLS-2$
		scaDomainClass = Class.forName( "org.apache.tuscany.sca.host.embedded.SCADomain" ); //$NON-NLS-1$
		Method newInstanceMethod = scaDomainClass.getMethod( "newInstance", new Class[] { String.class }); //$NON-NLS-1$
		scaDomain = newInstanceMethod.invoke( scaDomainClass, new Object[] { args[ 0 ]});
 
		// Wait...
		System.out.println( "\nType in 'q' followed by 'enter' to end this application." ); //$NON-NLS-1$
		char c;
		while(( c = (char) System.in.read()) != 'q' ) {
			System.out.println( c );
		}
 
	} catch( Exception e ) {
		e.printStackTrace();
 
	} finally {
		if( scaDomain != null ) {
			System.out.println( "Undeploying " + args[ 0 ] + "..." ); //$NON-NLS-1$ //$NON-NLS-2$
			Method closeMethod = scaDomainClass.getMethod( "close", new Class[ 0 ]); //$NON-NLS-1$
			closeMethod.invoke( scaDomain, new Object[ 0 ]);
			scaDomain = null;
			System.out.println( "Done." ); //$NON-NLS-1$
		}
	}
}

Creating a master launch configuration for your runtime platform

To create a master launch configuration for your runtime platform, follow the following steps:

  1. Go into Window > Preferences > SCA Tools > Run / Debug.
  2. Click Add....
    In the dialog that shows up, type in a name for your master launch configuration, e.g. "myConfiguration".

    Create an SCA master launch configuration for your platform

    Click OK.
  3. In the Classpath tab, add the libraries of your runtime and add the library for your launcher.
  4. In the Launch tab, specify the name of the launcher class.
  5. Make sure the arguments are valid according to what the main class expects.
    You can use two pre-defined variables:

Click OK to save the preferences.
You have created a master launch configuration for your runtime. You can instantiate it by right-clicking an SCA composite and selecting Run as > SCA Application.