forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r158980 - in forrest/trunk/tools/eclipse: .classpath lib/jetty-4.2.19.jar lib/servlet-2.3.jar lib/servlet-2.3.jar.license.txt plugin.xml src/org/apache/forrest/eclipse/ForrestPlugin.java src/org/apache/forrest/eclipse/job/ForrestManager.java src/org/apache/forrest/eclipse/job/ForrestRunner.java
Date Fri, 25 Mar 2005 02:02:44 GMT
Author: rgardler
Date: Thu Mar 24 18:02:42 2005
New Revision: 158980

URL: http://svn.apache.org/viewcvs?view=rev&rev=158980
Log:
-allow FORREST_HOME to be set by another plugin (some plugins need a specific version of Forrest)\n-pass
forrest.plugins property value to servlet startup -separated jetty server starting into a
separate class (first phae of allowing support of different servlet engines)

Removed:
    forrest/trunk/tools/eclipse/lib/jetty-4.2.19.jar
    forrest/trunk/tools/eclipse/lib/servlet-2.3.jar
    forrest/trunk/tools/eclipse/lib/servlet-2.3.jar.license.txt
Modified:
    forrest/trunk/tools/eclipse/.classpath
    forrest/trunk/tools/eclipse/plugin.xml
    forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/ForrestPlugin.java
    forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestManager.java
    forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestRunner.java

Modified: forrest/trunk/tools/eclipse/.classpath
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/.classpath?view=diff&r1=158979&r2=158980
==============================================================================
--- forrest/trunk/tools/eclipse/.classpath (original)
+++ forrest/trunk/tools/eclipse/.classpath Thu Mar 24 18:02:42 2005
@@ -2,9 +2,7 @@
 <classpath>
 	<classpathentry kind="src" path="src"/>
 	<classpathentry exported="true" kind="lib" path="lib/log4j-1.2.9.jar"/>
-	<classpathentry exported="true" kind="lib" path="lib/jetty-4.2.19.jar"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="lib" path="lib/servlet-2.3.jar"/>
 	<classpathentry kind="output" path="build"/>
 </classpath>

Modified: forrest/trunk/tools/eclipse/plugin.xml
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugin.xml?view=diff&r1=158979&r2=158980
==============================================================================
--- forrest/trunk/tools/eclipse/plugin.xml (original)
+++ forrest/trunk/tools/eclipse/plugin.xml Thu Mar 24 18:02:42 2005
@@ -30,12 +30,6 @@
       <library name="lib/log4j-1.2.9.jar">
          <export name="*"/>
       </library>
-      <library name="lib/jetty-4.2.19.jar">
-         <export name="*"/>
-      </library>
-      <library name="lib/servlet-2.3.jar">
-         <export name="*"/>
-      </library>
    </runtime>
    <requires>
       <import plugin="org.apache.ant"/>
@@ -50,6 +44,7 @@
       <import plugin="org.eclipse.ui.ide"/>
       <import plugin="org.eclipse.webbrowser"/>
       <import plugin="org.eclipse.debug.ui"/>
+      <import plugin="org.burrokeet.servletEngine"/>
    </requires>
 
 

Modified: forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/ForrestPlugin.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/ForrestPlugin.java?view=diff&r1=158979&r2=158980
==============================================================================
--- forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/ForrestPlugin.java (original)
+++ forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/ForrestPlugin.java Thu Mar
24 18:02:42 2005
@@ -86,13 +86,14 @@
 	public ResourceBundle getResourceBundle() {
 		return resourceBundle;
 	}
+	
 	/* (non-Javadoc)
 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeDefaultPreferences(org.eclipse.jface.preference.IPreferenceStore)
 	 */
 	protected void initializeDefaultPreferences(IPreferenceStore store) {
 		super.initializeDefaultPreferences(store);
 		
-		HashMap envVariables = new HashMap();
+	   HashMap envVariables = new HashMap();
 	   BufferedReader reader = null;
 
 	   //"env" works on Linux & Unix Variants but if we're on Windows,
@@ -130,5 +131,13 @@
 		if (envVariables.containsKey(ForrestPreferences.FORREST_HOME)) {
 			store.setDefault(ForrestPreferences.FORREST_HOME, (String)envVariables.get(ForrestPreferences.FORREST_HOME));
 		}
+	}
+	/**
+	 * Set the preference value for Forrest Home.
+	 * @param forrestHome
+	 */
+	public void setForrestHome(String forrestHome) {
+		IPreferenceStore store = getPreferenceStore();
+		store.setDefault(ForrestPreferences.FORREST_HOME, forrestHome);
 	}
 }

Modified: forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestManager.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestManager.java?view=diff&r1=158979&r2=158980
==============================================================================
--- forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestManager.java (original)
+++ forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestManager.java Thu
Mar 24 18:02:42 2005
@@ -61,7 +61,7 @@
 	private static final ForrestManager INSTANCE = new ForrestManager();
 
 	// FIXME: dir configuration should be in preferences and should be set by
-	// reading forrest.properties
+	// reading forrest.properties and forrest.build.xml (where some defaults are set)
 
 	public static final String FORREST_HOME = ForrestPlugin.getDefault()
 			.getPluginPreferences().getString(ForrestPreferences.FORREST_HOME);
@@ -98,6 +98,9 @@
 	
 	public static final String FORREST_ANTTASK_CLASSES = FORREST_HOME
 			+ File.separator + "tools" + File.separator + "anttasks" + File.separator;
+	
+	public static final String FORREST_PLUGINS = FORREST_HOME
+			+ File.separator + "build" + File.separator + "plugins" + File.separator;
 
 	private static final String FORREST_DEFAULT_PROPERTIES_FILE = FORREST_CORE_WEBAPP
 	+ File.separatorChar + "default-forrest.properties";
@@ -136,6 +139,9 @@
 		props.setSrcFile(new File(FORREST_DEFAULT_PROPERTIES_FILE));
 		props.execute();
 		
+		project.setProperty("forrest.home", FORREST_HOME);
+		project.setProperty("forrest.plugins", FORREST_PLUGINS);
+		
 		return project.getProperties();
 	}
 	
@@ -187,8 +193,6 @@
 			vctFiles.addAll(getLibFiles(FORREST_ENDORSED_LIB));
 			//			 add optional libs
 			vctFiles.addAll(getLibFiles(FORREST_OPTIONAL_LIB));
-			//			 add jetty libs
-			vctFiles.addAll(getLibFiles(JETTY_LIB));
 		} catch (FileNotFoundException e) {
 			logger.error("getClasspathFiles()", e);
 

Modified: forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestRunner.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestRunner.java?view=diff&r1=158979&r2=158980
==============================================================================
--- forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestRunner.java (original)
+++ forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestRunner.java Thu
Mar 24 18:02:42 2005
@@ -20,28 +20,16 @@
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
 
 import org.apache.forrest.eclipse.ForrestPlugin;
 import org.apache.forrest.eclipse.preference.ForrestPreferences;
 import org.apache.log4j.Logger;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
+import org.burrokeet.servletEngine.Jetty;
+import org.burrokeet.servletEngine.Server;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.JavaRuntime;
 import org.eclipse.webbrowser.WebBrowser;
 import org.eclipse.webbrowser.WebBrowserEditorInput;
 
@@ -59,12 +47,10 @@
 	
 	private String workingDir;
 
-	private static final int CORE_EXCEPTION = 100;
+	private static final int BROWSER_ERROR = 200;
 
-	private static final int IO_EXCEPTION = 101;
+	private static final int IO_EXCEPTION = 300;
 
-	private static final int BROWSER_ERROR = 200;
-	
 	/**
 	 * Create a Forrest runner that will run a Jetty server on a given directory
 	 * @param workingDir - the working directory for the command
@@ -98,86 +84,28 @@
 			
 		monitor.subTask("Starting Server");
 		if(status.isOK()) {
-			ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
-			ILaunchConfigurationType type =
-			      manager.getLaunchConfigurationType(ID_JAVA_APPLICATION);
-			ILaunchConfiguration[] configurations;
-			ILaunchConfigurationWorkingCopy workingCopy;
+			ForrestManager forrestManager = ForrestManager.getInstance();
+			String confPath = ForrestManager.FORREST_CORE_WEBAPP + File.separatorChar + "jettyconf.xml";
 			try {
-				configurations = manager.getLaunchConfigurations(type);
-				for (int i = 0; i < configurations.length; i++) {
-			      ILaunchConfiguration configuration = configurations[i];
-			      if (configuration.getName().equals("Start Jetty")) {
-			         configuration.delete();
-			         break;
-			      }
-			   }
-			   workingCopy = type.newInstance(null, "Start Jetty");
-			   workingCopy.setAttribute(ATTR_MAIN_TYPE_NAME,
-	              "org.mortbay.jetty.Server");
-			   // TODO: allow project specific jettyconf.xml
-			   String args = ForrestManager.FORREST_CORE_WEBAPP + File.separatorChar + "jettyconf.xml";
-			   workingCopy.setAttribute(ATTR_PROGRAM_ARGUMENTS, args);
-			   
-			   List classpath = new ArrayList();
-			   
-			   File[] files = ForrestManager.getClasspathFiles();
-			   IPath classpathEntryPath;
-			   IRuntimeClasspathEntry classpathEntry;
-			   for (int i = 0; i < files.length; i++) {
-				   classpathEntryPath = new Path(files[i].getAbsolutePath());
-				   classpathEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(classpathEntryPath);
-				   classpathEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
-				   classpath.add(classpathEntry.getMemento());
-			   }
-			   
-			   IPath systemLibsPath = new Path(JavaRuntime.JRE_CONTAINER);
-			   IRuntimeClasspathEntry systemLibsEntry =
-			      JavaRuntime.newRuntimeContainerClasspathEntry(systemLibsPath,
-			         IRuntimeClasspathEntry.STANDARD_CLASSES);
-			   classpath.add(systemLibsEntry.getMemento());
-			   
-			   workingCopy.setAttribute(ATTR_CLASSPATH, classpath);
-			   workingCopy.setAttribute(ATTR_DEFAULT_CLASSPATH, false);
-			   
-			   ForrestManager forrestManager = ForrestManager.getInstance();
-			   Hashtable props = forrestManager.getProperties(workingDir);
-			   
-			   String propName;
-			   String propValue;
-			   StringBuffer sbVars = new StringBuffer();
-			   for (Enumeration e = props.keys() ; e.hasMoreElements() ;) {
-		         propName = (String)e.nextElement();
-		         propValue = (String)props.get(propName);
-			   	 sbVars.append("-D");
-			   	 sbVars.append(propName);
-			   	 sbVars.append("=");
-			   	 sbVars.append(propValue);
-			   	 sbVars.append(" ");
-		         if (logger.isInfoEnabled()) {
-					logger.info("Project property  : " + propName + " = " + propValue);
-				 } 
-		       }
-			   
-			   String strEndorsedLibs = "-Djava.endorsed.dirs=\"" + ForrestManager.FORREST_ENDORSED_LIB
+ "\"";
-			   workingCopy.setAttribute(ATTR_VM_ARGUMENTS,
-			        sbVars.toString() + strEndorsedLibs);
-			   
-			   workingCopy.setAttribute(ATTR_WORKING_DIRECTORY, ForrestManager.FORREST_CORE_WEBAPP);
-			   
-			   ILaunchConfiguration jettyConfig = workingCopy.doSave();
-			   //DebugUITools.launch(configuration, ILaunchManager.RUN_MODE);
-			   ForrestManager.setServerLaunch( jettyConfig.launch(ILaunchManager.RUN_MODE, monitor));
-			} catch (CoreException e) {
-				logger.error("run(IProgressMonitor)", e);
-				return new Status(Status.ERROR, ForrestPlugin.ID, CORE_EXCEPTION, "Unable to start Jetty
server", e);
+				Server jetty = new Jetty(confPath, 
+					  			  ForrestManager.FORREST_CORE_WEBAPP, 
+								  ForrestManager.FORREST_ENDORSED_LIB,
+								  forrestManager.getProperties(workingDir),
+								  ForrestManager.getClasspathFiles());
+				status = jetty.start(monitor);
+				if (status.isOK()) {
+					ForrestManager.setServerLaunch(jetty.getLaunch());
+				} else {
+					ForrestManager.setServerLaunch(null);
+				}
 			} catch (IOException e) {
 				logger.error("run(IProgressMonitor)", e);
-				return new Status(Status.ERROR,ForrestPlugin.ID, IO_EXCEPTION, "Unable to start Jetty
server", e);
+				status = new Status(Status.ERROR,ForrestPlugin.ID, IO_EXCEPTION, "Unable to start Jetty
server", e);
 			}
 		}
 		
-		if ( ! openBrowser(monitor)) {
+		// FIXME: only open the browser once JETTY has fully started
+		if ( status.isOK() & ! openBrowser(monitor)) {
 			status = new Status(Status.WARNING, ForrestPlugin.ID, BROWSER_ERROR, "Unable to open browser",
null);
 		}
 		



Mime
View raw message