forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r111764 - in forrest/trunk/tools/eclipse: . src/org/apache/forrest src/org/apache/forrest/eclipse src/org/apache/forrest/eclipse/job src/org/apache/forrest/eclipse/popup/actions
Date Mon, 13 Dec 2004 23:35:48 GMT
Author: rgardler
Date: Mon Dec 13 15:35:48 2004
New Revision: 111764

URL: http://svn.apache.org/viewcvs?view=rev&rev=111764
Log:
refactoring to allow more controllable execution of Forrest
Added:
   forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/
   forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestBuilder.java   (contents,
props changed)
   forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestJob.java   (contents,
props changed)
   forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestManager.java   (contents,
props changed)
   forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestRunner.java
   forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestStopper.java   (contents,
props changed)
Removed:
   forrest/trunk/tools/eclipse/src/org/apache/forrest/ForrestRunner.java
Modified:
   forrest/trunk/tools/eclipse/.classpath
   forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/ForrestPlugin.java
   forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/BuildSite.java
   forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StartForrest.java
   forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StopForrest.java

Modified: forrest/trunk/tools/eclipse/.classpath
Url: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/.classpath?view=diff&rev=111764&p1=forrest/trunk/tools/eclipse/.classpath&r1=111763&p2=forrest/trunk/tools/eclipse/.classpath&r2=111764
==============================================================================
--- forrest/trunk/tools/eclipse/.classpath	(original)
+++ forrest/trunk/tools/eclipse/.classpath	Mon Dec 13 15:35:48 2004
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src/"/>
-	<classpathentry exported="true" kind="lib" path="lib/ant-apache-log4j.jar"/>
 	<classpathentry exported="true" kind="lib" path="lib/log4j-1.2.9.jar"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

Deleted: /forrest/trunk/tools/eclipse/src/org/apache/forrest/ForrestRunner.java
Url: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/src/org/apache/forrest/ForrestRunner.java?view=auto&rev=111763
==============================================================================

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&rev=111764&p1=forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/ForrestPlugin.java&r1=111763&p2=forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/ForrestPlugin.java&r2=111764
==============================================================================
--- forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/ForrestPlugin.java	(original)
+++ forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/ForrestPlugin.java	Mon Dec
13 15:35:48 2004
@@ -30,6 +30,7 @@
  * The main plugin class to be used in the desktop.
  */
 public class ForrestPlugin extends AbstractUIPlugin {
+	public final static String ID = "org.apache.forrest.eclipse";
 	//The shared instance.
 	private static ForrestPlugin plugin;
 

Added: forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestBuilder.java
Url: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestBuilder.java?view=auto&rev=111764
==============================================================================
--- (empty file)
+++ forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestBuilder.java	Mon
Dec 13 15:35:48 2004
@@ -0,0 +1,66 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.forrest.eclipse.job;
+
+import java.io.File;
+
+import org.apache.forrest.eclipse.ForrestPlugin;
+import org.apache.forrest.eclipse.preference.ForrestPreferences;
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+
+/**
+ * Run a version of FOrrest
+ */
+public class ForrestBuilder extends ForrestJob  {
+	/**
+	 * Logger for this class
+	 */
+	protected static final Logger logger = Logger.getLogger(ForrestBuilder.class);
+	
+	/**
+	 * Create a Forrest runner that will run a JEtty server on a given directory
+	 * @param workingDir - the working directory for the command
+	 */
+	protected ForrestBuilder(String workingDir) {
+		super("Forrest Runner");
+		
+		this.workingDir = workingDir;
+	}
+	
+	/* (non-Javadoc)
+	 * @see java.lang.Runnable#run()
+	 */
+	public IStatus run(IProgressMonitor monitor) {
+		if (logger.isDebugEnabled()) {
+			logger.debug("run(IProgressMonitor) - start");
+		}
+		
+		IStatus status = null;
+		String fhome = ForrestPlugin.getDefault().getPluginPreferences()
+		  .getString(ForrestPreferences.FORREST_HOME);
+		StringBuffer sb = new StringBuffer("-Dproject.home=");
+		sb.append(workingDir);
+		sb.append(" -Dbasedir=");
+		sb.append(fhome + File.separatorChar + "main");
+		sb.append(" site");
+        status = runAnt(monitor, sb.toString());
+		return status;
+	}
+	
+}
\ No newline at end of file

Added: forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestJob.java
Url: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestJob.java?view=auto&rev=111764
==============================================================================
--- (empty file)
+++ forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestJob.java	Mon Dec
13 15:35:48 2004
@@ -0,0 +1,85 @@
+/*
+ * Created on 13-Dec-2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.forrest.eclipse.job;
+
+import java.io.File;
+import java.net.URL;
+
+import org.apache.forrest.eclipse.ForrestPlugin;
+import org.apache.forrest.eclipse.preference.ForrestPreferences;
+import org.apache.log4j.Logger;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.eclipse.ant.core.AntRunner;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+
+/**
+ * @author Ross Gardler
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public abstract class ForrestJob extends Job {
+	/**
+	 * Logger for this class
+	 */
+	protected static final Logger logger = Logger.getLogger(ForrestJob.class);
+
+	public static final int EXCEPTION_UNIDENTIFIED = 1001;
+
+	/**
+	 * @param name
+	 */
+	public ForrestJob(String name) {
+		super(name);
+		
+		ForrestPlugin plugin = ForrestPlugin.getDefault();
+		URL urlPluginDir = plugin.getBundle().getEntry("/");
+		String strLog4jConf = "D:\\projects\\burrokeet\\forrestplugin\\conf\\log4j.xml";
+		DOMConfigurator.configure(strLog4jConf);
+	}
+
+	protected String workingDir;
+
+	/**
+	 * @param monitor
+	 * @param cmdString
+	 * @return
+	 */
+	protected IStatus runAnt(IProgressMonitor monitor, String cmdString) {
+		if (logger.isDebugEnabled()) {
+			logger.debug("runAnt(IProgressMonitor, String) - start");
+		}
+	
+		IStatus status = Status.OK_STATUS;
+		
+		if (cmdString != null) {
+			String fhome = ForrestPlugin.getDefault().getPluginPreferences()
+			  .getString(ForrestPreferences.FORREST_HOME);
+			AntRunner runner = new AntRunner();
+			String antFile = fhome + File.separatorChar + "main" + File.separatorChar + "forrest.build.xml";
+			try {
+				runner.setBuildFileLocation(antFile);
+				runner.setArguments(cmdString);
+				logger.info("Running ANT with command string = " + cmdString);
+				runner.run(monitor);
+			} catch (CoreException e) {
+				logger.error("run(IProgressMonitor)", e);
+				status = new Status(Status.ERROR, null, ForrestRunner.EXCEPTION_UNIDENTIFIED, "Forrest
Server Exception", null);
+			}
+		}
+	
+		if (logger.isDebugEnabled()) {
+			logger.debug("runAnt(IProgressMonitor, String) - end");
+		}
+		return status;
+	}
+
+}

Added: 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=auto&rev=111764
==============================================================================
--- (empty file)
+++ forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestManager.java	Mon
Dec 13 15:35:48 2004
@@ -0,0 +1,74 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.forrest.eclipse.job;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.jobs.Job;
+
+/**
+ * Manages instances of Forrest that are running on the local server.
+ */
+public class ForrestManager {
+	/**
+	 * Logger for this class
+	 */
+	private static final Logger logger = Logger.getLogger(ForrestManager.class);
+
+	public static final String COMMAND_BUILD = "site";
+	public static final String COMMAND_START = "run";
+	public static final String COMMAND_STOP = "stop";
+	
+	private static final int UNKOWN_COMMAND = 0;
+	private static final int BUILD = 1;
+	private static final int START = 2;
+	private static final int STOP = 3;
+	
+	private static final ForrestManager INSTANCE = new ForrestManager();
+	
+	/**
+	 * Create a manager, this is not intended to be called from your code.
+	 * Use Manager.getInstance() instead. 
+	 */
+	private ForrestManager() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+	
+	public static ForrestManager getInstance() {
+		return ForrestManager.INSTANCE;
+	}
+	
+	/**
+	 * Create a Forrest Job. 
+	 * @param workingDir - the directory on which the job is to work
+	 * @param cmd - the command the job is to carry out
+	 * @return
+	 */
+	public Job getForrestJob(String workingDir, String cmd) {
+		Job theJob;
+		if (cmd.equals(COMMAND_STOP)) {
+			theJob = new ForrestStopper(workingDir);
+		} else if (cmd.equals(COMMAND_START)){
+			theJob = new ForrestRunner(workingDir);
+		} else if (cmd.equals(COMMAND_BUILD)) {
+			theJob = new ForrestBuilder(workingDir);
+		} else {
+			theJob = null;
+		}
+		return theJob;
+	}
+
+}

Added: 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=auto&rev=111764
==============================================================================
--- (empty file)
+++ forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestRunner.java	Mon
Dec 13 15:35:48 2004
@@ -0,0 +1,74 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.forrest.eclipse.job;
+
+import java.io.File;
+
+import org.apache.forrest.eclipse.ForrestPlugin;
+import org.apache.forrest.eclipse.preference.ForrestPreferences;
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+
+/**
+ * Run a version of FOrrest
+ */
+public class ForrestRunner extends ForrestJob  {
+	/**
+	 * Logger for this class
+	 */
+	protected static final Logger logger = Logger.getLogger(ForrestRunner.class);
+	
+	private static final int EXCEPTION_UNABLE_TO_START = 2010;
+	private static final int EXCEPTION_UNABLE_TO_STOP = 2020;
+	
+	/**
+	 * Create a Forrest runner that will run a JEtty server on a given directory
+	 * @param workingDir - the working directory for the command
+	 */
+	protected ForrestRunner(String workingDir) {
+		super("Forrest Runner");
+		
+		this.workingDir = workingDir;
+	}
+	
+	/* (non-Javadoc)
+	 * @see java.lang.Runnable#run()
+	 */
+	public IStatus run(IProgressMonitor monitor) {
+		if (logger.isDebugEnabled()) {
+			logger.debug("run(IProgressMonitor) - start");
+		}
+		
+		IStatus status = null;
+		String fhome = ForrestPlugin.getDefault().getPluginPreferences()
+		  .getString(ForrestPreferences.FORREST_HOME);
+		StringBuffer sb = new StringBuffer("-Dproject.home=");
+		sb.append(workingDir);
+		sb.append(" -Dbasedir=");
+		sb.append(fhome + File.separatorChar + "main");
+		sb.append(" ");
+		sb.append("run");
+		
+		status = runAnt(monitor, sb.toString());    
+		
+		if (logger.isDebugEnabled()) {
+			logger.debug("run(IProgressMonitor) - end");
+		}
+		return status;
+	}
+}
\ No newline at end of file

Added: forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestStopper.java
Url: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestStopper.java?view=auto&rev=111764
==============================================================================
--- (empty file)
+++ forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/job/ForrestStopper.java	Mon
Dec 13 15:35:48 2004
@@ -0,0 +1,60 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.forrest.eclipse.job;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+
+/**
+ * Run a version of FOrrest
+ */
+public class ForrestStopper extends ForrestJob  {
+	/**
+	 * Logger for this class
+	 */
+	protected static final Logger logger = Logger.getLogger(ForrestStopper.class);
+	
+	/**
+	 * Create a Forrest runner that will run a JEtty server on a given directory
+	 * @param workingDir - the working directory for the command
+	 */
+	protected ForrestStopper(String workingDir) {
+		super("Forrest Runner");
+		
+		this.workingDir = workingDir;
+	}
+	
+	/* (non-Javadoc)
+	 * @see java.lang.Runnable#run()
+	 */
+	public IStatus run(IProgressMonitor monitor) {
+		if (logger.isDebugEnabled()) {
+			logger.debug("run(IProgressMonitor) - start");
+		}
+		
+		IStatus status = null;
+
+		logger.warn("run() - Forrest server not stopped", null);
+	
+		if (logger.isDebugEnabled()) {
+			logger.debug("run(IProgressMonitor) - end");
+		}
+		return status;
+	}
+	
+}
\ No newline at end of file

Modified: forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/BuildSite.java
Url: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/BuildSite.java?view=diff&rev=111764&p1=forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/BuildSite.java&r1=111763&p2=forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/BuildSite.java&r2=111764
==============================================================================
--- forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/BuildSite.java
(original)
+++ forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/BuildSite.java
Mon Dec 13 15:35:48 2004
@@ -15,8 +15,8 @@
  */
 package org.apache.forrest.eclipse.popup.actions;
 
-import org.apache.forrest.ForrestRunner;
 import org.apache.forrest.eclipse.ForrestPlugin;
+import org.apache.forrest.eclipse.job.ForrestManager;
 import org.apache.forrest.eclipse.preference.ForrestPreferences;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -80,7 +80,7 @@
 
 		IPath workingDirectory = activeProject.getLocation();
 		
-		Job forrest = new ForrestRunner(workingDirectory.toOSString(), "site");
+		Job forrest = ForrestManager.getInstance().getForrestJob(workingDirectory.toOSString(),
ForrestManager.COMMAND_BUILD);
 		forrest.setUser(true);
 		forrest.schedule();
 	}

Modified: forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StartForrest.java
Url: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StartForrest.java?view=diff&rev=111764&p1=forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StartForrest.java&r1=111763&p2=forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StartForrest.java&r2=111764
==============================================================================
--- forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StartForrest.java
(original)
+++ forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StartForrest.java
Mon Dec 13 15:35:48 2004
@@ -15,8 +15,8 @@
  */
 package org.apache.forrest.eclipse.popup.actions;
 
-import org.apache.forrest.ForrestRunner;
 import org.apache.forrest.eclipse.ForrestPlugin;
+import org.apache.forrest.eclipse.job.ForrestManager;
 import org.apache.forrest.eclipse.preference.ForrestPreferences;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -86,7 +86,7 @@
 			return;
 		}
 		
-		Job forrest = new ForrestRunner(workingDirectory.toOSString(), ForrestRunner.COMMAND_START);
+		Job forrest = ForrestManager.getInstance().getForrestJob(workingDirectory.toOSString(),
ForrestManager.COMMAND_START);
 		forrest.setUser(true);
 		forrest.schedule();
 	}

Modified: forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StopForrest.java
Url: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StopForrest.java?view=diff&rev=111764&p1=forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StopForrest.java&r1=111763&p2=forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StopForrest.java&r2=111764
==============================================================================
--- forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StopForrest.java
(original)
+++ forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/popup/actions/StopForrest.java
Mon Dec 13 15:35:48 2004
@@ -15,7 +15,7 @@
  */
 package org.apache.forrest.eclipse.popup.actions;
 
-import org.apache.forrest.ForrestRunner;
+import org.apache.forrest.eclipse.job.ForrestManager;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.jobs.Job;
@@ -49,7 +49,7 @@
 	 */
 	public void run(IAction action) {
 		IPath workingDirectory = activeProject.getLocation();
-		Job forrest = new ForrestRunner(workingDirectory.toOSString(), ForrestRunner.COMMAND_STOP);
+		Job forrest = ForrestManager.getInstance().getForrestJob(workingDirectory.toOSString(),
ForrestManager.COMMAND_STOP);
 		forrest.setUser(true);
 		forrest.schedule();
 	}

Mime
View raw message