summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/sca-java-2x-development-guide.html
diff options
context:
space:
mode:
authorcoreyg <coreyg@13f79535-47bb-0310-9956-ffa450edef68>2014-11-21 09:30:19 +0000
committercoreyg <coreyg@13f79535-47bb-0310-9956-ffa450edef68>2014-11-21 09:30:19 +0000
commit200a40b332420f94992eb39a6d0ea1cf1490ffc4 (patch)
tree1c76ef1d254c7bfc91128a313d319bd60da9d01e /site/trunk/site-publish/sca-java-2x-development-guide.html
parent85f53ab6ab4f664d63774c94b672a875c9e52b8a (diff)
Adding tuscany's website to their svn repo for svnpubsub
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1640879 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'site/trunk/site-publish/sca-java-2x-development-guide.html')
-rw-r--r--site/trunk/site-publish/sca-java-2x-development-guide.html533
1 files changed, 533 insertions, 0 deletions
diff --git a/site/trunk/site-publish/sca-java-2x-development-guide.html b/site/trunk/site-publish/sca-java-2x-development-guide.html
new file mode 100644
index 0000000000..a206cf1268
--- /dev/null
+++ b/site/trunk/site-publish/sca-java-2x-development-guide.html
@@ -0,0 +1,533 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<HTML>
+
+ <HEAD>
+ <META name="description" content="Apache Tuscany">
+ <META name="keywords" content="apache, apache tuscany, tuscany, service, services, fabric, soa, service oriented architecture, sca, service component architecture, das, sdo, csa, ruby, opensource">
+
+
+
+ <LINK type="text/css" rel="stylesheet" href="http://tuscany.apache.org/stylesheets/default.css">
+
+ <LINK rel="SHORTCUT ICON" href="http://cwiki.apache.org/confluence/display/TUSCANY/$images/favicon.ico">
+
+ <TITLE>SCA Java 2.x Development Guide : Apache Tuscany</TITLE>
+
+ <META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD>
+
+
+
+ <BODY onload="init()">
+
+
+
+
+ <TABLE valign="top" border="0" cellspacing="0" cellpadding="0" width="100%" background="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg">
+
+ <TR>
+
+ <TD valing="top" align="left">
+
+ <A href="http://cwiki.apache.org/confluence/pages/viewpage.action?spaceKey=TUSCANY&title=$siteroot"><IMG src="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg" height="91" width="25" border="0"></A>
+
+ </TD>
+
+ <TD>
+
+ <A href="http://tuscany.apache.org/"><IMG src="http://tuscany.apache.org/images/TuscanyLogo.jpg" border="0"></A>
+
+ </TD>
+
+
+
+ <TD width="100%">
+
+ &nbsp;
+
+ </TD>
+
+ <!--td align="right">
+
+ <img src="http://incubator.apache.org/tuscany/images/apache- incubator- logo.png" border="0">
+
+ </td-->
+
+
+
+ <!-- Adds the edit page link to the top banner-->
+
+ <TD valign="bottom">
+
+ <DIV style="padding: 2px 10px; margin: 0px;">
+
+ <A href="http://cwiki.apache.org/confluence/pages/editpage.action?pageId=100579">
+
+ <IMG src="http://tuscany.apache.org/images/notep_16.gif" height="16" width="16" border="0" align="absmiddle" title="Edit Page"></A>
+
+ </DIV>
+
+ </TD>
+
+
+
+ </TR>
+
+ </TABLE>
+
+
+
+
+
+ <TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
+
+ <TR class="topBar">
+
+ <TD align="left" valign="middle" class="topBarDiv" nowrap="true" width="100%">
+
+ &nbsp;<A href="home.html" title="Apache Tuscany">Apache Tuscany</A>&nbsp;&gt;&nbsp;<A href="home.html" title="Home">Home</A>&nbsp;&gt;&nbsp;<A href="sca-overview.html" title="SCA Overview">SCA Overview</A>&nbsp;&gt;&nbsp;<A href="sca-java.html" title="SCA Java">SCA Java</A>&nbsp;&gt;&nbsp;<A href="java-sca-documentation-menu.html" title="Java SCA Documentation Menu">Java SCA Documentation Menu</A>&nbsp;&gt;&nbsp;<A href="" title="SCA Java 2.x Development Guide">SCA Java 2.x Development Guide</A>
+
+ </TD>
+
+
+
+ <TD align="right" valign="middle" class="topBarDiv" align="left" nowrap="true">
+
+ <A href="http://mail-archives.apache.org/mod_mbox/tuscany-user">User List</A> | <A href="http://mail-archives.apache.org/mod_mbox/tuscany-dev">Dev List</A> | <A href="http://issues.apache.org/jira/browse/Tuscany">Issue Tracker</A>&nbsp;&nbsp;
+
+ </TD>
+
+ </TR>
+
+ </TABLE>
+
+
+
+
+ <TABLE border="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
+
+ <TR>
+
+ <TD align="left" valign="top">
+
+
+ <DIV id="PageContent">
+
+
+
+
+ <DIV class="pagecontent">
+
+ <DIV class="wiki-content">
+
+ <TABLE class="sectionMacroWithBorder" border="0" cellpadding="5" cellspacing="0" width="100%"><TBODY><TR>
+<TD class="confluenceTd" valign="top" width="15%">
+<DIV class="panel" style="background-color: #ECF4D1;border-color: #C3CDA1;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #C3CDA1;background-color: #C3CDA1;"><B>General</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
+<P><A href="home.html" title="Home">Home</A><BR>
+<A href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="nofollow">License </A><BR>
+<A href="sca-java-get-involved.html" title="SCA Java Get Involved">Get Involved</A><BR>
+<A href="sca-java-found-a-bug.html" title="SCA Java Found A Bug">Found a Bug?</A></P>
+</DIV></DIV>
+
+<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>SCA Java</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
+<P><A href="sca-java.html" title="SCA Java">SCA Java Home</A><BR>
+<A href="tuscany-dashboard.html" title="Tuscany Dashboard">SCA Dashboard</A><BR>
+<A href="java-sca-tools.html" title="Java SCA Tools">Tools </A><BR>
+<A href="tuscany-sca-java-faq.html" title="Tuscany SCA Java - FAQ">FAQ</A></P>
+</DIV></DIV>
+
+<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>SCA Java 1.x</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
+<P><A href="sca-java-releases.html" title="SCA Java Releases">Downloads</A><BR>
+<A href="java-sca-documentation-menu.html" title="Java SCA Documentation Menu">Documentation</A><BR>
+<A href="https://svn.apache.org/repos/asf/tuscany/sca-java-1.x/trunk/" rel="nofollow">1.x Source Code</A><BR>
+<A href="http://tinyurl.com/8rlxd3" rel="nofollow">Roadmap</A></P>
+</DIV></DIV>
+
+<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>SCA Java 2.x</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
+<P><A href="sca-java-2x-releases.html" title="SCA Java 2.x Releases">Downloads</A><BR>
+<A href="http://tuscany.apache.org/documentation-2x/" rel="nofollow">Documentation</A><BR>
+<A href="https://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/" rel="nofollow">2.x Source Code</A><BR>
+<A href="http://tinyurl.com/8rlxd3" rel="nofollow">Roadmap</A></P>
+</DIV></DIV>
+
+
+<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>Documentation</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
+<P><A href="sca-java-user-guide.html" title="SCA Java User Guide">User Guide</A><BR>
+<A href="sca-java-architecture-guide.html" title="SCA Java Architecture Guide">Architecture Guide</A><BR>
+<A href="sca-java-development-guide.html" title="SCA Java Development Guide">Developer Guide</A><BR>
+<A href="sca-java-extension-development-guide.html" title="SCA Java Extension Development Guide">Extension Developer Guide</A></P>
+</DIV></DIV>
+
+<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>Resources</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
+<P><A href="tuscany-sca-java-faq.html" title="Tuscany SCA Java - FAQ">FAQ</A><BR>
+<A href="https://svn.apache.org/repos/asf/incubator/tuscany/java/sca" rel="nofollow">Source Code</A></P>
+</DIV></DIV>
+</TD>
+<TD class="confluenceTd" valign="top" width="85%">
+<DIV class="panel" style="background-color: #ECF4D1;border-color: #C3CDA1;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #C3CDA1;background-color: #C3CDA1;"><B>How to get involved in development of Java SCA?</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
+<P>This document is the development guideline for SCA Java project.</P>
+<UL>
+ <LI><A href="#SCAJava2.xDevelopmentGuide-GeneralGuide" title="#General Guide">General Guide\</A></LI>
+ <LI><A href="#SCAJava2.xDevelopmentGuide-GettingSource" title="#Getting Source">Getting Source code\</A></LI>
+ <LI><A href="#SCAJava2.xDevelopmentGuide-Setup" title="#Setup">Setting up your development environment\</A></LI>
+ <LI><A href="#SCAJava2.xDevelopmentGuide-IDE" title="#IDE">Importing SCA modules into your Development IDE\</A></LI>
+ <LI><A href="#SCAJava2.xDevelopmentGuide-CodingGuidelines" title="#Coding Guidelines">Coding Guidelines\</A></LI>
+ <LI><A href="#SCAJava2.xDevelopmentGuide-Testing" title="#Testing">Testing\</A></LI>
+ <LI><A href="#SCAJava2.xDevelopmentGuide-ClientApplications">Client Applications</A></LI>
+ <LI><A href="#SCAJava2.xDevelopmentGuide-MavenBuildStructure" title="#Maven Build Structure">Maven Build Structure\</A></LI>
+ <LI><B>Development Hints</B>
+ <UL>
+ <LI><A href="#SCAJava2.xDevelopmentGuide-WebappinEclipse" title="#Webapp in Eclipse">Generating Eclipse WTP Web Projects for Webapp samples\</A></LI>
+ <LI><A href="#SCAJava2.xDevelopmentGuide-Ant" title="#Ant">Generating Dependencies for Ant in Samples\</A></LI>
+ </UL>
+ </LI>
+</UL>
+
+
+<P><BR clear="all">
+&nbsp;</P>
+</DIV></DIV>
+
+<H3><A name="SCAJava2.xDevelopmentGuide-OSGiOverviewandApproach"></A>OSGi Overview and Approach</H3>
+
+<P><A href="http://people.apache.org/~lresende/presentations/felix%20goes%20to%20tuscany.pdf" rel="nofollow">OSGI &amp; Tuscany</A></P>
+
+<H3><A name="SCAJava2.xDevelopmentGuide-GeneralGuide"></A><A name="SCAJava2.xDevelopmentGuide-GeneralGuide"></A> General Guide</H3>
+
+<P>Welcome to the Tuscany SCA Java subproject project. We look forward to your participation and try to help you get on board. Feel free to ask your questions on the mailing list.</P>
+
+<P>Here are some general guidelines we use in this project.</P>
+<UL>
+ <LI>Java SCA sub-project aims to provide enterprise-grade service infrastructure based on SCA.</LI>
+ <LI>Tuscany SCA is not just a reference implementation. We encourage innovation based on the tenets of SCA. A lot of work we do provides feedback to the specifications.</LI>
+ <LI>The Java SCA infrastructure should provide flexibility and choice. It should not dictate programming models but support many.</LI>
+ <LI>The Java SCA infrastructure is very modularized and is designed to be highly extensible so users can customize it to fit their needs.</LI>
+</UL>
+
+
+<H3><A name="SCAJava2.xDevelopmentGuide-Prerequisites"></A><A name="SCAJava2.xDevelopmentGuide-Prerequisites"></A> Prerequisites</H3>
+
+<P>Java SCA requires the following:</P>
+<UL>
+ <LI><A href="http://java.sun.com/j2se/1.5.0" rel="nofollow">JDK 5.0&#43; (J2SE 1.5.0+)</A></LI>
+ <LI><A href="http://maven.apache.org/" rel="nofollow">Apache Maven (2.0.9+)</A></LI>
+ <LI><A href="http://subversion.tigris.org/" rel="nofollow">Subversion (1.5+)</A> or <A href="http://tortoisesvn.tigris.org/" rel="nofollow">TortoiseSVN (1.5.x+)</A></LI>
+ <LI><A href="http://www.eclipse.org/downloads" rel="nofollow">Eclipse PDE (Ganymede ) </A></LI>
+</UL>
+
+
+<H4><A name="SCAJava2.xDevelopmentGuide-CheckingoutcodefromSubversion"></A>Checking out code from Subversion</H4>
+
+<P>Use the command as follows:</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+svn checkout https:<SPAN class="code-comment">//svn.apache.org/repos/asf/tuscany/java/sca</SPAN>
+</PRE>
+</DIV></DIV>
+
+<H3><A name="SCAJava2.xDevelopmentGuide-SettingupyourDevelopmentEnvironment"></A><A name="SCAJava2.xDevelopmentGuide-Setup"></A> Setting up your Development Environment</H3>
+
+<H4><A name="SCAJava2.xDevelopmentGuide-topdownbuild%28recommendedapproach%29"></A>top-down build (recommended approach)</H4>
+
+<P>Check out all of the java source code.</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+svn checkout https:<SPAN class="code-comment">//svn.apache.org/repos/asf/tuscany/java/sca</SPAN>
+</PRE>
+</DIV></DIV>
+<P>Building the SCA source code :</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+mvn -Psetup clean install
+mvn -fae clean install
+cd distribution
+mvn -fae clean install
+</PRE>
+</DIV></DIV>
+<P>It should work even if you start with an empty Maven local repository, and it should always work, however when you are building for Tuscany for the first time there are a lot of dependencies which must be downloaded so the first build can take a long time and it may fail with problems retrieving the dependencies.</P>
+
+<P><IMG class="emoticon" src="http://cwiki.apache.org/confluence/images/icons/emoticons/lightbulb_on.gif" height="16" width="16" align="absmiddle" alt="" border="0"> There can be occasional problems downloading artifacts from remote Maven repositories so if mvn fails with network related sounding messages sometimes just trying again can fix the problem.</P>
+
+<P><IMG class="emoticon" src="http://cwiki.apache.org/confluence/images/icons/emoticons/lightbulb_on.gif" height="16" width="16" align="absmiddle" alt="" border="0"> The trunk code sometimes has SNAPSHOT dependencies which can get out of date in your local repository so if you see odd build failures try updating the SNAPSHOT jars by using the &quot;-U&quot; parameter in the mvn command.</P>
+
+<P><IMG class="emoticon" src="http://cwiki.apache.org/confluence/images/icons/emoticons/lightbulb_on.gif" height="16" width="16" align="absmiddle" alt="" border="0"> Once you have done a top-down build, and your local maven repository is populated, you can start using the maven off line option to speed up the build process by using the &quot;-o&quot; parameter in the mvn command.</P>
+
+<DIV class="panelMacro"><TABLE class="infoMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="http://cwiki.apache.org/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD><P> The SCA build consumes a good amount of memory, in case you are seeing issues during the build, set a MAVEN_OPTS environment variable to allocate more memory for the build process.</P>
+
+<P> Windows : SET MAVEN_OPTS=-Xmx512m<BR>
+ Unix : export MAVEN_OPTS=-Xmx512m</P></TD></TR></TABLE></DIV>
+
+<H3><A name="SCAJava2.xDevelopmentGuide-ImportingSCAmodulesintoyourDevelopmentIDE"></A><A name="SCAJava2.xDevelopmentGuide-IDE"></A>Importing SCA modules into your Development IDE</H3>
+
+
+<H4><A name="SCAJava2.xDevelopmentGuide-UsingEclipse"></A>Using Eclipse</H4>
+
+
+<P>If this is the first time you are using your workspace with maven m2 local repository, you will need to tell your Eclipse workspace the location of the directory, and you can do this with the following command :</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+mvn -Declipse.workspace=[path-to-eclipse-workspace] eclipse:add-maven-repo
+</PRE>
+</DIV></DIV>
+<P>In order to generate the necessary project files to import the SCA modules to Eclipse, you can use the maven eclipse plugin</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+mvn -fae -Peclipse eclipse:eclipse
+</PRE>
+</DIV></DIV>
+
+
+<P>Now, launch your Eclipse IDE, select File-&gt;Import-&gt;Existing projects into Workplace, and then import the project from SCA Modules into your Eclipse Workspace.</P>
+
+<P>Now, launch your Eclipse IDE, select File-&gt;Import-&gt;Existing projects into Workplace, and then import the &quot;PDE Target&quot; project (from distribution/pdetarget) into your Eclipse Workspace.</P>
+
+<UL>
+ <LI>Import distribution/pdetarget</LI>
+ <LI>Inside eclipse, open tuscany-distribution-pdetarget project
+ <UL>
+ <LI>open target/tuscany-distribution-pdetarget.target</LI>
+ <LI>click &quot;Set as target platform&quot; on the upper-right side of the overview window that opened</LI>
+ </UL>
+ </LI>
+</UL>
+
+
+<P>There are some Tuscany Eclipse code templates available:<BR>
+<A href="https://svn.apache.org/repos/asf/tuscany/java/etc/tuscany-eclipse-codestyle.xml" rel="nofollow">Eclipse Style Formatter </A><BR>
+<A href="https://svn.apache.org/repos/asf/tuscany/java/etc/tuscany-eclipse-codetemplates.xml" rel="nofollow">Eclipse Templates </A></P>
+
+<H3><A name="SCAJava2.xDevelopmentGuide-CodingGuidelines"></A><A name="SCAJava2.xDevelopmentGuide-CodingGuidelines"></A> Coding Guidelines</H3>
+
+<P>There are a few simple guidelines when developing for JAVA SCA:</P>
+<UL>
+ <LI>The basic coding style used is the described at <A href="http://java.sun.com/docs/codeconv/" rel="nofollow">Sun Java coding standards</A> but the main thing is to be consistent with the existing code you're updating, so for example, if you're updating a method that uses the braces on the same line style don't add code with the hanging braces style.</LI>
+</UL>
+
+
+<UL>
+ <LI>Always include the Apache License Headers on all files (both source code files and resource files such as xml documents)</LI>
+</UL>
+
+
+<UL>
+ <LI>Include a descriptive log message for checkins, for example &quot;fixed such and such problem&quot;.</LI>
+</UL>
+
+
+<P>While Tuscany does not yet have an official style or template, here are some templates that folks have been using and have been checked into the build which are stored at <A href="https://svn.apache.org/repos/asf/tuscany/java/etc/" rel="nofollow">https://svn.apache.org/repos/asf/tuscany/java/etc/</A></P>
+
+<H4><A name="SCAJava2.xDevelopmentGuide-Namingconventionstoincreaseconsistency"></A>Naming conventions to increase consistency</H4>
+
+<P><B>Folder Names:</B> Please use all lowercases and dashes in folder names (like in the jar names)</P>
+<UL class="alternate" type="square">
+ <LI>Maven artifact id = tuscany-&lt;folder name&gt;</LI>
+</UL>
+
+
+<P><B>Package names:</B> Package names within modules should include the module name so that source code can be located in the source tree easily. So, for example, java/sca/module/implementation-java would be in package structure org.apache.tuscany.implementation.java.&#42;</P>
+
+<H3><A name="SCAJava2.xDevelopmentGuide-Testing"></A><A name="SCAJava2.xDevelopmentGuide-Testing"></A> Testing</H3>
+
+<P>Tuscany uses plain junit test cases to perform unit and integration testing, below is an example that can also be used as a template for writing new test cases; it demonstrates how to bootstrap the Tuscany SCA runtime in your test case, and because they are based on junit, you can run it from your IDE of choice or from Maven.</P>
+
+<DIV class="panelMacro"><TABLE class="infoMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="http://cwiki.apache.org/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD><P>Note that we are using JUnit 4.2 code style in OSGI development stream</P></TD></TR></TABLE></DIV>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+/**
+ * Description of your test <SPAN class="code-keyword">case</SPAN> and necessary details you find necessary
+ */
+@Scope(<SPAN class="code-quote">&quot;COMPOSITE&quot;</SPAN>) @EagerInit
+<SPAN class="code-keyword">public</SPAN> class CalculatorTestCase {
+
+ <SPAN class="code-keyword">private</SPAN> <SPAN class="code-keyword">static</SPAN> CalculatorService calculatorService;
+ <SPAN class="code-keyword">private</SPAN> <SPAN class="code-keyword">static</SPAN> NodeLauncher launcher;
+ <SPAN class="code-keyword">private</SPAN> <SPAN class="code-keyword">static</SPAN> Node node;
+
+ @Reference
+ <SPAN class="code-keyword">public</SPAN> void setCalculatorService(CalculatorService calculatorService) {
+ CalculatorTestCase.calculatorService = calculatorService;
+ }
+
+
+ @BeforeClass
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">static</SPAN> void setUpBeforeClass() <SPAN class="code-keyword">throws</SPAN> Exception {
+ launcher = NodeLauncher.newInstance();
+ <SPAN class="code-object">String</SPAN> location = ContributionLocationHelper.getContributionLocation(CalculatorClient.class);
+ node = launcher.createNode(<SPAN class="code-quote">&quot;Calculator.composite&quot;</SPAN>, <SPAN class="code-keyword">new</SPAN> Contribution(<SPAN class="code-quote">&quot;test&quot;</SPAN>, location));
+ <SPAN class="code-object">System</SPAN>.out.println(<SPAN class="code-quote">&quot;SCA Node API <SPAN class="code-object">ClassLoader</SPAN>: &quot;</SPAN> + node.getClass().getClassLoader());
+ node.start();
+ }
+
+ @AfterClass
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">static</SPAN> void tearDownAfterClass() <SPAN class="code-keyword">throws</SPAN> Exception {
+ <SPAN class="code-keyword">if</SPAN> (node != <SPAN class="code-keyword">null</SPAN>) {
+ node.stop();
+ node.destroy();
+ }
+ <SPAN class="code-keyword">if</SPAN> (launcher != <SPAN class="code-keyword">null</SPAN>) {
+ launcher.destroy();
+ }
+ }
+
+ @Test
+ <SPAN class="code-keyword">public</SPAN> void testCalculator() <SPAN class="code-keyword">throws</SPAN> Exception {
+ <SPAN class="code-comment">// Calculate
+</SPAN> assertEquals(calculatorService.add(3, 2), 5.0);
+ assertEquals(calculatorService.subtract(3, 2), 1.0);
+ assertEquals(calculatorService.multiply(3, 2), 6.0);
+ assertEquals(calculatorService.divide(3, 2), 1.5);
+ }
+}
+</PRE>
+</DIV></DIV>
+<P><IMG class="emoticon" src="http://cwiki.apache.org/confluence/images/icons/emoticons/lightbulb_on.gif" height="16" width="16" align="absmiddle" alt="" border="0"> Note that we use surefire maven plugin to run the unit and integration tests, and in most cases, they are configured to match a &#42;*/*TestCase.java file name pattern. Because of this, if your test case has a different file name pattern, you might execute it from your IDE of choice, but the maven build won't execute the test.</P>
+
+<H3><A name="SCAJava2.xDevelopmentGuide-ClientApplicationsasSCAComponents"></A><A name="SCAJava2.xDevelopmentGuide-ClientApplications"></A> Client Applications as SCA Components</H3>
+
+<P>Below is how you can build client applications as an SCA component.</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+@Scope(<SPAN class="code-quote">&quot;COMPOSITE&quot;</SPAN>) @EagerInit
+<SPAN class="code-keyword">public</SPAN> class CalculatorClient {
+
+ <SPAN class="code-keyword">private</SPAN> CalculatorService calculatorService;
+
+ @Reference
+ <SPAN class="code-keyword">public</SPAN> void setCalculatorService(CalculatorService calculatorService) {
+ <SPAN class="code-keyword">this</SPAN>.calculatorService = calculatorService;
+ }
+
+ @Init
+ <SPAN class="code-keyword">public</SPAN> void calculate() {
+
+ <SPAN class="code-comment">// Calculate
+</SPAN> <SPAN class="code-object">System</SPAN>.out.println(<SPAN class="code-quote">&quot;SCA API <SPAN class="code-object">ClassLoader</SPAN>: &quot;</SPAN> + print(Reference.class.getClassLoader()));
+ <SPAN class="code-object">System</SPAN>.out.println(<SPAN class="code-quote">&quot;3 + 2=&quot;</SPAN> + calculatorService.add(3, 2));
+ <SPAN class="code-object">System</SPAN>.out.println(<SPAN class="code-quote">&quot;3 - 2=&quot;</SPAN> + calculatorService.subtract(3, 2));
+ <SPAN class="code-object">System</SPAN>.out.println(<SPAN class="code-quote">&quot;3 * 2=&quot;</SPAN> + calculatorService.multiply(3, 2));
+ <SPAN class="code-object">System</SPAN>.out.println(<SPAN class="code-quote">&quot;3 / 2=&quot;</SPAN> + calculatorService.divide(3, 2));
+ }
+
+ <SPAN class="code-keyword">private</SPAN> <SPAN class="code-keyword">static</SPAN> <SPAN class="code-object">String</SPAN> print(<SPAN class="code-object">ClassLoader</SPAN> cl) {
+ <SPAN class="code-object">StringBuffer</SPAN> buf = <SPAN class="code-keyword">new</SPAN> <SPAN class="code-object">StringBuffer</SPAN>();
+ <SPAN class="code-keyword">for</SPAN> (; cl != <SPAN class="code-keyword">null</SPAN>;) {
+ buf.append(cl.toString());
+ buf.append(' ');
+ cl = cl.getParent();
+ }
+ <SPAN class="code-keyword">return</SPAN> buf.toString();
+ }
+
+}
+</PRE>
+</DIV></DIV>
+
+<H3><A name="SCAJava2.xDevelopmentGuide-MavenBuildStructure"></A><A name="SCAJava2.xDevelopmentGuide-MavenBuildStructure"></A> Maven Build Structure</H3>
+
+<P><EM>We use the term Module to refer to the leaf of maven tree.</EM></P>
+<UL>
+ <LI>sca/pom.xml's parent will be pom/parent/pom.xml</LI>
+ <LI>Other poms will use the pom from the parent folder as parent pom</LI>
+ <LI>Group id: org.apache.tuscany.sca</LI>
+ <LI>Version of our modules will be specified once in java/sca/pom.xml, child poms don't need specify a version as they get it from their parent</LI>
+ <LI>pom names begin Apache Tuscany SCA</LI>
+ <LI>Eclipse projects are generated for all built modules using mvn &#45;Peclipse eclipse:eclipse</LI>
+</UL>
+
+
+<H4><A name="SCAJava2.xDevelopmentGuide-Addinganewmoduleandnotreadytointegrate%3F"></A>Adding a new module and not ready to integrate?</H4>
+
+<P>'work-in-progress' modules can be worked on in the same source tree and yet not break the top-down build. You can do this by not listing your module(s) in java/sca/modules/pom.xml.</P>
+
+<H2><A name="SCAJava2.xDevelopmentGuide-DevelopmentHints"></A>Development Hints</H2>
+
+<H3><A name="SCAJava2.xDevelopmentGuide-GeneratingEclipseWTPWebProjectsforWebappsamples"></A><A name="SCAJava2.xDevelopmentGuide-WebappinEclipse"></A> Generating Eclipse WTP Web Projects for Webapp samples</H3>
+
+<P>If you're using Eclipse WTP and want to get WTP Web Projects generated<BR>
+for our Webapp samples you can simply pass a &#45;Dwtpversion=1.5 option to<BR>
+the usual mvn eclipse:eclipse command, like this:<BR>
+mvn &#45;Dwtpversion=1.5 &#45;Peclipse eclipse:eclipse</P>
+
+<P>The magic &#45;Dwtpversion=1.5 option will add the WTP Web project nature to<BR>
+all the Eclipse projects with &lt;packaging&gt;war&lt;/packaging&gt; in their Maven<BR>
+pom.xml. You'll then be able to add these projects to a WTP Tomcat or<BR>
+Geronimo Server configuration, to publish and run them straight from<BR>
+your Eclipse workspace.</P>
+
+<P>h3:<A name="SCAJava2.xDevelopmentGuide-Ant"></A> Generating Dependencies for Ant in Samples</P>
+
+<P>Figuring out the package dependency to include in Ant build.xml can be a pain. Here is a quick<BR>
+script which works in Linux environment for war files.</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+jar tvf sample-feed-aggregator-webapp.war | grep .jar | awk '{ printf <SPAN class="code-quote">&quot;%s\n&quot;</SPAN>, $8 }' | sed -e <SPAN class="code-quote">&quot;s/WEB-INF\/lib\<SPAN class="code-comment">///&quot;</SPAN> | awk '{ printf <SPAN class="code-quote">&quot;&lt;include name=\&quot;</SPAN>%s\<SPAN class="code-quote">&quot;/&gt;\n&quot;</SPAN>, $1 }' | grep -v tuscany</SPAN>
+</PRE>
+</DIV></DIV></TD></TR></TBODY></TABLE>
+
+ </DIV>
+
+ </DIV>
+
+ </DIV>
+
+
+ </TD>
+
+ </TR>
+
+ </TABLE>
+
+
+
+
+
+ <SCRIPT src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+
+ </SCRIPT>
+
+ <SCRIPT type="text/javascript">
+
+ _uacct = "UA-1174707-5";
+
+ urchinTracker();
+
+ </SCRIPT>
+
+
+
+
+ <A href="http://www.statcounter.com/" target="_blank"><IMG src="http://c26.statcounter.com/counter.php?sc_project=2619156&java=0&security=94bd7e7d&invisible=0" alt="website stats" border="0"></A>
+
+
+
+ <DIV class="footer">
+
+ Copyright &copy; 2003-2008, The Apache Software Foundation&nbsp;&nbsp;
+
+ </DIV>
+
+
+
+
+ </BODY>
+
+</HTML>