[Tynstep-svn] r129 - trunk/step-server/src/main/java/com/tyndalehouse/step/server

ChrisBurrell at crosswire.org ChrisBurrell at crosswire.org
Tue Apr 20 15:23:49 MST 2010


Author: ChrisBurrell
Date: 2010-04-20 15:23:49 -0700 (Tue, 20 Apr 2010)
New Revision: 129

Modified:
   trunk/step-server/src/main/java/com/tyndalehouse/step/server/StepServer.java
Log:
committing comments to 1.6 code to allow build to work

Modified: trunk/step-server/src/main/java/com/tyndalehouse/step/server/StepServer.java
===================================================================
--- trunk/step-server/src/main/java/com/tyndalehouse/step/server/StepServer.java	2010-04-20 22:05:26 UTC (rev 128)
+++ trunk/step-server/src/main/java/com/tyndalehouse/step/server/StepServer.java	2010-04-20 22:23:49 UTC (rev 129)
@@ -1,161 +1,162 @@
-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();
-		}
-	}
-
-}
+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();			
+			//start the browser - code not available in 1.5 - may need to do something different?
+			//			try {
+//                                   Desktop.getDesktop().browse(new URI("http://localhost:8080"));
+//				} 
+//				catch (MalformedURLException e1) {
+//				   e1.printStackTrace();
+//				} 
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+}




More information about the Tynstep-svn mailing list