Thanks On Thu, Feb 5, 2009 at 12:13 AM, ant elder <[email protected]> wrote: > ok done. > > ...ant > > On Thu, Feb 5, 2009 at 8:09 AM, Luciano Resende <[email protected]> > wrote: >> >> maven 2.0.7 should be ok, if you have tested with that, please move it >> back the wiki to that. >> >> On Thu, Feb 5, 2009 at 12:02 AM, ant elder <[email protected]> wrote: >> > This has changed the Tuscany prereqs to require Maven 2.0.9 was that >> > intentional? It used to say 2.0.7, I use 2.0.7 and it seems to work >> > fine. >> > Also 2.0.7 isn't that old so unless there is a good reason it would be >> > good >> > to be as accommodating as possible. >> > >> > ...ant >> > >> > On Wed, Feb 4, 2009 at 10:28 PM, <[email protected]> wrote: >> >> >> >> SCA Java Development Guide (TUSCANYxDOCx2x) edited by Luciano Resende >> >> Page: >> >> >> >> http://cwiki.apache.org/confluence/display/TUSCANYxDOCx2x/SCA+Java+Development+Guide >> >> Changes: >> >> >> >> http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=109132&originalVersion=2&revisedVersion=3 >> >> >> >> >> >> >> >> >> >> >> >> >> >> Content: >> >> --------------------------------------------------------------------- >> >> >> >> This document is the development guideline for SCA Java 2.x project. >> >> >> >> * [General Guide|#General Guide] >> >> * [Getting Source code|#Getting Source] >> >> * [Setting up your development environment|#Setup] >> >> * [Importing SCA modules into your Development IDE|#IDE] >> >> * [Coding Guidelines|#Coding Guidelines] >> >> * [Testing|#Testing] >> >> * [Client Applications|#Client Applications] >> >> * [Maven Build Structure|#Maven Build Structure] >> >> * *Development Hints* >> >> ** [Generating Eclipse WTP Web Projects for Webapp samples|#Webapp in >> >> Eclipse] >> >> ** [Generating Dependencies for Ant in Samples|#Ant] >> >> >> >> h3.OSGi Overview and Approach >> >> >> >> [OSGI & >> >> >> >> Tuscany|http://people.apache.org/~lresende/presentations/felix%20goes%20to%20tuscany.pdf] >> >> >> >> h3. {anchor:General Guide} General Guide >> >> >> >> 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. >> >> >> >> Here are some general guidelines we use in this project. >> >> * Java SCA sub-project aims to provide enterprise-grade service >> >> infrastructure based on SCA. >> >> * 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. >> >> * The Java SCA infrastructure should provide flexibility and choice. It >> >> should not dictate programming models but support many. >> >> * The Java SCA infrastructure is very modularized and is designed to be >> >> highly extensible so users can customize it to fit their needs. >> >> >> >> h3. {anchor:Prerequisites} Prerequisites >> >> >> >> Java SCA requires the following: >> >> * [JDK 5.0\+ (J2SE 1.5.0+)|http://java.sun.com/j2se/1.5.0] >> >> * [Apache Maven (2.0.9+)|http://maven.apache.org/] >> >> * [Subversion (1.5+)|http://subversion.tigris.org/] or [TortoiseSVN >> >> (1.5.x+)|http://tortoisesvn.tigris.org/] >> >> * [Eclipse PDE (Ganymede ) |http://www.eclipse.org/downloads] >> >> >> >> h4. Checking out code from Subversion >> >> >> >> Use the command as follows: >> >> {code} >> >> svn checkout https://svn.apache.org/repos/asf/tuscany/java/sca >> >> {code} >> >> >> >> h3. {anchor:Setup} Setting up your Development Environment >> >> >> >> h4. top-down build (recommended approach) >> >> >> >> Check out all of the java source code. >> >> {code} >> >> svn checkout https://svn.apache.org/repos/asf/tuscany/java/sca >> >> {code} >> >> Building the SCA source code : >> >> {code} >> >> mvn -Psetup clean install >> >> mvn -fae clean install >> >> {code} >> >> 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. >> >> >> >> (on) 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. >> >> >> >> (on) 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 "-U" parameter in the mvn >> >> command. >> >> >> >> (on) 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 "-o" parameter in the mvn command. >> >> >> >> {info} >> >> 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. >> >> >> >> Windows : SET MAVEN_OPTS=-Xmx512m >> >> Unix : export MAVEN_OPTS=-Xmx512m >> >> {info} >> >> >> >> h3. {anchor:IDE}Importing SCA modules into your Development IDE >> >> >> >> >> >> h4. Using Eclipse >> >> >> >> >> >> 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 : >> >> {code} >> >> mvn -Declipse.workspace=[path-to-eclipse-workspace] >> >> eclipse:add-maven-repo >> >> {code} >> >> In order to generate the necessary project files to import the SCA >> >> modules >> >> to Eclipse, you can use the maven eclipse plugin >> >> {code} >> >> mvn -fae -Peclipse >> >> {code} >> >> >> >> >> >> Now, launch your Eclipse IDE, select File->Import->Existing projects >> >> into >> >> Workplace, and then import the project from SCA Modules into your >> >> Eclipse >> >> Workspace. >> >> >> >> Now, let's set the "Target Platform" in your Eclipse IDE by following >> >> the >> >> steps below : >> >> >> >> * Inside eclipse, select File->Open File" and open >> >> "distribution/all/target/features/tuscany.target" >> >> ** click "Set as target platform" on the upper-right side of the >> >> overview >> >> window that opened >> >> >> >> There are also some Tuscany Eclipse code templates available: >> >> [Eclipse Style Formatter | >> >> >> >> https://svn.apache.org/repos/asf/tuscany/java/etc/tuscany-eclipse-codestyle.xml >> >> ] >> >> [Eclipse Templates | >> >> >> >> https://svn.apache.org/repos/asf/tuscany/java/etc/tuscany-eclipse-codetemplates.xml >> >> ] >> >> >> >> h3. {anchor:Coding Guidelines} Coding Guidelines >> >> >> >> There are a few simple guidelines when developing for JAVA SCA: >> >> * The basic coding style used is the described at [Sun Java coding >> >> standards|http://java.sun.com/docs/codeconv/] 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. >> >> >> >> * Always include the Apache License Headers on all files (both source >> >> code >> >> files and resource files such as xml documents) >> >> >> >> * Include a descriptive log message for checkins, for example "fixed >> >> such >> >> and such problem". >> >> >> >> 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 >> >> [https://svn.apache.org/repos/asf/tuscany/java/etc/] >> >> >> >> h4. Naming conventions to increase consistency >> >> >> >> *Folder Names:* Please use all lowercases and dashes in folder names >> >> (like >> >> in the jar names) >> >> - Maven artifact id = tuscany-<folder name> >> >> >> >> *Package names:* 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.\* >> >> >> >> h3. {anchor:Testing} Testing >> >> >> >> 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. >> >> >> >> {info} >> >> Note that we are using JUnit 4.2 code style in OSGI development stream >> >> {info} >> >> >> >> {code} >> >> /** >> >> * Description of your test case and necessary details you find >> >> necessary >> >> */ >> >> @Scope("COMPOSITE") @EagerInit >> >> public class CalculatorTestCase { >> >> >> >> private static CalculatorService calculatorService; >> >> private static NodeLauncher launcher; >> >> private static Node node; >> >> >> >> @Reference >> >> public void setCalculatorService(CalculatorService >> >> calculatorService) { >> >> CalculatorTestCase.calculatorService = calculatorService; >> >> } >> >> >> >> >> >> @BeforeClass >> >> public static void setUpBeforeClass() throws Exception { >> >> launcher = NodeLauncher.newInstance(); >> >> String location = >> >> >> >> ContributionLocationHelper.getContributionLocation(CalculatorClient.class); >> >> node = launcher.createNode("Calculator.composite", new >> >> Contribution("test", location)); >> >> System.out.println("SCA Node API ClassLoader: " + >> >> node.getClass().getClassLoader()); >> >> node.start(); >> >> } >> >> >> >> @AfterClass >> >> public static void tearDownAfterClass() throws Exception { >> >> if (node != null) { >> >> node.stop(); >> >> node.destroy(); >> >> } >> >> if (launcher != null) { >> >> launcher.destroy(); >> >> } >> >> } >> >> >> >> @Test >> >> public void testCalculator() throws Exception { >> >> // Calculate >> >> 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); >> >> } >> >> } >> >> {code} >> >> (on) Note that we use surefire maven plugin to run the unit and >> >> integration tests, and in most cases, they are configured to match a >> >> \**/*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. >> >> >> >> h3. {anchor:Client Applications} Client Applications as SCA Components >> >> >> >> Below is how you can build client applications as an SCA component. >> >> >> >> {code} >> >> @Scope("COMPOSITE") @EagerInit >> >> public class CalculatorClient { >> >> >> >> private CalculatorService calculatorService; >> >> >> >> @Reference >> >> public void setCalculatorService(CalculatorService >> >> calculatorService) { >> >> this.calculatorService = calculatorService; >> >> } >> >> >> >> @Init >> >> public void calculate() { >> >> >> >> // Calculate >> >> System.out.println("SCA API ClassLoader: " + >> >> print(Reference.class.getClassLoader())); >> >> System.out.println("3 + 2=" + calculatorService.add(3, 2)); >> >> System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); >> >> System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); >> >> System.out.println("3 / 2=" + calculatorService.divide(3, 2)); >> >> } >> >> >> >> private static String print(ClassLoader cl) { >> >> StringBuffer buf = new StringBuffer(); >> >> for (; cl != null;) { >> >> buf.append(cl.toString()); >> >> buf.append(' '); >> >> cl = cl.getParent(); >> >> } >> >> return buf.toString(); >> >> } >> >> >> >> } >> >> {code} >> >> >> >> h3. {anchor:Maven Build Structure} Maven Build Structure >> >> >> >> _We use the term Module to refer to the leaf of maven tree._ >> >> * sca/pom.xml's parent will be pom/parent/pom.xml >> >> * Other poms will use the pom from the parent folder as parent pom >> >> * Group id: org.apache.tuscany.sca >> >> * 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 >> >> * pom names begin Apache Tuscany SCA >> >> * Eclipse projects are generated for all built modules using mvn >> >> \-Peclipse eclipse:eclipse >> >> >> >> h4. Adding a new module and not ready to integrate? >> >> >> >> '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. >> >> >> >> h2. Development Hints >> >> >> >> h3. {anchor:Webapp in Eclipse} Generating Eclipse WTP Web Projects for >> >> Webapp samples >> >> >> >> If you're using Eclipse WTP and want to get WTP Web Projects generated >> >> for our Webapp samples you can simply pass a \-Dwtpversion=1.5 option >> >> to >> >> the usual mvn eclipse:eclipse command, like this: >> >> mvn \-Dwtpversion=1.5 \-Peclipse eclipse:eclipse >> >> >> >> The magic \-Dwtpversion=1.5 option will add the WTP Web project nature >> >> to >> >> all the Eclipse projects with <packaging>war</packaging> in their Maven >> >> pom.xml. You'll then be able to add these projects to a WTP Tomcat or >> >> Geronimo Server configuration, to publish and run them straight from >> >> your Eclipse workspace. >> >> >> >> h3:{anchor:Ant} Generating Dependencies for Ant in Samples >> >> >> >> Figuring out the package dependency to include in Ant build.xml can be >> >> a >> >> pain. Here is a quick >> >> script which works in Linux environment for war files. >> >> {code} >> >> jar tvf sample-feed-aggregator-webapp.war | grep .jar | awk '{ printf >> >> "%s\n", $8 }' | sed -e "s/WEB-INF\/lib\///" | awk '{ printf "<include >> >> name=\"%s\"/>\n", $1 }' | grep -v tuscany >> >> {code} >> >> {column} >> >> {section} >> >> >> >> --------------------------------------------------------------------- >> >> CONFLUENCE INFORMATION >> >> This message is automatically generated by Confluence >> >> >> >> Unsubscribe or edit your notifications preferences >> >> http://cwiki.apache.org/confluence/users/viewnotifications.action >> >> >> >> If you think it was sent incorrectly contact one of the administrators >> >> http://cwiki.apache.org/confluence/administrators.action >> >> >> >> If you want more information on Confluence, or have a bug to report see >> >> http://www.atlassian.com/software/confluence >> >> >> >> >> > >> > >> >> >> >> -- >> Luciano Resende >> Apache Tuscany, Apache PhotArk >> http://people.apache.org/~lresende >> http://lresende.blogspot.com/ > >
-- Luciano Resende Apache Tuscany, Apache PhotArk http://people.apache.org/~lresende http://lresende.blogspot.com/
