[Tynstep-svn] r110 - in trunk: . step-server step-server/.settings step-server/src step-server/src/main step-server/src/main/java step-server/src/main/java/com step-server/src/main/java/com/tyndalehouse step-server/src/main/java/com/tyndalehouse/step step-server/src/main/java/com/tyndalehouse/step/server step-server/src/main/resources

ChrisBurrell at crosswire.org ChrisBurrell at crosswire.org
Wed Apr 14 14:30:21 MST 2010


Author: ChrisBurrell
Date: 2010-04-14 14:30:21 -0700 (Wed, 14 Apr 2010)
New Revision: 110

Added:
   trunk/step-server/
   trunk/step-server/.classpath
   trunk/step-server/.project
   trunk/step-server/.settings/
   trunk/step-server/.settings/org.eclipse.jdt.core.prefs
   trunk/step-server/.settings/org.maven.ide.eclipse.prefs
   trunk/step-server/pom.xml
   trunk/step-server/src/
   trunk/step-server/src/main/
   trunk/step-server/src/main/java/
   trunk/step-server/src/main/java/com/
   trunk/step-server/src/main/java/com/tyndalehouse/
   trunk/step-server/src/main/java/com/tyndalehouse/step/
   trunk/step-server/src/main/java/com/tyndalehouse/step/server/
   trunk/step-server/src/main/java/com/tyndalehouse/step/server/StepServer.java
   trunk/step-server/src/main/resources/
   trunk/step-server/src/main/resources/jetty.xml
   trunk/step-server/src/main/resources/webapps/
Log:
committing step server

Added: trunk/step-server/.classpath
===================================================================
--- trunk/step-server/.classpath	                        (rev 0)
+++ trunk/step-server/.classpath	2010-04-14 21:30:21 UTC (rev 110)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: trunk/step-server/.project
===================================================================
--- trunk/step-server/.project	                        (rev 0)
+++ trunk/step-server/.project	2010-04-14 21:30:21 UTC (rev 110)
@@ -0,0 +1,17 @@
+<projectDescription>
+  <name>step-dataloader</name>
+  <comment/>
+  <projects/>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+    <buildCommand>
+      <name>org.maven.ide.eclipse.maven2Builder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+    <nature>org.maven.ide.eclipse.maven2Nature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: trunk/step-server/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/step-server/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ trunk/step-server/.settings/org.eclipse.jdt.core.prefs	2010-04-14 21:30:21 UTC (rev 110)
@@ -0,0 +1,6 @@
+#Mon Apr 05 13:29:00 BST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.5

Added: trunk/step-server/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- trunk/step-server/.settings/org.maven.ide.eclipse.prefs	                        (rev 0)
+++ trunk/step-server/.settings/org.maven.ide.eclipse.prefs	2010-04-14 21:30:21 UTC (rev 110)
@@ -0,0 +1,9 @@
+#Mon Apr 05 13:28:59 BST 2010
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1

Added: trunk/step-server/pom.xml
===================================================================
--- trunk/step-server/pom.xml	                        (rev 0)
+++ trunk/step-server/pom.xml	2010-04-14 21:30:21 UTC (rev 110)
@@ -0,0 +1,24 @@
+<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/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>com.tyndalehouse</groupId>
+		<artifactId>step-parent</artifactId>
+		<version>1.0-SNAPSHOT</version>
+		<relativePath>..</relativePath>
+	</parent>
+
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>com.tyndalehouse</groupId>
+	<artifactId>step-server</artifactId>
+	<packaging>jar</packaging>
+	<name>step-server</name>
+
+	
+	<dependencies>
+		<dependency>
+			<groupId>org.mortbay.jetty</groupId>
+			<artifactId>jetty</artifactId>
+			<version>6.1.22</version>
+		</dependency>
+	</dependencies>
+</project>

Added: trunk/step-server/src/main/java/com/tyndalehouse/step/server/StepServer.java
===================================================================
--- trunk/step-server/src/main/java/com/tyndalehouse/step/server/StepServer.java	                        (rev 0)
+++ trunk/step-server/src/main/java/com/tyndalehouse/step/server/StepServer.java	2010-04-14 21:30:21 UTC (rev 110)
@@ -0,0 +1,161 @@
+package com.tyndalehouse.step.server;
+
+import java.awt.Desktop;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.DefaultHandler;
+import org.mortbay.jetty.handler.HandlerList;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.mortbay.xml.XmlConfiguration;
+
+
+public class StepServer {
+	
+	StepServer() {
+
+	}
+
+	
+	
+	// creates and configures the Jetty server
+	private Server start() throws Exception {
+		Server jetty = new Server();
+		String[] configFiles = { "jetty.xml" };
+				
+		for (String configFile : configFiles) {
+			
+			XmlConfiguration configuration = new XmlConfiguration(new File(
+					configFile).toURI().toURL());
+			configuration.configure(jetty);
+		}
+
+		// configure our web application
+		WebAppContext appContext = new WebAppContext();
+		appContext.setContextPath("/");
+		File rd = new File("./");
+
+		//This needs to be parameterised
+		String pathToWar = System.getProperty("path.to.war");
+		if(pathToWar == null) {
+			pathToWar = "../../public_html";
+		}
+		
+		File warPath = new File(rd, pathToWar);
+		appContext.setWar(warPath.getAbsolutePath());
+
+		HandlerList handlers = new HandlerList();
+		handlers
+				.setHandlers(new Handler[] { appContext, new DefaultHandler() });
+
+		jetty.setHandler(handlers);
+
+		jetty.start();
+		return jetty;
+	}
+
+	//creates a simple table in the database
+//	private void doDatabase() {
+//		String sql = "CREATE table APP.ADDRESS (    ID          INTEGER NOT NULL                PRIMARY KEY GENERATED ALWAYS AS IDENTITY                (START WITH 1, INCREMENT BY 1),    LASTNAME    VARCHAR(30),    FIRSTNAME   VARCHAR(30),    MIDDLENAME  VARCHAR(30),    PHONE       VARCHAR(20),    EMAIL       VARCHAR(30),    ADDRESS1    VARCHAR(30),    ADDRESS2    VARCHAR(30),    CITY        VARCHAR(30),    STATE       VARCHAR(30),    POSTALCODE  VARCHAR(20),    COUNTRY     VARCHAR(30) )";
+//		
+//		try {
+//			Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+//		} catch (ClassNotFoundException e) {
+//			// TODO Auto-generated catch block
+//			e.printStackTrace();
+//		}
+//
+//		Connection dbConnection = null;
+//		String strUrl = "jdbc:derby:DefaultAddressBook;create=true";
+//
+//		try {
+//		    dbConnection = DriverManager.getConnection(strUrl);
+//		} catch (SQLException ex) {
+//		    ex.printStackTrace();
+//		}
+//
+//	    Statement statement = null;
+//	    try {
+//	        statement = dbConnection.createStatement();
+//	        statement.execute(sql);
+//	    } catch (SQLException ex) {
+//	        ex.printStackTrace();
+//	    }
+//	    
+//	    System.out.println("Terminated OK");
+//	    System.exit(0);
+//	}
+
+//	private void checkJSwordInstalled() {
+//        // An installer knows how to install books
+//        Installer installer = getNewCustomInstaller();
+//
+//        
+//        // Get a list of all the available books (ESV, KJV, etc.)
+//        //List availableBooks = installer.getBooks();
+//
+//        // get some available books. In this case, just one book.
+//        List availableBooks = installer.getBooks(new MyBookFilter("ESV")); //$NON-NLS-1$
+//        Book book = null;
+//        if (availableBooks.size() != 0) {
+//        	book = (Book) availableBooks.get(0);
+//        }
+//
+//        //check the book above is available
+//        if (book != null)
+//        {
+//        	//if we have it, log it as an INFO message
+//        	//TODO: if we have it, log as INFO message
+//            System.out.println("Book " + book.getInitials() + " is available"); //$NON-NLS-1$ //$NON-NLS-2$
+//
+//            try
+//            {
+//            	//now check whether it needs installing...
+//                // Now install it. Note this is a background task.
+//            	//TODO: add logging here too.
+//            	if (Books.installed().getBook("ESV") == null) {
+//            		installer.install(book);
+//            		System.out.println("Installing ESV book");
+//            	}
+//            }
+//            catch (InstallException e)
+//            {
+//                e.printStackTrace();
+//            }
+//        }		
+//	}
+//
+//	private HttpSwordInstaller  getNewCustomInstaller() {
+//		HttpSwordInstaller chrisInstaller = new HttpSwordInstaller();
+//        chrisInstaller.setHost("www.crosswire.org");
+//        //chrisInstaller.setProxyHost("xxx.xxx.xxx.xxx");
+//        //chrisInstaller.setProxyPort(new Integer(xxxx));
+//        chrisInstaller.setPackageDirectory("/ftpmirror/pub/sword/packages/rawzip");
+//        chrisInstaller.setCatalogDirectory("/ftpmirror/pub/sword/raw");
+//        return chrisInstaller;
+//	}
+//
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		try {
+			//doDatabase();
+			StepServer ms = new StepServer();			
+			/* Server s = */ ms.start();			
+			try {
+				   Desktop.getDesktop().browse(new URI("http://localhost:8080"));
+				} 
+				catch (MalformedURLException e1) {
+				   e1.printStackTrace();
+				} 
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+}

Added: trunk/step-server/src/main/resources/jetty.xml
===================================================================
--- trunk/step-server/src/main/resources/jetty.xml	                        (rev 0)
+++ trunk/step-server/src/main/resources/jetty.xml	2010-04-14 21:30:21 UTC (rev 110)
@@ -0,0 +1,204 @@
+<?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="maxThreads">250</Set>
+      </New>
+
+      <!-- Optional Java 5 bounded threadpool with job queue 
+      <New class="org.mortbay.thread.concurrent.ThreadPool">
+        <Set name="corePoolSize">250</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">1</Set>
+            <Set name="statsOn">false</Set>
+            <Set name="confidentialPort">8443</Set>
+	    <Set name="lowResourcesConnections">1000</Set>
+	    <Set name="lowResourcesMaxIdleTime">500</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>
+    
+    <!-- =========================================================== -->
+    <!-- Configure the context deployer                              -->
+    <!-- A context deployer will deploy contexts described in        -->
+    <!-- configuration files discovered in a directory.              -->
+    <!-- The configuration directory can be scanned for hot          -->
+    <!-- deployments at the configured scanInterval.                 -->
+    <!--                                                             -->
+    <!-- This deployer is configured to deploy contexts configured   -->
+    <!-- in the $JETTY_HOME/contexts directory                       -->
+    <!--                                                             -->
+    <!-- =========================================================== -->
+    <Call name="addLifeCycle">
+      <Arg>
+        <New class="org.mortbay.jetty.deployer.ContextDeployer">
+          <Set name="contexts"><Ref id="Contexts"/></Set>
+          <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contexts</Set>
+          <Set name="scanInterval">1</Set>
+        </New>
+      </Arg>
+    </Call>
+
+    <!-- =========================================================== -->
+    <!-- Configure the webapp deployer.                              -->
+    <!-- A webapp  deployer will deploy standard webapps discovered  -->
+    <!-- in a directory at startup, without the need for additional  -->
+    <!-- configuration files.    It does not support hot deploy or   -->
+    <!-- non standard contexts (see ContextDeployer above).          -->
+    <!--                                                             -->
+    <!-- This deployer is configured to deploy webapps from the      -->
+    <!-- $JETTY_HOME/webapps directory                               -->
+    <!--                                                             -->
+    <!-- Normally only one type of deployer need be used.            -->
+    <!--                                                             -->
+    <!-- =========================================================== -->
+    <Call name="addLifeCycle">
+      <Arg>
+        <New class="org.mortbay.jetty.deployer.WebAppDeployer">
+          <Set name="contexts"><Ref id="Contexts"/></Set>
+          <Set name="webAppDir"><SystemProperty name="jetty.home" default="."/>/webapps</Set>
+	  <Set name="parentLoaderPriority">false</Set>
+	  <Set name="extract">true</Set>
+	  <Set name="allowDuplicates">false</Set>
+          <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
+        </New>
+      </Arg>
+    </Call>
+
+    <!-- =========================================================== -->
+    <!-- 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>




More information about the Tynstep-svn mailing list