Jump to: navigation, search

Difference between revisions of "SCA/SCA Component/SCA Java Run and Debug FraSCAti"

< SCA
 
(3 intermediate revisions by one other user not shown)
Line 5: Line 5:
 
* Create a master launch configuration for OW2 FraSCAti.
 
* Create a master launch configuration for OW2 FraSCAti.
 
* Instantiate this configuration for the composite to deploy.
 
* Instantiate this configuration for the composite to deploy.
* Optionnaly, modify the generated configuration (for advanced use).
+
* Optionaly, modify the generated configuration (for advanced use).
  
  
Line 38: Line 38:
  
  
In the classpath tab, click '''Add library...''', select all the librairies of OW2 FraSCAti 0.5 and click '''Open'''.
+
In the '''Classpath''' tab, click '''Add library...''', select all the librairies of OW2 FraSCAti 0.5 and click '''Open'''.
  
 
[[Image:SCA Java Run and Debug Frascati4.gif]]
 
[[Image:SCA Java Run and Debug Frascati4.gif]]
  
  
In the main tab, copy <code>org.eclipse.stp.sca.deployment.mains.FrascatiMain05</code> in the '''Main class''' field.<br />
+
In the '''Launch''' tab, copy <code>org.eclipse.stp.sca.deployment.mains.FrascatiMain05</code> in the '''Main class''' field.<br />
 
This class is provided by the <code>org.eclipse.stp.sca.deployment</code> plug-in and just deploys the composite.  
 
This class is provided by the <code>org.eclipse.stp.sca.deployment</code> plug-in and just deploys the composite.  
  
Line 71: Line 71:
  
  
=== Modifying the launch configuration ===
+
=== Modify the launch configuration ===
  
 
Let's suppose you want to add special arguments to the configuration, or try on another JRE.<br />
 
Let's suppose you want to add special arguments to the configuration, or try on another JRE.<br />

Latest revision as of 03:35, 9 November 2010

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.

SCA Java Run and Debug Frascati1.gif


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.

SCA Java Run and Debug Frascati2.gif


And you should see the classpath contains a reference to the org.eclipse.stp.sca.deployment plug-in.

SCA Java Run and Debug Frascati3.gif


In the Classpath tab, click Add library..., select all the librairies of OW2 FraSCAti 0.5 and click Open.

SCA Java Run and Debug Frascati4.gif


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.

SCA Java Run and Debug Frascati5.gif


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.


SCA Java Run and Debug runAs.gif


Otherwise, in the dialog that shows up, select the "FraSCAti 0.5" configuration.
You should get the following console display.

SCA Java Run and Debug Frascati6.gif


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.

SCA Java Run and Debug Frascati7.gif


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$
	}
}