Commits

Sam Adams committed 7ec3bdb

added standalone project

  • Participants
  • Parent commits 1f6b876

Comments (0)

Files changed (24)

 
     <modelVersion>4.0.0</modelVersion>
 
-    <groupId>uk.ac.cam.ch.wwmm.quixote</groupId>
-    <artifactId>quixote-repository-aggregator</artifactId>
+    <groupId>uk.ac.cam.ch.wwmm.quixote.repository</groupId>
+    <artifactId>quixote-repository</artifactId>
     <version>0.1-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <name>Quixote Data Repository Aggregator</name>
 
     <modules>
-        <module>quixote-repository</module>
+        <module>quixote-repository-chempound</module>
         <module>quixote-repository-webapp</module>
+        <module>quixote-repository-standalone</module>
     </modules>
 
     <repositories>

quixote-repository-chempound/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">
+
+    <parent>
+        <groupId>uk.ac.cam.ch.wwmm.quixote.repository</groupId>
+        <artifactId>quixote-repository</artifactId>
+        <version>0.1-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>quixote-repository-chempound</artifactId>
+
+    <name>Quixote Data Repository :: Chempound</name>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>net.chempound</groupId>
+            <artifactId>chempound-webapp</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>net.chempound.chemistry</groupId>
+            <artifactId>chemistry-search-structure</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>net.chempound.chemistry</groupId>
+            <artifactId>chemistry-jmol-plugin</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>net.chempound.plugins</groupId>
+            <artifactId>chempound-jquery-plugin</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>net.chempound.crystallography</groupId>
+            <artifactId>crystallography-handler</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>net.chempound.compchem</groupId>
+            <artifactId>compchem-handler</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>[1.6.1]</version>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.5</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.google.inject</groupId>
+            <artifactId>guice</artifactId>
+            <version>3.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.inject.extensions</groupId>
+            <artifactId>guice-servlet</artifactId>
+            <version>3.0</version>
+        </dependency>
+
+    </dependencies>
+
+</project>

quixote-repository-chempound/src/main/java/uk/ac/cam/ch/wwmm/quixote/QuixoteChempoundServletConfig.java

+package uk.ac.cam.ch.wwmm.quixote;
+
+import com.google.inject.AbstractModule;
+import net.chempound.webapp.ChempoundServletConfig;
+
+/**
+ * @author Sam Adams
+ */
+public class QuixoteChempoundServletConfig extends ChempoundServletConfig {
+
+    public QuixoteChempoundServletConfig() {
+        super();
+    }
+
+    protected AbstractModule getPluginsModule() {
+        return new QuixotePluginsModule();
+    }
+
+}

quixote-repository-chempound/src/main/java/uk/ac/cam/ch/wwmm/quixote/QuixotePluginsModule.java

+package uk.ac.cam.ch.wwmm.quixote;
+
+import com.google.inject.AbstractModule;
+import net.chempound.compchem.CompChemModule;
+import net.chempound.crystal.CrystallographyModule;
+import net.chempound.plugins.jmol.JmolModule;
+import net.chempound.plugins.jquery.JQueryModule;
+import net.chempound.webapp.search.chemistry.StructureSearchProviderModule;
+
+/**
+ * @author Sam Adams
+ */
+public class QuixotePluginsModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+        install(new StructureSearchProviderModule());
+        install(new CrystallographyModule());
+        install(new CompChemModule());
+
+        install(new JQueryModule());
+        install(new JmolModule());
+    }
+
+}

quixote-repository-chempound/src/main/java/uk/ac/cam/ch/wwmm/quixote/QuixoteWebappLauncher.java

+package uk.ac.cam.ch.wwmm.quixote;
+
+import com.google.inject.AbstractModule;
+import net.chempound.webapp.ChempoundWebappLauncher;
+
+/**
+ * @author Sam Adams
+ */
+public class QuixoteWebappLauncher extends ChempoundWebappLauncher {
+
+    public static void main(final String[] args) throws Exception {
+        final QuixoteWebappLauncher launcher = new QuixoteWebappLauncher();
+        launcher.start();
+    }
+
+    @Override
+    protected AbstractModule getPluginsModule() {
+        return new QuixotePluginsModule();
+    }
+
+}

quixote-repository-chempound/src/main/resources/log4j.properties

+
+log4j.rootLogger = WARN, A
+
+log4j.appender.A = org.apache.log4j.ConsoleAppender
+log4j.appender.A.layout = org.apache.log4j.PatternLayout
+log4j.appender.A.layout.ConversionPattern = %-4r [%t] %-5p %c %x - %m%n
+log4j.appender.A.target = System.err
+
+log4j.logger.uk.ac.cam.ch.wwmm.chempound = DEBUG
+

quixote-repository-standalone/.hgignore

+
+# maven
+^target/
+/target/
+
+# intellij
+^.idea/
+\.iml$
+
+# eclipse
+^\.classpath$
+/\.classpath$
+^\.project$
+/\.project$
+^\.settings/
+/\.settings/
+
+# temp files
+~$
+\.old$
+^temp/
+/temp/
+^workspace/

quixote-repository-standalone/LICENSE.txt

Empty file added.

quixote-repository-standalone/NOTICE.txt

Empty file added.

quixote-repository-standalone/README.txt

+Launching Quixote/Chempound
+
+The standalone Chempound repository has an embedded Jetty web server.  It can be launched on http://localhost:8181/ by
+running:
+
+ java -jar quixote-webapp-standalone-0.1-SNAPSHOT.war
+
+To use an alternative address/port run:
+
+ java -Dchempound.uri=http://server-name:port/ -jar quixote-webapp-standalone-0.1-SNAPSHOT.war
+

quixote-repository-standalone/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">
+
+    <parent>
+        <groupId>uk.ac.cam.ch.wwmm.quixote.repository</groupId>
+        <artifactId>quixote-repository</artifactId>
+        <version>0.1-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>quixote-repository-standalone</artifactId>
+    <packaging>war</packaging>
+
+    <name>Quixote Data Repository :: Standalone Webapp</name>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>uk.ac.cam.ch.wwmm.quixote.repository</groupId>
+            <artifactId>quixote-repository-webapp</artifactId>
+            <version>0.1-SNAPSHOT</version>
+            <type>war</type>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mortbay.jetty</groupId>
+            <artifactId>jetty</artifactId>
+            <version>6.1.26</version>
+        </dependency>
+
+    </dependencies>
+
+    <repositories>
+        <repository>
+            <id>ucc-repo</id>
+            <url>https://maven.ch.cam.ac.uk/m2repo</url>
+        </repository>
+    </repositories>
+
+
+    <build>
+        <plugins>
+
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>none</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <version>1.4</version>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                        <configuration>
+                            <shadedArtifactAttached>false</shadedArtifactAttached>
+                            <createDependencyReducedPom>true</createDependencyReducedPom>
+                            <transformers>
+                                <transformer
+                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                                    <mainClass>EmbeddedJettyServer</mainClass>
+                                </transformer>
+                            </transformers>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <!-- The main class needs to be in the root of the war in order to be runnable -->
+            <plugin>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>move-main-class</id>
+                        <phase>compile</phase>
+                        <configuration>
+                            <tasks>
+                                <move todir="${project.build.directory}/${project.artifactId}-${project.version}">
+                                    <fileset dir="${project.build.directory}/classes/">
+                                        <include name="EmbeddedJettyServer.class"/>
+                                    </fileset>
+                                </move>
+                            </tasks>
+                        </configuration>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <configuration>
+                    <descriptors>
+                        <descriptor>src/main/assembly/bin-dist.xml</descriptor>
+                    </descriptors>
+                    <appendAssemblyId>false</appendAssemblyId>
+                    <attach>false</attach>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                        <phase>package</phase>
+                    </execution>
+                </executions>
+            </plugin>
+
+        </plugins>
+    </build>
+
+</project>

quixote-repository-standalone/run.bat

+mvn -Dchempound.workspace=target/workspace -Dchempound.uri=http://localhost:8181/ -Djetty.port=8181 compile jetty:run

quixote-repository-standalone/run.sh

+#!/bin/bash
+mvn -Dchempound.workspace=target/workspace -Dchempound.uri=http://localhost:8181/ -Djetty.port=8181 compile jetty:run

quixote-repository-standalone/src/main/assembly/bin-dist.xml

+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+
+    <id>bin-dist</id>
+
+    <formats>
+        <format>tar.gz</format>
+        <format>zip</format>
+    </formats>
+
+    <baseDirectory>quixote-repository-${project.version}</baseDirectory>
+
+    <files>
+        <file>
+            <source>src/main/bin/run.bat</source>
+            <outputDirectory>/</outputDirectory>
+            <filtered>true</filtered>
+            <lineEnding>dos</lineEnding>
+        </file>
+        <file>
+            <source>src/main/bin/run.sh</source>
+            <outputDirectory>/</outputDirectory>
+            <filtered>true</filtered>
+            <lineEnding>unix</lineEnding>
+            <fileMode>0755</fileMode>
+        </file>
+        <file>
+            <source>target/quixote-webapp-standalone-0.1-SNAPSHOT.war</source>
+            <outputDirectory>/</outputDirectory>
+            <destName>quixote-webapp-standalone-0.1-SNAPSHOT.war</destName>
+        </file>
+    </files>
+
+    <fileSets>
+        <fileSet>
+            <includes>
+                <include>README*</include>
+                <include>LICENSE*</include>
+                <include>NOTICE*</include>
+            </includes>
+        </fileSet>
+    </fileSets>
+
+</assembly>

quixote-repository-standalone/src/main/bin/run.bat

+java -jar quixote-webapp-standalone-${project.version}.war

quixote-repository-standalone/src/main/bin/run.sh

+#!/bin/sh
+
+java -jar quixote-webapp-standalone-${project.version}.war

quixote-repository-standalone/src/main/java/EmbeddedJettyServer.java

+/*
+ * Copyright 2012 Sam Adams
+ *
+ * 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.
+ */
+
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.webapp.WebAppContext;
+
+import java.net.URI;
+import java.net.URL;
+import java.security.ProtectionDomain;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Sam Adams
+ */
+public class EmbeddedJettyServer {
+
+    private final Map<String,String> initParams = new HashMap<String, String>();
+    private final WebAppContext webAppContext;
+    private int port;
+
+    private EmbeddedJettyServer() {
+        webAppContext = createWebAppContext();
+    }
+
+    private WebAppContext createWebAppContext() {
+        final ProtectionDomain domain = EmbeddedJettyServer.class.getProtectionDomain();
+        final URL location = domain.getCodeSource().getLocation();
+
+        final WebAppContext webapp = new WebAppContext();
+        webapp.setContextPath("/");
+        webapp.setDescriptor(location.toExternalForm() + "/WEB-INF/web.xml");
+        webapp.setWar(location.toExternalForm());
+
+        return webapp;
+    }
+
+    private void run() throws Exception {
+        checkConfiguration();
+        if (!initParams.isEmpty()) {
+            webAppContext.setInitParams(initParams);
+        }
+
+        final Server server = new Server(port);
+        server.setHandler(webAppContext);
+
+        server.start();
+        server.join();
+    }
+
+    private void checkConfiguration() {
+        checkWorkspace();
+        checkUri();
+    }
+
+    private void checkWorkspace() {
+        if (System.getProperty("chempound.workspace") == null) {
+            initParams.put("chempound.workspace", "./quixote-workspace/");
+        }
+    }
+
+    private void checkUri() {
+        String uri = System.getProperty("chempound.uri");
+        if (uri == null) {
+            initParams.put("chempound.uri", "http://localhost:8181/");
+            port = 8181;
+        } else {
+            URI u = URI.create(uri);
+            port = u.getPort() == -1 ? 80 : u.getPort();
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        final EmbeddedJettyServer server = new EmbeddedJettyServer();
+        server.run();
+    }
+
+}

quixote-repository-standalone/src/main/resources/log4j.properties

+
+log4j.rootLogger = WARN, A
+
+log4j.appender.A = org.apache.log4j.ConsoleAppender
+log4j.appender.A.layout = org.apache.log4j.PatternLayout
+log4j.appender.A.layout.ConversionPattern = %-4r [%t] %-5p %c %x - %m%n
+log4j.appender.A.target = System.err
+
+log4j.logger.uk.ac.cam.ch.wwmm.chempound = DEBUG
+

quixote-repository-webapp/pom.xml

          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
     <parent>
-        <groupId>uk.ac.cam.ch.wwmm.quixote</groupId>
-        <artifactId>quixote-repository-aggregator</artifactId>
+        <groupId>uk.ac.cam.ch.wwmm.quixote.repository</groupId>
+        <artifactId>quixote-repository</artifactId>
         <version>0.1-SNAPSHOT</version>
     </parent>
 
     <dependencies>
 
         <dependency>
-            <groupId>uk.ac.cam.ch.wwmm.quixote</groupId>
-            <artifactId>quixote-repository</artifactId>
+            <groupId>uk.ac.cam.ch.wwmm.quixote.repository</groupId>
+            <artifactId>quixote-repository-chempound</artifactId>
             <version>0.1-SNAPSHOT</version>
         </dependency>
 

quixote-repository/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">
-
-    <parent>
-        <groupId>uk.ac.cam.ch.wwmm.quixote</groupId>
-        <artifactId>quixote-repository-aggregator</artifactId>
-        <version>0.1-SNAPSHOT</version>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>quixote-repository</artifactId>
-
-    <name>Quixote Data Repository</name>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>net.chempound</groupId>
-            <artifactId>chempound-webapp</artifactId>
-            <version>0.1-SNAPSHOT</version>
-        </dependency>
-
-        <dependency>
-            <groupId>net.chempound.chemistry</groupId>
-            <artifactId>chemistry-search-structure</artifactId>
-            <version>0.1-SNAPSHOT</version>
-        </dependency>
-
-        <dependency>
-            <groupId>net.chempound.chemistry</groupId>
-            <artifactId>chemistry-jmol-plugin</artifactId>
-            <version>0.1-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>net.chempound.plugins</groupId>
-            <artifactId>chempound-jquery-plugin</artifactId>
-            <version>0.1-SNAPSHOT</version>
-        </dependency>
-
-        <dependency>
-            <groupId>net.chempound.crystallography</groupId>
-            <artifactId>crystallography-handler</artifactId>
-            <version>0.1-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>net.chempound.compchem</groupId>
-            <artifactId>compchem-handler</artifactId>
-            <version>0.1-SNAPSHOT</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <version>[1.6.1]</version>
-        </dependency>
-
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
-            <version>2.5</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.google.inject</groupId>
-            <artifactId>guice</artifactId>
-            <version>3.0</version>
-        </dependency>
-        <dependency>
-            <groupId>com.google.inject.extensions</groupId>
-            <artifactId>guice-servlet</artifactId>
-            <version>3.0</version>
-        </dependency>
-
-    </dependencies>
-
-</project>

quixote-repository/src/main/java/uk/ac/cam/ch/wwmm/quixote/QuixoteChempoundServletConfig.java

-package uk.ac.cam.ch.wwmm.quixote;
-
-import com.google.inject.AbstractModule;
-import net.chempound.webapp.ChempoundServletConfig;
-
-/**
- * @author Sam Adams
- */
-public class QuixoteChempoundServletConfig extends ChempoundServletConfig {
-
-    public QuixoteChempoundServletConfig() {
-        super();
-    }
-
-    protected AbstractModule getPluginsModule() {
-        return new QuixotePluginsModule();
-    }
-
-}

quixote-repository/src/main/java/uk/ac/cam/ch/wwmm/quixote/QuixotePluginsModule.java

-package uk.ac.cam.ch.wwmm.quixote;
-
-import com.google.inject.AbstractModule;
-import net.chempound.compchem.CompChemModule;
-import net.chempound.crystal.CrystallographyModule;
-import net.chempound.plugins.jmol.JmolModule;
-import net.chempound.plugins.jquery.JQueryModule;
-import net.chempound.webapp.search.chemistry.StructureSearchProviderModule;
-
-/**
- * @author Sam Adams
- */
-public class QuixotePluginsModule extends AbstractModule {
-
-    @Override
-    protected void configure() {
-        install(new StructureSearchProviderModule());
-        install(new CrystallographyModule());
-        install(new CompChemModule());
-
-        install(new JQueryModule());
-        install(new JmolModule());
-    }
-
-}

quixote-repository/src/main/java/uk/ac/cam/ch/wwmm/quixote/QuixoteWebappLauncher.java

-package uk.ac.cam.ch.wwmm.quixote;
-
-import com.google.inject.AbstractModule;
-import net.chempound.webapp.ChempoundWebappLauncher;
-
-/**
- * @author Sam Adams
- */
-public class QuixoteWebappLauncher extends ChempoundWebappLauncher {
-
-    public static void main(final String[] args) throws Exception {
-        final QuixoteWebappLauncher launcher = new QuixoteWebappLauncher();
-        launcher.start();
-    }
-
-    @Override
-    protected AbstractModule getPluginsModule() {
-        return new QuixotePluginsModule();
-    }
-
-}

quixote-repository/src/main/resources/log4j.properties

-
-log4j.rootLogger = WARN, A
-
-log4j.appender.A = org.apache.log4j.ConsoleAppender
-log4j.appender.A.layout = org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern = %-4r [%t] %-5p %c %x - %m%n
-log4j.appender.A.target = System.err
-
-log4j.logger.uk.ac.cam.ch.wwmm.chempound = DEBUG
-