commit - 63823a9f1ddefd9361bcf5223c7b9e71fee7bf40
commit + 3646830693ecf3652ff9954002a685430634ad59
blob - /dev/null
blob + 4ffa13f363bb7e2a984cd5dbd5049b70d07bfd07 (mode 644)
--- /dev/null
+++ modules/server/moxo-server.iml
+<?xml version="1.0" encoding="UTF-8"?>
+<module relativePaths="false" MavenProjectsManager.isMavenModule="true" version="4">
+ <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/target/classes" />
+ <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+ <excludeFolder url="file://$MODULE_DIR$/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" exported="" name="Maven: org.mortbay.jetty:jetty:6.1.1" level="project" />
+ <orderEntry type="library" exported="" name="Maven: org.mortbay.jetty:jetty-util:6.1.1" level="project" />
+ <orderEntry type="library" exported="" name="Maven: org.mortbay.jetty:servlet-api-2.5:6.1.1" level="project" />
+ <orderEntry type="module" module-name="webdav" exported="" />
+ <orderEntry type="library" exported="" name="Maven: commons-vfs:commons-vfs:1.0" level="project" />
+ <orderEntry type="library" exported="" name="Maven: commons-logging:commons-logging:1.0.4" level="project" />
+ <orderEntry type="library" exported="" name="Maven: commons-httpclient:commons-httpclient:3.0.1" level="project" />
+ <orderEntry type="library" exported="" name="Maven: junit:junit:3.8.1" level="project" />
+ <orderEntry type="library" exported="" name="Maven: commons-codec:commons-codec:1.3" level="project" />
+ <orderEntry type="library" exported="" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
+ <orderEntry type="library" exported="" name="Maven: dom4j:dom4j:1.6.1" level="project" />
+ <orderEntry type="library" exported="" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
+ <orderEntry type="library" exported="" name="Maven: jaxen:jaxen:1.1.1" level="project" />
+ <orderEntry type="library" exported="" name="Maven: jdom:jdom:1.0" level="project" />
+ <orderEntry type="library" exported="" name="Maven: xerces:xercesImpl:2.6.2" level="project" />
+ <orderEntry type="library" exported="" name="Maven: xom:xom:1.0" level="project" />
+ <orderEntry type="library" exported="" name="Maven: xerces:xmlParserAPIs:2.6.2" level="project" />
+ <orderEntry type="library" exported="" name="Maven: xalan:xalan:2.6.0" level="project" />
+ <orderEntry type="library" exported="" name="Maven: com.ibm.icu:icu4j:2.6.1" level="project" />
+ <orderEntry type="library" exported="" name="Maven: javax.servlet:servlet-api:2.5" level="project" />
+ <orderEntry type="module" module-name="vfs.s3" exported="" />
+ <orderEntry type="library" exported="" name="Maven: net.java.dev.jets3t:jets3t:0.6.1" level="project" />
+ </component>
+ <component name="copyright">
+ <Base>
+ <setting name="state" value="1" />
+ </Base>
+ <LanguageOptions name="HTML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JAVA">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JSP">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JavaScript">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="Properties">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="XML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="__TEMPLATE__">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright &#36;today.year Matthias L. Jugel. Licensed 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." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="4" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ </component>
+</module>
+
blob - /dev/null
blob + 476dfe8db6dc10c84d565ecc644ec9683126cfdd (mode 644)
--- /dev/null
+++ modules/server/pom.xml
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.thinkberg</groupId>
+ <artifactId>moxo-server</artifactId>
+ <name>Moxo Server</name>
+ <version>1.0</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>6.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.thinkberg</groupId>
+ <artifactId>webdav</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.thinkberg</groupId>
+ <artifactId>vfs.s3</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <verbose>true</verbose>
+ <fork>true</fork>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+ <!--
+ mvn test
+ Documentation: http://maven.apache.org/plugins/maven-surefire-plugin/
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/MoxoTest.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+
+ <!--
+ jar
+ mvn package
+ Documentation: http://maven.apache.org/plugins/maven-jar-plugin/
+ -->
+ <!--<plugin>-->
+ <!--<groupId>org.apache.maven.plugins</groupId>-->
+ <!--<artifactId>maven-jar-plugin</artifactId>-->
+ <!--<executions>-->
+ <!--<execution>-->
+ <!--<phase>package</phase>-->
+ <!--<goals>-->
+ <!--<goal>jar</goal>-->
+ <!--</goals>-->
+ <!--<configuration>-->
+ <!--<classifier>client</classifier>-->
+ <!--<includes>-->
+ <!--<include>**/client/*</include>-->
+ <!--<include>**/servlet/*</include>-->
+ <!--<include>barcode-client.properties</include>-->
+ <!--<include>log4j.properties</include>-->
+ <!--<include>images/*</include>-->
+ <!--<include>templates/*</include>-->
+ <!--</includes>-->
+ <!--</configuration>-->
+ <!--</execution>-->
+ <!--</executions>-->
+ <!--</plugin>-->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>com.thinkberg.moxo.Main</mainClass>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ <includes>
+ <include>**/moxo/*</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
blob - /dev/null
blob + 834ca79e40db93587eb89c07798c51befb4cdbe8 (mode 644)
--- /dev/null
+++ modules/server/src/main/java/com/thinkberg/moxo/Main.java
+/*
+ * Copyright 2007 Matthias L. Jugel.
+ *
+ * Licensed 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 com.thinkberg.moxo;
+
+import java.io.*;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.Policy;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+/**
+ * The launcher is responsible for extracting referenced libraries from the jar and
+ * setting up the classpath.
+ *
+ * @author Matthias L. Jugel
+ */
+public class Main {
+ private final static URL location = Main.class.getProtectionDomain().getCodeSource().getLocation();
+
+ public static void main(String args[])
+ throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+ ClassLoader parentClassLoader = Thread.currentThread().getContextClassLoader();
+ if (null == parentClassLoader) {
+ parentClassLoader = Main.class.getClassLoader();
+ }
+ if (null == parentClassLoader) {
+ parentClassLoader = ClassLoader.getSystemClassLoader();
+ }
+ URLClassLoader classLoader = new URLClassLoader(initClassPath(), parentClassLoader);
+ Thread.currentThread().setContextClassLoader(classLoader);
+
+ System.setSecurityManager(null);
+
+ try {
+ Policy.getPolicy().refresh();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ Class mainClass = classLoader.loadClass("com.thinkberg.moxo.MoxoJettyRunner");
+ @SuppressWarnings({"RedundantArrayCreation"})
+ final Method main = mainClass.getDeclaredMethod("main", new Class[]{String[].class});
+ main.invoke(null, new Object[]{args});
+ }
+
+ /**
+ * Read the jar manifest and add class-path entries to the classpath.
+ *
+ * @return the classpath
+ */
+ @SuppressWarnings({"ConstantConditions"})
+ private static URL[] initClassPath() {
+ List<URL> urlArray = new ArrayList<URL>();
+ InputStream manifestIn = null;
+ InputStream jarIn = null;
+ try {
+ manifestIn = location.openStream();
+ JarInputStream launcherJarIs = new JarInputStream(manifestIn);
+ StringBuffer classPath = new StringBuffer(location.getFile());
+ List<URL> classpathList = new ArrayList<URL>(urlArray);
+ JarEntry jarEntry;
+ while (null != (jarEntry = launcherJarIs.getNextJarEntry())) {
+ if (!jarEntry.isDirectory() && jarEntry.getName().endsWith(".jar")) {
+ try {
+ URL classPathEntry = getResourceUrl(jarEntry.getName());
+ if (!classpathList.contains(classPathEntry)) {
+ urlArray.add(classPathEntry);
+ classPath.append(File.pathSeparatorChar);
+ classPath.append(classPathEntry.getFile());
+ }
+ } catch (IOException e) {
+ System.err.println("ignored '" + jarEntry.getName() + "'");
+ }
+ }
+ }
+
+ System.setProperty("java.class.path", classPath.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ manifestIn.close();
+ } catch (Throwable ignore) {
+ // ignore errors
+ }
+ try {
+ jarIn.close();
+ } catch (Throwable ignore) {
+ // ignore errors
+ }
+ }
+ return urlArray.toArray(new URL[urlArray.size()]);
+ }
+
+ /**
+ * Get URL.
+ *
+ * @param resource resource name/path
+ * @return the url pointing to the resource
+ * @throws IOException if the resource cannot be accessed
+ */
+ private static URL getResourceUrl(String resource) throws IOException {
+ File directoryBase = new File(location.getFile()).getParentFile();
+ File file = new File(resource);
+ if (file.isAbsolute() && file.exists()) {
+ return file.toURL();
+ }
+ file = new File(directoryBase, resource);
+ if (file.exists()) {
+ return file.toURL();
+ }
+
+ URL resourceURL = Main.class.getResource("/" + resource);
+ if (null != resourceURL) {
+ return extract(resourceURL);
+ }
+
+ throw new MalformedURLException(resource);
+ }
+
+ /**
+ * Extract file from launcher jar to be able to access is via classpath.
+ *
+ * @param resource the jar resource to be extracted
+ * @return a url pointing to the new file
+ * @throws IOException if the extraction was not possible
+ */
+ private static URL extract(URL resource) throws IOException {
+ File f = File.createTempFile("launcher_", ".jar");
+ f.deleteOnExit();
+ if (f.getParentFile() != null) {
+ f.getParentFile().mkdirs();
+ }
+ InputStream is = new BufferedInputStream(resource.openStream());
+ FileOutputStream os = new FileOutputStream(f);
+ byte[] arr = new byte[8192];
+ for (int i = 0; i >= 0; i = is.read(arr)) {
+ os.write(arr, 0, i);
+ }
+ is.close();
+ os.close();
+ return f.toURL();
+ }
+}
\ No newline at end of file
blob - /dev/null
blob + 81fa814c760d3f3302548ef451f1fcad06157e6d (mode 644)
--- /dev/null
+++ modules/server/src/main/java/com/thinkberg/moxo/MoxoJettyRunner.java
+/*
+ * Copyright 2007 Matthias L. Jugel.
+ *
+ * Licensed 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 com.thinkberg.moxo;
+
+import org.mortbay.jetty.Server;
+import org.mortbay.xml.XmlConfiguration;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * The Java Webserver starter uses jetty.
+ *
+ * @author Matthias L. Jugel
+ */
+public class MoxoJettyRunner {
+ private static final String CONF_JETTY_XML = "/jetty.xml";
+
+ public static void main(String[] args) {
+ System.out.println("Moxo S3 DAV Proxy (c) 2007 Matthias L. Jugel");
+
+ // set encoding of the JVM and make sure Jetty decodes URIs correctly
+ System.setProperty("file.encoding", "UTF-8");
+ System.setProperty("org.mortbay.util.URI.charset", "UTF-8");
+
+ try {
+ Server server = new Server();
+ XmlConfiguration xmlConfiguration = new XmlConfiguration(getXmlConfigurationUrl());
+ xmlConfiguration.configure(server);
+ server.start();
+ server.join();
+ } catch (Exception e) {
+ System.err.println("Can't start server: " + e.getMessage());
+ System.exit(1);
+ }
+ }
+
+ private static URL getXmlConfigurationUrl() {
+ String configFile = System.getProperty("jetty.xml", CONF_JETTY_XML);
+ URL url = MoxoJettyRunner.class.getResource(configFile);
+ if (null == url) {
+ try {
+ url = new File(configFile).toURL();
+ System.err.println("Loading configuration from file: " + url.toExternalForm());
+ } catch (MalformedURLException e) {
+ // ignore ...
+ }
+ }
+ return url;
+ }
+}
blob - /dev/null
blob + ee8611fc7310c54462bf8672a9ff9845cbab912a (mode 644)
--- /dev/null
+++ modules/server/src/main/resources/commons-logging.properties
+#
+# Copyright 2007 Matthias L. Jugel.
+#
+# Licensed 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.
+#
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger
+org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
\ No newline at end of file
blob - /dev/null
blob + 71c406fc4d38c233930be39548d9d3767b2a5d3b (mode 644)
--- /dev/null
+++ modules/server/src/main/resources/jetty.xml
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
+
+<!-- =============================================================== -->
+<!-- Configure the Jetty Server -->
+<!-- -->
+<!-- Documentation of this file format can be found at: -->
+<!-- http://docs.codehaus.org/display/JETTY/jetty.xml -->
+<!-- -->
+<!-- =============================================================== -->
+
+
+<Configure id="Server" class="org.mortbay.jetty.Server">
+
+ <!-- =========================================================== -->
+ <!-- Server Thread Pool -->
+ <!-- =========================================================== -->
+ <Set name="ThreadPool">
+ <!-- Default bounded blocking threadpool
+ -->
+ <New class="org.mortbay.thread.BoundedThreadPool">
+ <Set name="minThreads">10</Set>
+ <Set name="lowThreads">50</Set>
+ <Set name="maxThreads">250</Set>
+ </New>
+
+ <!-- Optional Java 5 bounded threadpool with job queue
+ <New class="org.mortbay.thread.concurrent.ThreadPool">
+ <Arg type="int">0</Arg>
+ <Set name="corePoolSize">10</Set>
+ <Set name="maximumPoolSize">250</Set>
+ </New>
+ -->
+ </Set>
+
+
+ <!-- =========================================================== -->
+ <!-- Set connectors -->
+ <!-- =========================================================== -->
+ <!-- One of each type! -->
+ <!-- =========================================================== -->
+
+ <!-- Use this connector for many frequently idle connections
+ and for threadless continuations.
+ -->
+ <Call name="addConnector">
+ <Arg>
+ <New class="org.mortbay.jetty.nio.SelectChannelConnector">
+ <Set name="port">
+ <SystemProperty name="jetty.port" default="8080"/>
+ </Set>
+ <Set name="maxIdleTime">30000</Set>
+ <Set name="Acceptors">2</Set>
+ <Set name="confidentialPort">8443</Set>
+ </New>
+ </Arg>
+ </Call>
+
+ <Call name="addConnector">
+ <Arg>
+ <New class="org.mortbay.jetty.security.SslSocketConnector">
+ <Set name="Port">8443</Set>
+ <Set name="maxIdleTime">30000</Set>
+ <Set name="keystore"><SystemProperty name="user.home" default="."/>/.keystore
+ </Set>
+ <Set name="password">OBF:1fvu20731x191vul1vup1x1d20731ftg</Set>
+ <Set name="keyPassword">OBF:1fvu20731x191vul1vup1x1d20731ftg</Set>
+ <Set name="truststore"><SystemProperty name="user.home" default="."/>/.keystore
+ </Set>
+ <Set name="trustPassword">OBF:1fvu20731x191vul1vup1x1d20731ftg</Set>
+ </New>
+ </Arg>
+ </Call>
+
+ <!-- Use this connector if NIO is not available.
+ <Call name="addConnector">
+ <Arg>
+ <New class="org.mortbay.jetty.bio.SocketConnector">
+ <Set name="port">8081</Set>
+ <Set name="maxIdleTime">50000</Set>
+ <Set name="lowResourceMaxIdleTime">1500</Set>
+ </New>
+ </Arg>
+ </Call>
+ -->
+
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- To add a HTTPS SSL listener -->
+ <!-- see jetty-ssl.xml to add an ssl connector. use -->
+ <!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+
+ <!-- =========================================================== -->
+ <!-- Set up global session ID manager -->
+ <!-- =========================================================== -->
+ <!--
+ <Set name="sessionIdManager">
+ <New class="org.mortbay.jetty.servlet.HashSessionIdManager">
+ <Set name="workerName">node1</Set>
+ </New>
+ </Set>
+ -->
+
+ <!-- =========================================================== -->
+ <!-- Set handler Collection Structure -->
+ <!-- =========================================================== -->
+ <Set name="handler">
+ <New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection">
+ <Set name="handlers">
+ <Array type="org.mortbay.jetty.Handler">
+ <Item>
+ <New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/>
+ </Item>
+ <Item>
+ <New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/>
+ </Item>
+ <Item>
+ <New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/>
+ </Item>
+ </Array>
+ </Set>
+ </New>
+ </Set>
+
+ <!-- Set the handler for our web dav servlet -->
+ <Set name="handler">
+ <New id="WebDAVServletContext" class="org.mortbay.jetty.servlet.Context">
+ <Set name="contextPath">/</Set>
+ <Set name="resourceBase">
+ <SystemProperty name="jetty.docroot" default="."/>
+ </Set>
+ <Call name="addServlet">
+ <Arg>com.thinkberg.webdav.servlet.MoxoWebDAVServlet</Arg>
+ <Arg>/*</Arg>
+ <Call name="setInitParameter">
+ <Arg>vfs.uri</Arg>
+ <Arg>ram:/</Arg>
+ </Call>
+ <Call name="setInitParameter">
+ <Arg>vfs.auth.domain</Arg>
+ <Arg></Arg>
+ </Call>
+ <Call name="setInitParameter">
+ <Arg>vfs.auth.user</Arg>
+ <Arg>theuser</Arg>
+ </Call>
+ <Call name="setInitParameter">
+ <Arg>vfs.auth.password</Arg>
+ <Arg>thepassword</Arg>
+ </Call>
+ </Call>
+
+ </New>
+ </Set>
+
+
+ <!-- =========================================================== -->
+ <!-- Configure Authentication Realms -->
+ <!-- Realms may be configured for the entire server here, or -->
+ <!-- they can be configured for a specific web app in a context -->
+ <!-- configuration (see $(jetty.home)/contexts/test.xml for an -->
+ <!-- example). -->
+ <!-- =========================================================== -->
+ <Set name="UserRealms">
+ <Array type="org.mortbay.jetty.security.UserRealm">
+ <!--
+ <Item>
+ <New class="org.mortbay.jetty.security.HashUserRealm">
+ <Set name="name">Test Realm</Set>
+ <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
+ </New>
+ </Item>
+ -->
+ </Array>
+ </Set>
+
+ <!-- =========================================================== -->
+ <!-- Configure Request Log -->
+ <!-- Request logs may be configured for the entire server here, -->
+ <!-- or they can be configured for a specific web app in a -->
+ <!-- contexts configuration (see $(jetty.home)/contexts/test.xml -->
+ <!-- for an example). -->
+ <!-- =========================================================== -->
+ <Ref id="RequestLog">
+ <Set name="requestLog">
+ <New id="RequestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
+ <Arg>
+ <SystemProperty name="jetty.logs" default="./logs"/>
+ /yyyy_mm_dd.request.log
+ </Arg>
+ <Set name="retainDays">90</Set>
+ <Set name="append">true</Set>
+ <Set name="extended">false</Set>
+ <Set name="LogTimeZone">GMT</Set>
+ </New>
+ </Set>
+ </Ref>
+
+ <!-- =========================================================== -->
+ <!-- extra options -->
+ <!-- =========================================================== -->
+ <Set name="stopAtShutdown">true</Set>
+ <!-- ensure/prevent Server: header being sent to browsers -->
+ <Set name="sendServerVersion">true</Set>
+
+</Configure>
blob - /dev/null
blob + 06d0ba45d0947de8c84d470d4bc1a1fd74c4346a (mode 644)
--- /dev/null
+++ modules/server/src/main/resources/simplelog.properties
+#
+# Copyright 2007 Matthias L. Jugel.
+#
+# Licensed 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.
+#
+
+org.apache.commons.logging.simplelog.defaultlog=error
+org.apache.commons.logging.simplelog.log.com.thinkberg.vfs.s3=info
+org.apache.commons.logging.simplelog.log.com.thinkberg.webdav=info
\ No newline at end of file
blob - 834ca79e40db93587eb89c07798c51befb4cdbe8 (mode 644)
blob + /dev/null
--- src/main/java/com/thinkberg/moxo/Main.java
+++ /dev/null
-/*
- * Copyright 2007 Matthias L. Jugel.
- *
- * Licensed 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 com.thinkberg.moxo;
-
-import java.io.*;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.security.Policy;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-
-/**
- * The launcher is responsible for extracting referenced libraries from the jar and
- * setting up the classpath.
- *
- * @author Matthias L. Jugel
- */
-public class Main {
- private final static URL location = Main.class.getProtectionDomain().getCodeSource().getLocation();
-
- public static void main(String args[])
- throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
- ClassLoader parentClassLoader = Thread.currentThread().getContextClassLoader();
- if (null == parentClassLoader) {
- parentClassLoader = Main.class.getClassLoader();
- }
- if (null == parentClassLoader) {
- parentClassLoader = ClassLoader.getSystemClassLoader();
- }
- URLClassLoader classLoader = new URLClassLoader(initClassPath(), parentClassLoader);
- Thread.currentThread().setContextClassLoader(classLoader);
-
- System.setSecurityManager(null);
-
- try {
- Policy.getPolicy().refresh();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- Class mainClass = classLoader.loadClass("com.thinkberg.moxo.MoxoJettyRunner");
- @SuppressWarnings({"RedundantArrayCreation"})
- final Method main = mainClass.getDeclaredMethod("main", new Class[]{String[].class});
- main.invoke(null, new Object[]{args});
- }
-
- /**
- * Read the jar manifest and add class-path entries to the classpath.
- *
- * @return the classpath
- */
- @SuppressWarnings({"ConstantConditions"})
- private static URL[] initClassPath() {
- List<URL> urlArray = new ArrayList<URL>();
- InputStream manifestIn = null;
- InputStream jarIn = null;
- try {
- manifestIn = location.openStream();
- JarInputStream launcherJarIs = new JarInputStream(manifestIn);
- StringBuffer classPath = new StringBuffer(location.getFile());
- List<URL> classpathList = new ArrayList<URL>(urlArray);
- JarEntry jarEntry;
- while (null != (jarEntry = launcherJarIs.getNextJarEntry())) {
- if (!jarEntry.isDirectory() && jarEntry.getName().endsWith(".jar")) {
- try {
- URL classPathEntry = getResourceUrl(jarEntry.getName());
- if (!classpathList.contains(classPathEntry)) {
- urlArray.add(classPathEntry);
- classPath.append(File.pathSeparatorChar);
- classPath.append(classPathEntry.getFile());
- }
- } catch (IOException e) {
- System.err.println("ignored '" + jarEntry.getName() + "'");
- }
- }
- }
-
- System.setProperty("java.class.path", classPath.toString());
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- manifestIn.close();
- } catch (Throwable ignore) {
- // ignore errors
- }
- try {
- jarIn.close();
- } catch (Throwable ignore) {
- // ignore errors
- }
- }
- return urlArray.toArray(new URL[urlArray.size()]);
- }
-
- /**
- * Get URL.
- *
- * @param resource resource name/path
- * @return the url pointing to the resource
- * @throws IOException if the resource cannot be accessed
- */
- private static URL getResourceUrl(String resource) throws IOException {
- File directoryBase = new File(location.getFile()).getParentFile();
- File file = new File(resource);
- if (file.isAbsolute() && file.exists()) {
- return file.toURL();
- }
- file = new File(directoryBase, resource);
- if (file.exists()) {
- return file.toURL();
- }
-
- URL resourceURL = Main.class.getResource("/" + resource);
- if (null != resourceURL) {
- return extract(resourceURL);
- }
-
- throw new MalformedURLException(resource);
- }
-
- /**
- * Extract file from launcher jar to be able to access is via classpath.
- *
- * @param resource the jar resource to be extracted
- * @return a url pointing to the new file
- * @throws IOException if the extraction was not possible
- */
- private static URL extract(URL resource) throws IOException {
- File f = File.createTempFile("launcher_", ".jar");
- f.deleteOnExit();
- if (f.getParentFile() != null) {
- f.getParentFile().mkdirs();
- }
- InputStream is = new BufferedInputStream(resource.openStream());
- FileOutputStream os = new FileOutputStream(f);
- byte[] arr = new byte[8192];
- for (int i = 0; i >= 0; i = is.read(arr)) {
- os.write(arr, 0, i);
- }
- is.close();
- os.close();
- return f.toURL();
- }
-}
\ No newline at end of file
blob - 81fa814c760d3f3302548ef451f1fcad06157e6d (mode 644)
blob + /dev/null
--- src/main/java/com/thinkberg/moxo/MoxoJettyRunner.java
+++ /dev/null
-/*
- * Copyright 2007 Matthias L. Jugel.
- *
- * Licensed 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 com.thinkberg.moxo;
-
-import org.mortbay.jetty.Server;
-import org.mortbay.xml.XmlConfiguration;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- * The Java Webserver starter uses jetty.
- *
- * @author Matthias L. Jugel
- */
-public class MoxoJettyRunner {
- private static final String CONF_JETTY_XML = "/jetty.xml";
-
- public static void main(String[] args) {
- System.out.println("Moxo S3 DAV Proxy (c) 2007 Matthias L. Jugel");
-
- // set encoding of the JVM and make sure Jetty decodes URIs correctly
- System.setProperty("file.encoding", "UTF-8");
- System.setProperty("org.mortbay.util.URI.charset", "UTF-8");
-
- try {
- Server server = new Server();
- XmlConfiguration xmlConfiguration = new XmlConfiguration(getXmlConfigurationUrl());
- xmlConfiguration.configure(server);
- server.start();
- server.join();
- } catch (Exception e) {
- System.err.println("Can't start server: " + e.getMessage());
- System.exit(1);
- }
- }
-
- private static URL getXmlConfigurationUrl() {
- String configFile = System.getProperty("jetty.xml", CONF_JETTY_XML);
- URL url = MoxoJettyRunner.class.getResource(configFile);
- if (null == url) {
- try {
- url = new File(configFile).toURL();
- System.err.println("Loading configuration from file: " + url.toExternalForm());
- } catch (MalformedURLException e) {
- // ignore ...
- }
- }
- return url;
- }
-}
blob - ee8611fc7310c54462bf8672a9ff9845cbab912a (mode 644)
blob + /dev/null
--- src/main/resources/commons-logging.properties
+++ /dev/null
-#
-# Copyright 2007 Matthias L. Jugel.
-#
-# Licensed 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.
-#
-#org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger
-org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
\ No newline at end of file
blob - 71c406fc4d38c233930be39548d9d3767b2a5d3b (mode 644)
blob + /dev/null
--- src/main/resources/jetty.xml
+++ /dev/null
-<?xml version="1.0"?>
-<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
-
-<!-- =============================================================== -->
-<!-- Configure the Jetty Server -->
-<!-- -->
-<!-- Documentation of this file format can be found at: -->
-<!-- http://docs.codehaus.org/display/JETTY/jetty.xml -->
-<!-- -->
-<!-- =============================================================== -->
-
-
-<Configure id="Server" class="org.mortbay.jetty.Server">
-
- <!-- =========================================================== -->
- <!-- Server Thread Pool -->
- <!-- =========================================================== -->
- <Set name="ThreadPool">
- <!-- Default bounded blocking threadpool
- -->
- <New class="org.mortbay.thread.BoundedThreadPool">
- <Set name="minThreads">10</Set>
- <Set name="lowThreads">50</Set>
- <Set name="maxThreads">250</Set>
- </New>
-
- <!-- Optional Java 5 bounded threadpool with job queue
- <New class="org.mortbay.thread.concurrent.ThreadPool">
- <Arg type="int">0</Arg>
- <Set name="corePoolSize">10</Set>
- <Set name="maximumPoolSize">250</Set>
- </New>
- -->
- </Set>
-
-
- <!-- =========================================================== -->
- <!-- Set connectors -->
- <!-- =========================================================== -->
- <!-- One of each type! -->
- <!-- =========================================================== -->
-
- <!-- Use this connector for many frequently idle connections
- and for threadless continuations.
- -->
- <Call name="addConnector">
- <Arg>
- <New class="org.mortbay.jetty.nio.SelectChannelConnector">
- <Set name="port">
- <SystemProperty name="jetty.port" default="8080"/>
- </Set>
- <Set name="maxIdleTime">30000</Set>
- <Set name="Acceptors">2</Set>
- <Set name="confidentialPort">8443</Set>
- </New>
- </Arg>
- </Call>
-
- <Call name="addConnector">
- <Arg>
- <New class="org.mortbay.jetty.security.SslSocketConnector">
- <Set name="Port">8443</Set>
- <Set name="maxIdleTime">30000</Set>
- <Set name="keystore"><SystemProperty name="user.home" default="."/>/.keystore
- </Set>
- <Set name="password">OBF:1fvu20731x191vul1vup1x1d20731ftg</Set>
- <Set name="keyPassword">OBF:1fvu20731x191vul1vup1x1d20731ftg</Set>
- <Set name="truststore"><SystemProperty name="user.home" default="."/>/.keystore
- </Set>
- <Set name="trustPassword">OBF:1fvu20731x191vul1vup1x1d20731ftg</Set>
- </New>
- </Arg>
- </Call>
-
- <!-- Use this connector if NIO is not available.
- <Call name="addConnector">
- <Arg>
- <New class="org.mortbay.jetty.bio.SocketConnector">
- <Set name="port">8081</Set>
- <Set name="maxIdleTime">50000</Set>
- <Set name="lowResourceMaxIdleTime">1500</Set>
- </New>
- </Arg>
- </Call>
- -->
-
- <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
- <!-- To add a HTTPS SSL listener -->
- <!-- see jetty-ssl.xml to add an ssl connector. use -->
- <!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml -->
- <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
-
- <!-- =========================================================== -->
- <!-- Set up global session ID manager -->
- <!-- =========================================================== -->
- <!--
- <Set name="sessionIdManager">
- <New class="org.mortbay.jetty.servlet.HashSessionIdManager">
- <Set name="workerName">node1</Set>
- </New>
- </Set>
- -->
-
- <!-- =========================================================== -->
- <!-- Set handler Collection Structure -->
- <!-- =========================================================== -->
- <Set name="handler">
- <New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection">
- <Set name="handlers">
- <Array type="org.mortbay.jetty.Handler">
- <Item>
- <New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/>
- </Item>
- <Item>
- <New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/>
- </Item>
- <Item>
- <New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/>
- </Item>
- </Array>
- </Set>
- </New>
- </Set>
-
- <!-- Set the handler for our web dav servlet -->
- <Set name="handler">
- <New id="WebDAVServletContext" class="org.mortbay.jetty.servlet.Context">
- <Set name="contextPath">/</Set>
- <Set name="resourceBase">
- <SystemProperty name="jetty.docroot" default="."/>
- </Set>
- <Call name="addServlet">
- <Arg>com.thinkberg.webdav.servlet.MoxoWebDAVServlet</Arg>
- <Arg>/*</Arg>
- <Call name="setInitParameter">
- <Arg>vfs.uri</Arg>
- <Arg>ram:/</Arg>
- </Call>
- <Call name="setInitParameter">
- <Arg>vfs.auth.domain</Arg>
- <Arg></Arg>
- </Call>
- <Call name="setInitParameter">
- <Arg>vfs.auth.user</Arg>
- <Arg>theuser</Arg>
- </Call>
- <Call name="setInitParameter">
- <Arg>vfs.auth.password</Arg>
- <Arg>thepassword</Arg>
- </Call>
- </Call>
-
- </New>
- </Set>
-
-
- <!-- =========================================================== -->
- <!-- Configure Authentication Realms -->
- <!-- Realms may be configured for the entire server here, or -->
- <!-- they can be configured for a specific web app in a context -->
- <!-- configuration (see $(jetty.home)/contexts/test.xml for an -->
- <!-- example). -->
- <!-- =========================================================== -->
- <Set name="UserRealms">
- <Array type="org.mortbay.jetty.security.UserRealm">
- <!--
- <Item>
- <New class="org.mortbay.jetty.security.HashUserRealm">
- <Set name="name">Test Realm</Set>
- <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
- </New>
- </Item>
- -->
- </Array>
- </Set>
-
- <!-- =========================================================== -->
- <!-- Configure Request Log -->
- <!-- Request logs may be configured for the entire server here, -->
- <!-- or they can be configured for a specific web app in a -->
- <!-- contexts configuration (see $(jetty.home)/contexts/test.xml -->
- <!-- for an example). -->
- <!-- =========================================================== -->
- <Ref id="RequestLog">
- <Set name="requestLog">
- <New id="RequestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
- <Arg>
- <SystemProperty name="jetty.logs" default="./logs"/>
- /yyyy_mm_dd.request.log
- </Arg>
- <Set name="retainDays">90</Set>
- <Set name="append">true</Set>
- <Set name="extended">false</Set>
- <Set name="LogTimeZone">GMT</Set>
- </New>
- </Set>
- </Ref>
-
- <!-- =========================================================== -->
- <!-- extra options -->
- <!-- =========================================================== -->
- <Set name="stopAtShutdown">true</Set>
- <!-- ensure/prevent Server: header being sent to browsers -->
- <Set name="sendServerVersion">true</Set>
-
-</Configure>
blob - 06d0ba45d0947de8c84d470d4bc1a1fd74c4346a (mode 644)
blob + /dev/null
--- src/main/resources/simplelog.properties
+++ /dev/null
-#
-# Copyright 2007 Matthias L. Jugel.
-#
-# Licensed 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.
-#
-
-org.apache.commons.logging.simplelog.defaultlog=error
-org.apache.commons.logging.simplelog.log.com.thinkberg.vfs.s3=info
-org.apache.commons.logging.simplelog.log.com.thinkberg.webdav=info
\ No newline at end of file