KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > forrest > eclipse > job > ForrestStopper


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation or its licensors,
3  * as applicable.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.forrest.eclipse.job;
18
19 import org.apache.forrest.eclipse.ForrestPlugin;
20 import org.apache.log4j.Logger;
21 import org.eclipse.core.runtime.IProgressMonitor;
22 import org.eclipse.core.runtime.IStatus;
23 import org.eclipse.core.runtime.Status;
24 import org.eclipse.debug.core.DebugException;
25
26
27 /**
28  * Run a version of FOrrest
29  */

30 public class ForrestStopper extends ForrestJob {
31     /**
32      * Logger for this class
33      */

34     protected static final Logger logger = Logger.getLogger(ForrestStopper.class);
35     
36     private static final int EXCEPTION_UNABLE_TO_STOP = 3010;
37     
38     /**
39      * Create a Forrest runner that will run a JEtty server on a given directory
40      * @param workingDir - the working directory for the command
41      */

42     protected ForrestStopper(String JavaDoc workingDir) {
43         super("Forrest Runner");
44         
45         this.workingDir = workingDir;
46     }
47     
48     /* (non-Javadoc)
49      * @see java.lang.Runnable#run()
50      */

51     public IStatus run(IProgressMonitor monitor) {
52         if (logger.isDebugEnabled()) {
53             logger.debug("run(IProgressMonitor) - start");
54         }
55         
56         IStatus status = null;
57
58         try {
59             ForrestManager.stopServer(workingDir);
60             logger.info("run() - Forrest server stopped");
61             status = Status.OK_STATUS;
62         } catch (DebugException e) {
63             logger.error("run(IProgressMonitor)", e);
64             status = new Status(Status.ERROR, ForrestPlugin.ID, ForrestStopper.EXCEPTION_UNABLE_TO_STOP, "Unable to stop Forrest Server", e);
65         }
66         
67         if (logger.isDebugEnabled()) {
68             logger.debug("run(IProgressMonitor) - end");
69         }
70         return status;
71     }
72     
73 }
Popular Tags