Author: dennyxu
Date: 2009-10-10 04:29:27 -0400 (Sat, 10 Oct 2009)
New Revision: 18034
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml
Log:
JBide-4257: cannot create top down java bean web service
changes:
1.when launching a jbossws jax-ws tools command line, set java_home environment variable
to the location of java runtime of the web service web project
this change avoid the generating web service failure if the user doesn't set
java_home
2. add a workaround for JBWS-2687, so if the user use jdk1.6, web service generation can
work as well
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2009-10-10
05:01:34 UTC (rev 18033)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2009-10-10
08:29:27 UTC (rev 18034)
@@ -9,6 +9,7 @@
import java.util.List;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.internal.utils.Policy;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -21,6 +22,8 @@
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
import org.jboss.tools.ws.core.utils.StatusUtils;
@@ -34,95 +37,145 @@
protected ServiceModel model;
private String cmdFileName_linux;
private String cmdFileName_win;
+ private static String JAVA_HOME = "JAVA_HOME"; //$NON-NLS-1$
public AbstractGenerateCodeCommand(ServiceModel model) {
this.model = model;
cmdFileName_linux = getCommandLineFileName_linux();
cmdFileName_win = getCommandLineFileName_win();
+
}
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
- IStatus status = Status.OK_STATUS;
+ try {
+ monitor.beginTask("", 100); //$NON-NLS-1$
+ monitor
+ .subTask(JBossWSCreationCoreMessages.Progress_Message_Generating);
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- model.getWebProjectName());
+ IStatus status = Status.OK_STATUS;
- try {
- String runtimeLocation = JBossWSCreationUtils
- .getJBossWSRuntimeLocation(project);
- String commandLocation = runtimeLocation + Path.SEPARATOR + "bin";
//$NON-NLS-1$
- IPath path = new Path(commandLocation);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(model.getWebProjectName());
- List<String> command = new ArrayList<String>();
+ try {
+ String runtimeLocation = JBossWSCreationUtils
+ .getJBossWSRuntimeLocation(project);
+ String commandLocation = runtimeLocation + Path.SEPARATOR
+ + "bin"; //$NON-NLS-1$
+ IPath path = new Path(commandLocation);
- if (System.getProperty("os.name").toLowerCase().indexOf("win")
>= 0) { //$NON-NLS-1$ //$NON-NLS-2$
- command.add("cmd.exe"); //$NON-NLS-1$
- command.add("/c"); //$NON-NLS-1$
- command.add(cmdFileName_win);
- path = path.append(cmdFileName_win);
- } else {
- command.add("sh"); //$NON-NLS-1$
- command.add(cmdFileName_linux);
- path = path.append(cmdFileName_linux);
- }
+ List<String> command = new ArrayList<String>();
+ String[] env = getEnvironmentVariables(project);
- if (!path.toFile().getAbsoluteFile().exists()) {
- return StatusUtils
- .errorStatus(NLS
- .bind(
- JBossWSCreationCoreMessages.Error_Message_Command_File_Not_Found,
- new String[] { path.toOSString() }));
- }
+ if (System.getProperty("os.name").toLowerCase().indexOf("win")
>= 0) { //$NON-NLS-1$ //$NON-NLS-2$
+ command.add("cmd.exe"); //$NON-NLS-1$
+ command.add("/c"); //$NON-NLS-1$
+ command.add(cmdFileName_win);
+ path = path.append(cmdFileName_win);
+ } else {
+ command.add("sh"); //$NON-NLS-1$
+ command.add(cmdFileName_linux);
+ path = path.append(cmdFileName_linux);
+ }
- addCommandlineArgs(command);
- addCommonArgs(command, project);
-
- Process proc = DebugPlugin.exec(command.toArray(new String[command
- .size()]), new File(commandLocation));
- StringBuffer errorResult = new StringBuffer();
- StringBuffer inputResult = new StringBuffer();
+ if (!path.toFile().getAbsoluteFile().exists()) {
+ return StatusUtils
+ .errorStatus(NLS
+ .bind(
+ JBossWSCreationCoreMessages.Error_Message_Command_File_Not_Found,
+ new String[] { path.toOSString() }));
+ }
- convertInputStreamToString(errorResult, proc.getErrorStream());
- convertInputStreamToString(inputResult, proc.getInputStream());
+ addCommandlineArgs(command);
+ addCommonArgs(command, project);
- int exitValue = proc.waitFor();
+ Process proc = DebugPlugin.exec(command
+ .toArray(new String[command.size()]), new File(
+ commandLocation), env);
+ StringBuffer errorResult = new StringBuffer();
+ StringBuffer inputResult = new StringBuffer();
- if (exitValue != 0) {
- return StatusUtils.errorStatus(errorResult.toString());
- } else {
+ convertInputStreamToString(errorResult, proc.getErrorStream());
+ convertInputStreamToString(inputResult, proc.getInputStream());
+
+ int exitValue = proc.waitFor();
+
String resultInput = inputResult.toString();
- if (resultInput != null && resultInput.indexOf("[ERROR]") >= 0)
{ //$NON-NLS-1$
- JBossWSCreationCore.getDefault().logError(resultInput);
- IStatus errorStatus = StatusUtils
- .warningStatus(resultInput);
- status = StatusUtils
- .warningStatus(
- JBossWSCreationCoreMessages.Error_Message_Failed_To_Generate_Code,
- new CoreException(errorStatus));
+
+ if (exitValue != 0) {
+
+ JBossWSCreationCore.getDefault().logError(
+ errorResult.toString());
+ JBossWSCreationCore.getDefault().logError(
+ inputResult.toString());
+
+ if (resultInput != null
+ && resultInput.indexOf("compiling code...") >= 0)
{//$NON-NLS-1$
+ return StatusUtils
+ .warningStatus(errorResult.toString());
+ }
+ return StatusUtils.errorStatus(errorResult.toString());
} else {
- JBossWSCreationCore.getDefault().logInfo(resultInput);
+ if (resultInput != null
+ && resultInput.indexOf("[ERROR]") >= 0) { //$NON-NLS-1$
+ JBossWSCreationCore.getDefault()
+ .logWarning(resultInput);
+ IStatus errorStatus = StatusUtils
+ .warningStatus(resultInput);
+ status = StatusUtils
+ .warningStatus(
+ JBossWSCreationCoreMessages.Error_Message_Failed_To_Generate_Code,
+ new CoreException(errorStatus));
+ } else {
+ JBossWSCreationCore.getDefault().logInfo(resultInput);
+ }
}
+
+ } catch (InterruptedException e) {
+ JBossWSCreationCore.getDefault().logError(e);
+ return StatusUtils.errorStatus(e);
+ } catch (CoreException e) {
+ JBossWSCreationCore.getDefault().logError(e);
+ // unable to get runtime location
+ return e.getStatus();
+ } catch (Exception e) {
+ JBossWSCreationCore.getDefault().logError(e);
+ return StatusUtils.errorStatus(e);
}
- } catch (InterruptedException e) {
- JBossWSCreationCore.getDefault().logError(e);
- return StatusUtils.errorStatus(e);
- } catch (CoreException e) {
- JBossWSCreationCore.getDefault().logError(e);
- // unable to get runtime location
- return e.getStatus();
- } catch (Exception e) {
- JBossWSCreationCore.getDefault().logError(e);
- return StatusUtils.errorStatus(e);
+ refreshProject(model.getWebProjectName(), monitor);
+
+ return status;
+ } finally {
+ monitor.done();
}
- refreshProject(model.getWebProjectName(), monitor);
+ }
- return status;
+ //SET JAVA_HOME environment variable to the location of java runtime of the project
+ //so jbossws jax-ws command line tools will only use the java runtime to launch java
command
+ private String[] getEnvironmentVariables(IProject project){
+ String[] env = null;
+ String javaHome = System.getenv(JAVA_HOME);
+ if(javaHome == null || !(new File(javaHome).exists())){
+ IJavaProject javaProject = JavaCore.create(project);
+ if(javaProject == null) return null;
+
+ try {
+ IVMInstall vm = JavaRuntime.getVMInstall(javaProject);
+ String javaLocation = vm.getInstallLocation().toString();
+ env = new String[]{JAVA_HOME + "=" + javaLocation}; //$NON-NLS-1$
+
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ return env;
}
-
+
private void addCommonArgs(List<String> command, IProject project) throws
Exception {
String projectRoot = JBossWSCreationUtils.getProjectRoot(
model.getWebProjectName()).toOSString();
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2009-10-10
05:01:34 UTC (rev 18033)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2009-10-10
08:29:27 UTC (rev 18034)
@@ -12,6 +12,8 @@
# END NON-TRANSLATABLE
Label_Button_Text_Remove=Remove
+Progress_Message_Generating=Generating Web Service resources...
+
Error_Message_Invalid_Binding_File={0} is not a valid JAX-WS or JAXB binding file
Error_Message_Failed_To_Generate_Code=Failed to Generate Web Service code, please check
the log for more details
Error_Message_Failed_to_Generate_Implementation=Failed to generate implementation class
@@ -45,3 +47,4 @@
JBossWSFacetInstallPage_New=New...
JBossWSRuntimeConfigBlock_Duplicated_Jar=Duplicated jar on classpath:{0}
Client_Sample_Run_Over= Call Over!
+
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2009-10-10
05:01:34 UTC (rev 18033)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2009-10-10
08:29:27 UTC (rev 18034)
@@ -31,6 +31,7 @@
public static String Value_Target_0;
public static String Value_Target_1;
public static String Label_Button_Text_Remove;
+ public static String Progress_Message_Generating;
public static String Error_Message_Invalid_Binding_File;
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml 2009-10-10 05:01:34 UTC
(rev 18033)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml 2009-10-10 08:29:27 UTC
(rev 18034)
@@ -41,7 +41,6 @@
class="org.jboss.tools.ws.creation.ui.wsrt.JBossWebServiceRuntime">
<required-facet-version facet="jst.web" version="2.3"
allow-newer="true" />
- <required-facet-version facet="jbossws.core" version="2.0"
allow-newer="true" />
</clientRuntime>
</extension>
@@ -79,4 +78,4 @@
</page>
</extension>
-</plugin>
\ No newline at end of file
+</plugin>