You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2009/11/05 19:05:11 UTC

svn commit: r833106 - in /tuscany/sandbox/travelsample/launchers/common: ./ build.xml pom.xml src/main/java/scatours/FullAppLauncher.java src/main/java/scatours/launcher/ src/main/java/scatours/launcher/LauncherUtil.java

Author: rfeng
Date: Thu Nov  5 18:05:10 2009
New Revision: 833106

URL: http://svn.apache.org/viewvc?rev=833106&view=rev
Log:
Add a utility for launchers to handle different ways to locate contributions

Added:
    tuscany/sandbox/travelsample/launchers/common/
      - copied from r826319, tuscany/sandbox/travelsample/launchers/fullapp/
    tuscany/sandbox/travelsample/launchers/common/pom.xml
      - copied, changed from r830020, tuscany/sandbox/travelsample/launchers/fullapp/pom.xml
    tuscany/sandbox/travelsample/launchers/common/src/main/java/scatours/launcher/
    tuscany/sandbox/travelsample/launchers/common/src/main/java/scatours/launcher/LauncherUtil.java   (with props)
Removed:
    tuscany/sandbox/travelsample/launchers/common/build.xml
    tuscany/sandbox/travelsample/launchers/common/src/main/java/scatours/FullAppLauncher.java

Copied: tuscany/sandbox/travelsample/launchers/common/pom.xml (from r830020, tuscany/sandbox/travelsample/launchers/fullapp/pom.xml)
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/launchers/common/pom.xml?p2=tuscany/sandbox/travelsample/launchers/common/pom.xml&p1=tuscany/sandbox/travelsample/launchers/fullapp/pom.xml&r1=830020&r2=833106&rev=833106&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/launchers/fullapp/pom.xml (original)
+++ tuscany/sandbox/travelsample/launchers/common/pom.xml Thu Nov  5 18:05:10 2009
@@ -25,187 +25,21 @@
         <version>1.6-SNAPSHOT</version>
         <!--relativePath>../../pom.xml</relativePath-->
     </parent><version>1.0-SNAPSHOT</version>
-    <artifactId>scatours-launcher-fullapp</artifactId>
-    <name>Apache Tuscany SCA Tours Full Application Launcher</name>
+    <artifactId>scatours-launcher-common</artifactId>
+    <name>Apache Tuscany SCA Tours Common Utility for Launchers</name>
 
     <dependencies>
     
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-assembly</artifactId>
-            <version>1.6-SNAPSHOT</version>
-        </dependency>
-        
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-core</artifactId>
-            <version>1.6-SNAPSHOT</version>
-        </dependency>        
-            
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-assembly-xml</artifactId>
-            <version>1.6-SNAPSHOT</version>
-        </dependency>
-        
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-node-api</artifactId>
             <version>1.6-SNAPSHOT</version>
         </dependency>
         
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-node-launcher</artifactId>
-            <version>1.6-SNAPSHOT</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-domain-manager</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-node-runtime</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>
-        
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-java</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>        
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-java-runtime</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-widget-runtime-tuscany</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-binding-atom-abdera</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-binding-jsonrpc-js</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-binding-http-runtime</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-binding-ws-axis2</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-binding-sca-axis2</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-binding-ejb-runtime</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-ejb</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>
-        
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-bpel-ode</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency> 
-        
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-spring</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency> 
-        
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-spring-runtime</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency>        
-
-<!-- 
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-policy-transaction</artifactId>
-            <version>1.6-SNAPSHOT</version>
-            <scope>runtime</scope>
-        </dependency> 
--->        
-        <dependency>
-            <groupId>org.apache.derby</groupId>
-            <artifactId>derby</artifactId>
-            <version>10.3.1.4</version>
-            <scope>runtime</scope>
-        </dependency>
 
     </dependencies>
     
     <build>
        <finalName>${artifactId}</finalName>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
-                <version>2.2</version>
-                <configuration>
-                    <archive>
-                        <manifest>
-                            <addClasspath>true</addClasspath>
-                            <classpathPrefix>../lib/</classpathPrefix>
-                            <mainClass>scatours.FullAppLauncher</mainClass>
-                        </manifest>
-                    </archive>
-                </configuration>
-            </plugin>
-        </plugins>              
     </build>
 </project>

Added: tuscany/sandbox/travelsample/launchers/common/src/main/java/scatours/launcher/LauncherUtil.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/launchers/common/src/main/java/scatours/launcher/LauncherUtil.java?rev=833106&view=auto
==============================================================================
--- tuscany/sandbox/travelsample/launchers/common/src/main/java/scatours/launcher/LauncherUtil.java (added)
+++ tuscany/sandbox/travelsample/launchers/common/src/main/java/scatours/launcher/LauncherUtil.java Thu Nov  5 18:05:10 2009
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package scatours.launcher;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.SCAContribution;
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
+
+/**
+ * This utility locates SCA contributions by name so that the launcher can work with various environments where 
+ * contributions are stored differently.
+ */
+public class LauncherUtil {
+
+    /**
+     * Locate an SCA contribution by name
+     * @param name The name of the SCA contribution archive
+     * @return The SCAContribution
+     */
+    public static SCAContribution locate(String name) {
+        // Try to use the target/classes directory inside Eclipse/Maven
+        File file = new File("../../contributions/" + name + "/target/classes");
+        if (!file.exists()) {
+            // Try to use the target/<contribution>.jar that is generated by maven build
+            file = new File("../../contributions/" + name + "/target/" + name + ".jar");
+            if (!file.exists()) {
+                // Try to use the contribution jar under the contributions folder of the distribution
+                file = new File("../contributions/" + name + ".jar");
+                if (!file.exists()) {
+                    throw new IllegalArgumentException("Contribution " + name + " cannot be located.");
+                }
+            }
+        }
+        return new SCAContribution(name, file.toURI().toString());
+    }
+
+    /**
+     * Locate an SCA contribution by replacing the ${name} in the pattern 
+     * @param urlPattern The url pattern that contains ${name}
+     * @param name The name of the contribution archive
+     * @return The SCAContribution
+     */
+    public static SCAContribution locate(String urlPattern, String name) {
+        String url = urlPattern.replace("${name}", name);
+        return new SCAContribution(name, url);
+    }
+
+    /**
+     * Create an SCA node from a list of contribution names
+     * @param composite
+     * @param contributionNames
+     * @return
+     */
+    public static SCANode createNode(String composite, String... contributionNames) {
+        SCAContribution[] contributions = new SCAContribution[contributionNames.length];
+        int index = 0;
+        for (String name : contributionNames) {
+            contributions[index++] = locate(name);
+        }
+        SCANode node = SCANodeFactory.newInstance().createSCANode(composite, contributions);
+        return node;
+    }
+}

Propchange: tuscany/sandbox/travelsample/launchers/common/src/main/java/scatours/launcher/LauncherUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sandbox/travelsample/launchers/common/src/main/java/scatours/launcher/LauncherUtil.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date