[wsas-java-dev] svn commit r9432 - in branches/wsas/java/2.1/wsf/java/modules/eclipse-wtp-plugins: org.wso2.wsf.ide.core/src/org/wso2/wsf/ide/core/plugin/messages org.wso2.wsf.ide.wtp.ext/src/org/wso2/wsf/ide/wtp/ext/server/command org.wso2.wsf.ide.wtp.ext/src/org/wso2/wsf/ide/wtp/ext/server/util

svn at wso2.org svn at wso2.org
Sat Nov 3 08:44:32 PDT 2007


Author: sandakith
Date: Sat Nov  3 08:43:59 2007
New Revision: 9432

Added:
   branches/wsas/java/2.1/wsf/java/modules/eclipse-wtp-plugins/org.wso2.wsf.ide.wtp.ext/src/org/wso2/wsf/ide/wtp/ext/server/util/WSASDebugUtil.java
Modified:
   branches/wsas/java/2.1/wsf/java/modules/eclipse-wtp-plugins/org.wso2.wsf.ide.core/src/org/wso2/wsf/ide/core/plugin/messages/WSASCoreUIMessages.java
   branches/wsas/java/2.1/wsf/java/modules/eclipse-wtp-plugins/org.wso2.wsf.ide.wtp.ext/src/org/wso2/wsf/ide/wtp/ext/server/command/WSASDebugCommand.java
Log:
Fix the windows WSAS debug issue.

Modified: branches/wsas/java/2.1/wsf/java/modules/eclipse-wtp-plugins/org.wso2.wsf.ide.core/src/org/wso2/wsf/ide/core/plugin/messages/WSASCoreUIMessages.java
==============================================================================
--- branches/wsas/java/2.1/wsf/java/modules/eclipse-wtp-plugins/org.wso2.wsf.ide.core/src/org/wso2/wsf/ide/core/plugin/messages/WSASCoreUIMessages.java	(original)
+++ branches/wsas/java/2.1/wsf/java/modules/eclipse-wtp-plugins/org.wso2.wsf.ide.core/src/org/wso2/wsf/ide/core/plugin/messages/WSASCoreUIMessages.java	Sat Nov  3 08:43:59 2007
@@ -23,6 +23,7 @@
 			"org.wso2.wsf.ide.core.plugin.messages.WSASCoreUI";		//$NON-NLS-1$
 	public static final String DIR_BIN = "bin" ; 					//$NON-NLS-1$
 	public static final String WSAS_START_BAT = "startup.bat" ; 	//$NON-NLS-1$
+	public static final String WSAS_DEBUG_BAT = "wso2wsas.bat" ; 	//$NON-NLS-1$
 	public static final String WSAS_START_SH = "wso2wsas.sh" ;      //$NON-NLS-1$
 	public static final String WSAS_STOP_BAT = "shutdown.bat" ; 	//$NON-NLS-1$
 	public static final String WSAS_STOP_SH = "shutdown.sh" ; 		//$NON-NLS-1$

Modified: branches/wsas/java/2.1/wsf/java/modules/eclipse-wtp-plugins/org.wso2.wsf.ide.wtp.ext/src/org/wso2/wsf/ide/wtp/ext/server/command/WSASDebugCommand.java
==============================================================================
--- branches/wsas/java/2.1/wsf/java/modules/eclipse-wtp-plugins/org.wso2.wsf.ide.wtp.ext/src/org/wso2/wsf/ide/wtp/ext/server/command/WSASDebugCommand.java	(original)
+++ branches/wsas/java/2.1/wsf/java/modules/eclipse-wtp-plugins/org.wso2.wsf.ide.wtp.ext/src/org/wso2/wsf/ide/wtp/ext/server/command/WSASDebugCommand.java	Sat Nov  3 08:43:59 2007
@@ -15,6 +15,8 @@
  */
 package org.wso2.wsf.ide.wtp.ext.server.command;
 
+import java.io.File;
+import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 
 import org.eclipse.core.runtime.IStatus;
@@ -22,16 +24,20 @@
 import org.wso2.wsf.ide.core.plugin.messages.WSASCoreUIMessages;
 import org.wso2.wsf.ide.core.utils.FileUtils;
 import org.wso2.wsf.ide.wtp.ext.server.bean.WSASConfigurationBean;
+import org.wso2.wsf.ide.wtp.ext.server.util.WSASDebugUtil;
 
 public class WSASDebugCommand {
 	
     private static IStatus status;
 
-	public  static IStatus run() throws InvocationTargetException {
+	public  static IStatus run() throws InvocationTargetException{
+	 try{
 		status = Status.OK_STATUS;
 		Process wsasProcess = null;
-		String pathNodesStopWin[] = {WSASCoreUIMessages.DIR_BIN, WSASCoreUIMessages.WSAS_START_BAT};
+		String pathNodesStopWin[] = {WSASCoreUIMessages.DIR_BIN, WSASCoreUIMessages.WSAS_DEBUG_BAT};
 		String pathNodesStopIx[] = {WSASCoreUIMessages.DIR_BIN, WSASCoreUIMessages.WSAS_START_SH};
+		WSASDebugUtil debugUtil = new WSASDebugUtil();
+		File runnerFile = debugUtil.createWindowsDebugRunnerFile();
 
 		if (WSASConfigurationBean.isWsasStartStatus()) {
 			status = new Status( IStatus.ERROR,"id",11,WSASCoreUIMessages.WSAS_ALREADY_RUNNING,null);
@@ -39,7 +45,6 @@
 		}else{
 		
 				String wsasInstallationLocation = WSASConfigurationBean.getWsasInstallationPath();
-				try {
 					Runtime runtime = Runtime.getRuntime();
 					String OS = System.getProperty(WSASCoreUIMessages.PROPERTIES_OS_NAME).toLowerCase();
 					String debugAppender = WSASCoreUIMessages.WSAS_DEFAULT_DEBUG_APPENDER +
@@ -48,7 +53,8 @@
 							|| (OS.indexOf(WSASCoreUIMessages.OS_WIN_NT) > -1)
 							|| (OS.indexOf(WSASCoreUIMessages.OS_WIN_2000) > -1)
 							|| (OS.indexOf(WSASCoreUIMessages.OS_WIN_XP) > -1)) {
-						wsasProcess = runtime.exec(FileUtils.addNodesToPath(wsasInstallationLocation, 
+						wsasProcess = runtime.exec(runnerFile.getAbsolutePath() + " "+ 
+													FileUtils.addNodesToPath(wsasInstallationLocation, 
 																			pathNodesStopWin) 
 																			+debugAppender);
 						wsasProcess.waitFor();
@@ -57,14 +63,13 @@
 							FileUtils.addNodesToPath(wsasInstallationLocation, pathNodesStopIx) 
 						              +debugAppender);
 					}
-				} catch (Exception e) {
-					e.printStackTrace();
-				}
-				
 				WSASConfigurationBean.setWSASAlreadyRunning(false);
-				
 		}
-		return status;
+		runnerFile.delete();
+	  } catch (Exception e) {
+			e.printStackTrace();
+	  }
+	  return status;
 	}
 
 }

Added: branches/wsas/java/2.1/wsf/java/modules/eclipse-wtp-plugins/org.wso2.wsf.ide.wtp.ext/src/org/wso2/wsf/ide/wtp/ext/server/util/WSASDebugUtil.java
==============================================================================
--- (empty file)
+++ branches/wsas/java/2.1/wsf/java/modules/eclipse-wtp-plugins/org.wso2.wsf.ide.wtp.ext/src/org/wso2/wsf/ide/wtp/ext/server/util/WSASDebugUtil.java	Sat Nov  3 08:43:59 2007
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.wso2.wsf.ide.wtp.ext.server.util;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+public class WSASDebugUtil {
+	
+	public File createWindowsDebugRunnerFile() 
+												throws 	IllegalArgumentException,
+														FileNotFoundException,
+														IOException
+														{
+		IPath runnerPath = new Path(System.getProperty("user.dir"));
+		runnerPath = runnerPath.append("runner.bat");
+		File aFile = new File(runnerPath.toOSString());
+		aFile.createNewFile();
+		String aContents ="start %1 %2 %3 & exit";
+	    if (aFile == null) {
+	        throw new IllegalArgumentException("File should not be null.");
+	      }
+	      if (!aFile.exists()) {
+	        throw new FileNotFoundException ("File does not exist: " + aFile);
+	      }
+	      if (!aFile.isFile()) {
+	        throw new IllegalArgumentException("Should not be a directory: " + aFile);
+	      }
+	      if (!aFile.canWrite()) {
+	        throw new IllegalArgumentException("File cannot be written: " + aFile);
+	      }
+
+	      //declared here only to make visible to finally clause; generic reference
+	      Writer output = null;
+	      try {
+	        //use buffering
+	        //FileWriter always assumes default encoding is OK!
+	        output = new BufferedWriter( new FileWriter(aFile) );
+	        output.write( aContents );
+	      }
+	      finally {
+	        //flush and close both "output" and its underlying FileWriter
+	        if (output != null) output.close();
+	      }
+	      return aFile;
+	}
+
+}




More information about the Wsas-java-dev mailing list