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.
SCA/SCA Component/SCA Java Run and Debug FraSCAti
Contents
Introduction
This tutorial explains how you can run an SCA Java project created with SCA Tools on OW2 FraSCAti.
There are three simple steps to perform:
- Create a master launch configuration for OW2 FraSCAti.
- Instantiate this configuration for the composite to deploy.
- Optionaly, modify the generated configuration (for advanced use).
For this tutorial, we will use the "Simple Weather Sample" provided by SCA Tools.
It is an SCA project that you can create by selecting File > New > Examples > SCA > SCA Examples and then by choosing the Weather - Simple weather sample.
Three simple steps
Create a master launch configuration
The first thing to do is to create a master launch configuration.
For this example, we use OW2 FraSCAti 0.5.
Go into Window > Preferences > SCA Tools > Run / Debug.
Click Add.... In the dialog that shows up, type in "FraSCAti 0.5".
That will be the name of our master launch configuration.
Click OK.
You should see the argument line is filled with ${composite_name}.
When this master launch configuration is instantiated (applied) for a composite, this variable will be replaced by the composite file name.
And you should see the classpath contains a reference to the org.eclipse.stp.sca.deployment
plug-in.
In the Classpath tab, click Add library..., select all the librairies of OW2 FraSCAti 0.5 and click Open.
In the Launch tab, copy org.eclipse.stp.sca.deployment.mains.FrascatiMain05
in the Main class field.
This class is provided by the org.eclipse.stp.sca.deployment
plug-in and just deploys the composite.
Click OK to save this configuration.
Run the composite with this configuration
In the package explorer, find the simpleWeather.composite
file.
Make a right-click on it and select Run as... > SCA application. If you have created only one master configuration, it should automatically be launched.
Otherwise, in the dialog that shows up, select the "FraSCAti 0.5" configuration.
You should get the following console display.
You made it run without modifying the project classpath.
Type in 'q' to stop the main application.
Modify the launch configuration
Let's suppose you want to add special arguments to the configuration, or try on another JRE.
Go into Run > Run configurations... and select your configuration in the SCA category. Its name looks like < compositeName > - < masterLaunchConfigurationName >
You can now edit its properties, save it and run it again.
Links to visit
Appendix: the main method for FraSCAti
public static void main( String[] args ) throws Exception { if( args.length != 1 ) throw new IllegalArgumentException( "<Usage>\n\tFrascatiMain05.main( new String[] { <compositeFilePath> });" ); //$NON-NLS-1$ Object factory = null; try { System.out.println( "Deploying " + args[ 0 ] + "..." ); //$NON-NLS-1$ //$NON-NLS-2$ factory = Class.forName( "org.ow2.frascati.factory.Factory" ).newInstance(); //$NON-NLS-1$ Method newInstanceMethod = factory.getClass().getMethod( "getComposite", new Class[] { String.class }); //$NON-NLS-1$ newInstanceMethod.invoke( factory, 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 { System.out.println( "Undeploying " + args[ 0 ] + "..." ); //$NON-NLS-1$ //$NON-NLS-2$ System.out.println( "Done." ); //$NON-NLS-1$ } }