You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2009/02/20 12:54:42 UTC

svn commit: r746217 - in /camel/trunk/components: ./ camel-web-standalone/ camel-web-standalone/src/ camel-web-standalone/src/main/ camel-web-standalone/src/main/assembly/ camel-web-standalone/src/main/java/ camel-web-standalone/src/main/java/org/ came...

Author: jstrachan
Date: Fri Feb 20 11:54:42 2009
New Revision: 746217

URL: http://svn.apache.org/viewvc?rev=746217&view=rev
Log:
CAMEL-1355 added a stand alone camel-web-standalone.jar which can be executed via 'java -jar camel-web-standalone.jar' to boot up Camel Web

Added:
    camel/trunk/components/camel-web-standalone/
    camel/trunk/components/camel-web-standalone/pom.xml   (with props)
    camel/trunk/components/camel-web-standalone/src/
    camel/trunk/components/camel-web-standalone/src/main/
    camel/trunk/components/camel-web-standalone/src/main/assembly/
    camel/trunk/components/camel-web-standalone/src/main/assembly/assembly.xml   (with props)
    camel/trunk/components/camel-web-standalone/src/main/java/
    camel/trunk/components/camel-web-standalone/src/main/java/org/
    camel/trunk/components/camel-web-standalone/src/main/java/org/apache/
    camel/trunk/components/camel-web-standalone/src/main/java/org/apache/camel/
    camel/trunk/components/camel-web-standalone/src/main/java/org/apache/camel/web/
    camel/trunk/components/camel-web-standalone/src/main/java/org/apache/camel/web/Main.java   (with props)
Modified:
    camel/trunk/components/pom.xml

Added: camel/trunk/components/camel-web-standalone/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web-standalone/pom.xml?rev=746217&view=auto
==============================================================================
--- camel/trunk/components/camel-web-standalone/pom.xml (added)
+++ camel/trunk/components/camel-web-standalone/pom.xml Fri Feb 20 11:54:42 2009
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+  <parent>
+    <artifactId>components</artifactId>
+    <groupId>org.apache.camel</groupId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>camel-web-standalone</artifactId>
+
+  <name>Camel :: Web :: Standalone</name>
+  <description>Standalone Camel Web</description>
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-web</artifactId>
+      <version>${project.version}</version>
+      <type>war</type>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty-runner</artifactId>
+      <version>7.0.0.pre5</version>
+    </dependency>
+
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <appendAssemblyId>false</appendAssemblyId>
+          <descriptors>
+            <descriptor>src/main/assembly/assembly.xml</descriptor>
+          </descriptors>
+          <archive>
+            <manifest>
+              <mainClass>org.apache.camel.web.Main</mainClass>
+            </manifest>
+          </archive>
+        </configuration>
+
+        <executions>
+          <execution>
+            <id>make-assembly</id>
+            <phase>package</phase>
+            <goals>
+              <goal>attached</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file

Propchange: camel/trunk/components/camel-web-standalone/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-web-standalone/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: camel/trunk/components/camel-web-standalone/src/main/assembly/assembly.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web-standalone/src/main/assembly/assembly.xml?rev=746217&view=auto
==============================================================================
--- camel/trunk/components/camel-web-standalone/src/main/assembly/assembly.xml (added)
+++ camel/trunk/components/camel-web-standalone/src/main/assembly/assembly.xml Fri Feb 20 11:54:42 2009
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<assembly>
+  <id>camel-web-standalone</id>
+  <formats>
+    <format>jar</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+      <directory>src/main/assembly</directory>
+      <outputDirectory></outputDirectory>
+      <includes>
+        <include>embedded.properties</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory></outputDirectory>
+      <unpack>true</unpack>
+      <outputFileNameMapping></outputFileNameMapping>
+      <includes>
+        <include>org.apache.camel:camel-web-standalone</include>
+        <include>log4j:log4j</include>
+      </includes>
+    </dependencySet>
+    <dependencySet>
+      <unpack>true</unpack>
+      <outputDirectory></outputDirectory>
+      <outputFileNameMapping></outputFileNameMapping>
+      <includes>
+        <include>org.mortbay.jetty:jetty-runner</include>
+      </includes>
+    </dependencySet>
+    <dependencySet>
+      <outputDirectory></outputDirectory>
+      <outputFileNameMapping>camel-web.war</outputFileNameMapping>
+      <includes>
+        <include>org.apache.camel:camel-web</include>
+      </includes>
+    </dependencySet>
+  </dependencySets>
+</assembly>
\ No newline at end of file

Propchange: camel/trunk/components/camel-web-standalone/src/main/assembly/assembly.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-web-standalone/src/main/assembly/assembly.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: camel/trunk/components/camel-web-standalone/src/main/java/org/apache/camel/web/Main.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web-standalone/src/main/java/org/apache/camel/web/Main.java?rev=746217&view=auto
==============================================================================
--- camel/trunk/components/camel-web-standalone/src/main/java/org/apache/camel/web/Main.java (added)
+++ camel/trunk/components/camel-web-standalone/src/main/java/org/apache/camel/web/Main.java Fri Feb 20 11:54:42 2009
@@ -0,0 +1,81 @@
+/**
+ * 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 org.apache.camel.web;
+
+import org.mortbay.jetty.runner.Runner;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * A bootstrap class for starting Jetty Runner using an embedded war
+ *
+ * @version $Revision: 745637 $
+ */
+public class Main {
+    private static final String WAR_POSTFIX = ".war";
+    private static final String WAR_NAME = "camel-web";
+    private static final String WAR_FILENAME = WAR_NAME + WAR_POSTFIX;
+    private static final int KB = 1024;
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("Welcome to Apache Camel!");
+        
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        URL resource = classLoader.getResource(WAR_FILENAME);
+        if (resource == null) {
+            System.err.println("Could not find the " + WAR_FILENAME + " on classpath!");
+            System.exit(1);
+        }
+
+        File warFile = File.createTempFile(WAR_NAME + "-", WAR_POSTFIX);
+        System.out.println("Extracting " + WAR_FILENAME + " to " + warFile + " ...");
+
+        writeStreamTo(resource.openStream(), new FileOutputStream(warFile), 8 * KB);
+
+        System.out.println("Extracted " + WAR_FILENAME);
+        System.out.println("Launching Jetty Runner...");
+
+        List<String> argsList = new ArrayList<String>();
+        if (args != null) {
+            argsList.addAll(Arrays.asList(args));
+        }
+        argsList.add(warFile.getCanonicalPath());
+        Runner.main(argsList.toArray(new String[argsList.size()]));
+        System.exit(0);
+    }
+
+    public static int writeStreamTo(final InputStream input, final OutputStream output, int bufferSize) throws IOException {
+        int available = Math.min(input.available(), 256 * KB);
+        byte[] buffer = new byte[Math.max(bufferSize, available)];
+        int answer = 0;
+        int count = input.read(buffer);
+        while (count >= 0) {
+            output.write(buffer, 0, count);
+            answer += count;
+            count = input.read(buffer);
+        }
+        return answer;
+    }
+}

Propchange: camel/trunk/components/camel-web-standalone/src/main/java/org/apache/camel/web/Main.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-web-standalone/src/main/java/org/apache/camel/web/Main.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: camel/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/pom.xml?rev=746217&r1=746216&r2=746217&view=diff
==============================================================================
--- camel/trunk/components/pom.xml (original)
+++ camel/trunk/components/pom.xml Fri Feb 20 11:54:42 2009
@@ -96,5 +96,6 @@
     <module>camel-xmpp</module>
     <module>camel-xstream</module>
     <module>camel-web</module>
+    <module>camel-web-standalone</module>
   </modules>
 </project>