To run or debug an SCA Java project on your own Java runtime, you must:
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$
}
}
}
To create a master launch configuration for your runtime platform, follow the following steps:
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.