Author: Grid.Qian
Date: 2009-04-27 00:24:58 -0400 (Mon, 27 Apr 2009)
New Revision: 14928
Added:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java
Removed:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java
Modified:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/.classpath
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSDL2JavaCommand.java
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/projects/JavaFirstTestProject/.classpath
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java
Log:
JBIDE-3783: can't generate WS from a java class in the java project not dynamic web
project and update the unit tests for this issue
Modified:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/.classpath
===================================================================
---
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/.classpath 2009-04-25
18:43:22 UTC (rev 14927)
+++
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/.classpath 2009-04-27
04:24:58 UTC (rev 14928)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry exported="true" kind="lib"
path="lib/wsdl4j.jar"/>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry exported="true" kind="lib"
path="lib/wsdl4j.jar"
sourcepath="org.jboss.tools.ws.creation.coresrc.zip"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
===================================================================
---
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2009-04-25
18:43:22 UTC (rev 14927)
+++
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2009-04-27
04:24:58 UTC (rev 14928)
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name.0
-Bundle-SymbolicName: org.jboss.tools.ws.creation.core
+Bundle-SymbolicName: org.jboss.tools.ws.creation.core;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.jboss.tools.ws.creation.core.JBossWSCreationCore
Bundle-Vendor: %Bundle-Vendor.0
@@ -16,7 +16,6 @@
org.eclipse.wst.wsdl,
org.eclipse.wst.command.env.core,
org.eclipse.wst.command.env,
- org.eclipse.jst.ws.axis2.consumption.core,
org.apache.ant,
org.apache.xerces,
org.eclipse.jst.j2ee,
@@ -32,7 +31,9 @@
org.jboss.tools.common,
org.jboss.ide.eclipse.as.classpath.core;bundle-version="1.0.0",
org.eclipse.jst.server.core;bundle-version="1.1.0",
- org.eclipse.jdt;bundle-version="3.4.0"
+ org.eclipse.jdt;bundle-version="3.4.0",
+ org.eclipse.jdt.launching;bundle-version="3.4.0",
+ org.eclipse.debug.core;bundle-version="3.4.0"
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.creation.core,
org.jboss.tools.ws.creation.core.commands,
Modified:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
===================================================================
---
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2009-04-25
18:43:22 UTC (rev 14927)
+++
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2009-04-27
04:24:58 UTC (rev 14928)
@@ -5,6 +5,8 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
@@ -16,6 +18,7 @@
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.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.osgi.util.NLS;
@@ -46,20 +49,22 @@
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
model.getWebProjectName());
- String projectRoot = JBossWSCreationUtils.getProjectRoot(
- model.getWebProjectName()).toOSString();
- IJavaProject javaProject = JavaCore.create(project);
try {
String runtimeLocation = JBossWSCreationUtils
.getJBossWSRuntimeLocation(project);
String commandLocation = runtimeLocation + Path.SEPARATOR + "bin";
IPath path = new Path(commandLocation);
- StringBuffer command = new StringBuffer();
+
+ List<String> command = new ArrayList<String>();
+
if (System.getProperty("os.name").toLowerCase().indexOf("win")
>= 0) {
- command.append("cmd.exe /c ").append(cmdFileName_win);
+ command.add("cmd.exe");
+ command.add("/c");
+ command.add(cmdFileName_win);
path = path.append(cmdFileName_win);
} else {
- command.append("sh ").append(cmdFileName_linux);
+ command.add("sh");
+ command.add(cmdFileName_linux);
path = path.append(cmdFileName_linux);
}
@@ -71,18 +76,11 @@
new String[] { path.toOSString() }));
}
- String args = getCommandlineArgs();
- command.append(" -k ").append(args).append(" ");
- if(model.getWsdlURI() != null){
- command.append(model.getWsdlURI());
- }
- command.append(" -o ").append(projectRoot).append(Path.SEPARATOR)
- .append(
- javaProject.getOutputLocation()
- .removeFirstSegments(1).toOSString());
- Runtime rt = Runtime.getRuntime();
- Process proc = rt.exec(command.toString(), null, new File(
- commandLocation));
+ 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();
@@ -97,9 +95,10 @@
String resultInput = inputResult.toString();
if (resultInput != null && resultInput.indexOf("[ERROR]") >= 0)
{
JBossWSCreationCore.getDefault().logError(resultInput);
- IStatus errorStatus = StatusUtils.errorStatus(resultInput);
+ IStatus errorStatus = StatusUtils
+ .warningStatus(resultInput);
status = StatusUtils
- .errorStatus(
+ .warningStatus(
JBossWSCreationCoreMessages.Error_Message_Failed_To_Generate_Code,
new CoreException(errorStatus));
} else {
@@ -107,15 +106,16 @@
}
}
- } catch (IOException e) {
+ } catch (InterruptedException e) {
JBossWSCreationCore.getDefault().logError(e);
-
- } catch (InterruptedException e) {
- // ignore
+ 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);
@@ -123,6 +123,28 @@
return status;
}
+ private void addCommonArgs(List<String> command, IProject project) throws
Exception {
+ String projectRoot = JBossWSCreationUtils.getProjectRoot(
+ model.getWebProjectName()).toOSString();
+ IJavaProject javaProject = JavaCore.create(project);
+
+ command.add("-k");
+
+ command.add("-s");
+ command.add(JBossWSCreationUtils.getJavaProjectSrcLocation(project));
+
+ command.add("-o");
+ StringBuffer opDir = new StringBuffer();
+ opDir.append(projectRoot).append(Path.SEPARATOR).append(
+ javaProject.getOutputLocation().removeFirstSegments(1)
+ .toOSString());
+ command.add(opDir.toString());
+ if (model.getWsdlURI() != null) {
+ command.add(model.getWsdlURI());
+ }
+
+ }
+
private void convertInputStreamToString(final StringBuffer result,
final InputStream input) {
@@ -160,7 +182,8 @@
}
}
- abstract protected String getCommandlineArgs();
+ abstract protected void addCommandlineArgs(List<String> command)
+ throws Exception;
abstract protected String getCommandLineFileName_linux();
Added:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java
===================================================================
---
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java
(rev 0)
+++
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java 2009-04-27
04:24:58 UTC (rev 14928)
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.creation.core.commands;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.core.utils.ClasspathParser;
+import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
+
+/**
+ * @author Grid Qian
+ */
+public class Java2WSCommand extends AbstractGenerateCodeCommand {
+
+ private static String WSPROVIDER_FILE_NAME_LINUX = "wsprovide.sh";
+ private static String WSPROVIDER_FILE_NAME_WIN = "wsprovide.bat";
+
+ public Java2WSCommand(ServiceModel model) {
+ super(model);
+ }
+
+ @Override
+ protected String getCommandLineFileName_linux() {
+ return WSPROVIDER_FILE_NAME_LINUX;
+ }
+
+ @Override
+ protected String getCommandLineFileName_win() {
+ return WSPROVIDER_FILE_NAME_WIN;
+ }
+
+ @Override
+ protected void addCommandlineArgs(List<String> command) throws IOException {
+
+ String projectName = model.getWebProjectName();
+ String projectRoot = JBossWSCreationUtils.getProjectRoot(projectName)
+ .toOSString();
+
+ IProject iProject = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(projectName);
+
+ if (model.isGenWSDL()) {
+ command.add("-w");
+ }
+ command.add("-r");
+ command.add(projectRoot + Path.SEPARATOR + "wsdl");
+ command.add(model.getServiceClasses().get(0));
+
+ command.add("-c");
+ command.add(getClasspath(iProject));
+ }
+
+ private String getClasspath(IProject iProject) throws IOException {
+ String cpStr = ClasspathParser.getInstance().getClasspathString(
+ iProject);
+
+ if (isLongCommandLines(cpStr)) {
+ File tempJar = null;
+ tempJar = File.createTempFile("temp", ".jar");
+ Manifest mf = new Manifest();
+
+ // replace space with "%20"
+ cpStr = cpStr.replace(" ", "%20");
+ // replace \ with /
+ cpStr = cpStr.replace("\\", "/");
+ // get classpath array
+ String[] cpArray = cpStr.split(";");
+ StringBuffer cpBF = new StringBuffer();
+ for (int i = 0; i < cpArray.length; i++) {
+ // if the classpath entry is a directory, it should be added a /
+ // after it
+ if (!cpArray[i].endsWith(".jar") &&
!cpArray[i].endsWith("/")) {
+ cpArray[i] = cpArray[i] + "/";
+ }
+ // if the system is windows, the classpath entry should be added
+ // a / before it
+ if (System.getProperty("os.name").toLowerCase().indexOf("win")
>= 0)
+ cpArray[i] = "/" + cpArray[i];
+ // there should be a space between classpath entries
+ cpBF.append(cpArray[i]).append(" ");
+ }
+ cpStr = cpBF.toString();
+ cpStr.trim();
+
+ mf.getMainAttributes().put(Attributes.Name.CLASS_PATH, cpStr);
+ mf.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.2");
+
+ try {
+ FileUtil.jar(new File[0], tempJar.getAbsolutePath(), mf);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ cpStr = tempJar.getAbsolutePath();
+ } else {
+ // if the system is not windows, the split should be :
+ if (System.getProperty("os.name").toLowerCase().indexOf("win")
< 0)
+ cpStr = cpStr.replace(";", ":");
+ }
+ return cpStr;
+ }
+
+ public boolean isLongCommandLines(String command) {
+ if (command == null)
+ return false;
+ return command.length() > 1024 ? true : false;
+ }
+
+ // private String getClasspathEntries(IJavaProject javaProject) {
+ // IClasspathEntry[] iniEntries = null;
+ // List<IClasspathEntry> pathList = new ArrayList<IClasspathEntry>();
+ // IClasspathEntry[] resolvedEntries = null;
+ // try {
+ // iniEntries = javaProject.getRawClasspath();
+ // for (IClasspathEntry entry : iniEntries) {
+ // IClasspathContainer container = JavaCore.getClasspathContainer(
+ // entry.getPath(), javaProject);
+ // if (!(container instanceof JBossWSRuntimeClasspathContainer)) {
+ // if (!(container instanceof RuntimeClasspathContainer && container
+ // .getDescription().contains("JBoss"))) {
+ // pathList.add(entry);
+ // }
+ // }
+ // }
+ // resolvedEntries = ((JavaProject) javaProject)
+ // .resolveClasspath(pathList
+ // .toArray(new IClasspathEntry[pathList.size()]));
+ // } catch (JavaModelException e) { // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ // StringBuffer path = new StringBuffer();
+ // for (IClasspathEntry entry : resolvedEntries) {
+ // if (entry.getEntryKind() == 3) {
+ // path.append(workspaceRoot);
+ // continue;
+ // }
+ // if (entry.getEntryKind() == 2) {
+ // String projectRoot = JBossWSCreationUtils.getProjectRoot(
+ // entry.getPath().segment(0)).toOSString();
+ // IProject refProject = ResourcesPlugin.getWorkspace().getRoot()
+ // .getProject(entry.getPath().segment(0));
+ // IJavaProject refJavaProject = JavaCore.create(refProject);
+ // try {
+ // path.append(projectRoot).append(Path.SEPARATOR).append(
+ // refJavaProject.getOutputLocation()
+ // .removeFirstSegments(1).toOSString())
+ // .append(seperator);
+ // } catch (JavaModelException e) {
+ // e.printStackTrace();
+ // }
+ // } else {
+ // path.append(entry.getPath().toOSString()).append(seperator);
+ // }
+ // }
+ // String str = path.toString();
+ // if (str.endsWith(seperator)) {
+ // str = str.substring(0, str.length() - 1);
+ // }
+ // return str;
+ //
+ // }
+
+}
\ No newline at end of file
Property changes on:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSDL2JavaCommand.java
===================================================================
---
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSDL2JavaCommand.java 2009-04-25
18:43:22 UTC (rev 14927)
+++
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSDL2JavaCommand.java 2009-04-27
04:24:58 UTC (rev 14928)
@@ -3,9 +3,7 @@
import java.io.File;
import java.util.List;
-import org.eclipse.core.runtime.Path;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
-import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
public class WSDL2JavaCommand extends AbstractGenerateCodeCommand{
@@ -26,39 +24,36 @@
protected String getCommandLineFileName_win() {
return WSCONSUEM_FILE_NAME_WIN;
}
-
+
@Override
- protected String getCommandlineArgs() {
- String commandLine;
- String project = model.getWebProjectName();
- String projectRoot = JBossWSCreationUtils.getProjectRoot(project).toOSString();
- commandLine = "-s " + projectRoot + Path.SEPARATOR + "src";
+ protected void addCommandlineArgs(List<String> command) {
if(model.getCustomPackage() != null &&
!"".equals(model.getCustomPackage())){
- commandLine += " -p " + model.getCustomPackage();
+ command.add("-p");
+ command.add(model.getCustomPackage());
}
List<String> bindingFiles = model.getBindingFiles();
for(String bindingFileLocation: bindingFiles){
File bindingFile = new File(bindingFileLocation);
if(bindingFile.exists()){
- commandLine += " -b " + bindingFileLocation;
+ command.add("-b");
+ command.add(bindingFileLocation);
}
}
if(model.getCatalog() != null &&
!"".equals(model.getCatalog().trim())){
File catalog = new File(model.getCatalog());
if(catalog.exists()){
- commandLine += " -c " + model.getCatalog();
+ command.add("-c");
+ command.add(model.getCatalog());
}
}
if(model.getTarget() != null){
- commandLine += " -t " + model.getTarget();
+ command.add("-t");
+ command.add(model.getTarget());
}
-
-
- return commandLine;
}
}
Deleted:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java
===================================================================
---
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java 2009-04-25
18:43:22 UTC (rev 14927)
+++
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java 2009-04-27
04:24:58 UTC (rev 14928)
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.creation.core.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.core.JavaProject;
-import org.eclipse.jst.server.core.internal.RuntimeClasspathContainer;
-import
org.jboss.tools.ws.core.classpath.JBossWSRuntimeClassPathInitializer.JBossWSRuntimeClasspathContainer;
-import org.jboss.tools.ws.creation.core.data.ServiceModel;
-import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
-
-/**
- * @author Grid Qian
- */
-@SuppressWarnings("restriction")
-public class WSProviderInvokeCommand extends AbstractGenerateCodeCommand {
-
- private static String WSPROVIDER_FILE_NAME_LINUX = "wsprovide.sh";
- private static String WSPROVIDER_FILE_NAME_WIN = "wsprovide.bat";
- private static String SEPERATOR_WIN = ";";
- private static String SEPERATOR_LINUX = ":";
- private String seperator;
-
- public WSProviderInvokeCommand(ServiceModel model) {
- super(model);
- }
-
- @Override
- protected String getCommandLineFileName_linux() {
- return WSPROVIDER_FILE_NAME_LINUX;
- }
-
- @Override
- protected String getCommandLineFileName_win() {
- return WSPROVIDER_FILE_NAME_WIN;
- }
-
- @Override
- protected String getCommandlineArgs() {
- if (System.getProperty("os.name").toLowerCase().indexOf("win")
>= 0) {
- seperator = SEPERATOR_WIN;
- } else {
- seperator = SEPERATOR_LINUX;
- }
- StringBuffer commandLine = new StringBuffer();
- String projectName = model.getWebProjectName();
- String projectRoot = JBossWSCreationUtils.getProjectRoot(projectName)
- .toOSString();
-
- IProject iProject = ResourcesPlugin.getWorkspace().getRoot()
- .getProject(projectName);
- IJavaProject javaProject = JavaCore.create(iProject);
-
- commandLine.append(" -s ").append(projectRoot).append(Path.SEPARATOR)
- .append("src");
-
- try {
- commandLine.append(" -c ");
- if(seperator.equals(SEPERATOR_WIN)){
- commandLine.append("\"");
- }
-
- commandLine.append(projectRoot).append(Path.SEPARATOR).append(
- javaProject.getOutputLocation().removeFirstSegments(1)
- .toOSString()).append(seperator);
- commandLine.append(getClasspathEntries(javaProject));
- if(seperator.equals(SEPERATOR_WIN)){
- commandLine.append("\"");
- }
- commandLine.append(" ");
- } catch (JavaModelException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- if (model.isGenWSDL()) {
- commandLine.append(" -w ");
- }
- commandLine.append(" -r
").append(projectRoot).append(Path.SEPARATOR).append("wsdl ");
- commandLine.append(model.getServiceClasses().get(0));
-
- return commandLine.toString();
-
- }
-
- private String getClasspathEntries(IJavaProject javaProject) {
- IClasspathEntry[] iniEntries = null;
- List<IClasspathEntry> pathList = new ArrayList<IClasspathEntry>();
- IClasspathEntry[] resolvedEntries = null;
- try {
- iniEntries = javaProject.getRawClasspath();
- for (IClasspathEntry entry : iniEntries) {
- IClasspathContainer container = JavaCore.getClasspathContainer(
- entry.getPath(), javaProject);
- if (!(container instanceof JBossWSRuntimeClasspathContainer)) {
- if (!(container instanceof RuntimeClasspathContainer && container
- .getDescription().contains("JBoss"))) {
- pathList.add(entry);
- }
- }
- }
- resolvedEntries = ((JavaProject) javaProject)
- .resolveClasspath(pathList
- .toArray(new IClasspathEntry[pathList.size()]));
- } catch (JavaModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- StringBuffer path = new StringBuffer();
- for (IClasspathEntry entry : resolvedEntries) {
- if (entry.getEntryKind() == 3 || entry.getEntryKind() == 2) {
- // path.append(workspaceRoot);
- continue;
- }
- path.append(entry.getPath().toOSString()).append(seperator);
- }
- String str = path.toString();
- if(str.endsWith(seperator)){
- str = str.substring(0, str.length()-1);
- }
- return str;
-
- }
-}
Added:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java
===================================================================
---
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java
(rev 0)
+++
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java 2009-04-27
04:24:58 UTC (rev 14928)
@@ -0,0 +1,278 @@
+package org.jboss.tools.ws.creation.core.utils;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
+
+public class ClasspathParser {
+
+ private static ClasspathParser instance;
+
+ private ClasspathParser() {
+ }
+
+ public static ClasspathParser getInstance() {
+ if (instance == null)
+ instance = new ClasspathParser();
+ return instance;
+ }
+
+ public String getClasspathString(IProject project) {
+ StringBuffer classpath = new StringBuffer();
+ String[] classpathEntries = getClasspath(project, false);
+
+ Vector<String> classpathVector = new Vector<String>();
+ for (int i = 0; i < classpathEntries.length; i++) {
+ if (!classpathVector.contains(classpathEntries[i])) {
+ classpathVector.add(classpathEntries[i]);
+ classpath.append(classpathEntries[i]);
+ classpath.append(";");
+ }
+ }
+ return classpath.toString();
+ }
+
+ @SuppressWarnings("restriction")
+ private String[] getClasspath(IProject project, boolean isDependent) {
+ String[] cClasspath = new String[0];
+ ArrayList<String> projectClasspath = new ArrayList<String>();
+ boolean needJavaClasspath = false;
+
+ IVirtualComponent comp = ComponentCore.createComponent(project);
+ if (comp != null) {
+
+ // get a ear component classpath
+ if (J2EEUtils.isEARComponent(comp)) {
+ cClasspath = getClasspathOfEARProject(project, comp
+ .getName());
+
+ // add component classpath to the project classpath
+ for (int j = 0; j < cClasspath.length; j++) {
+ projectClasspath.add(cClasspath[j]);
+ }
+ } else if (J2EEUtils.isWebComponent(comp)
+ || J2EEUtils.isJavaComponent(comp)) {
+ needJavaClasspath = true;
+
+ IContainer outputContainer = null;
+ IResource fragmentRoot = null;
+ IPackageFragmentRoot[] pkgFragmentRoot = ResourceUtils
+ .getJavaPackageFragmentRoots(project);
+ ArrayList<String> webComponentClasspath = new ArrayList<String>();
+ try {
+ for (int i = 0; i < pkgFragmentRoot.length; i++) {
+ fragmentRoot = pkgFragmentRoot[i]
+ .getCorrespondingResource();
+ if (fragmentRoot != null
+ && (fragmentRoot.getProject().equals(project))
+ && (fragmentRoot.getType() != IResource.FILE)) {
+ outputContainer = J2EEProjectUtilities
+ .getOutputContainer(project,
+ pkgFragmentRoot[i]);
+ if (outputContainer != null) {
+ webComponentClasspath.add(outputContainer
+ .getLocation().toOSString());
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ }
+
+ // add Web component classpath to the project classpath
+ Iterator<String> iter = webComponentClasspath.iterator();
+ while (iter.hasNext()) {
+ projectClasspath.add((String) iter.next());
+ }
+ }
+
+ if (!isDependent) {
+ if (J2EEUtils.isWebComponent(comp)) {
+ needJavaClasspath = true;
+ cClasspath = getWebInfLib(project);
+ for (int j = 0; j < cClasspath.length; j++) {
+ projectClasspath.add(cClasspath[j]);
+ }
+ }
+ }
+
+ } else {
+ needJavaClasspath = true;
+ }
+
+ // a Web or Java component in the project, get the project's Java classpath
+ if (needJavaClasspath) {
+ String[] javaClasspath;
+ try {
+ IJavaProject javaProj = (IJavaProject) project
+ .getNature(JavaCore.NATURE_ID);
+ if (javaProj != null) {
+ javaClasspath = getClasspathForJavaProject(javaProj);
+ for (int j = 0; j < javaClasspath.length; j++) {
+ projectClasspath.add(javaClasspath[j]);
+ }
+ }
+ } catch (CoreException e) {
+ // can't get Java classpath, ignore
+ }
+ }
+
+ return (String[]) projectClasspath.toArray(new String[projectClasspath
+ .size()]);
+ }
+
+ // Need to get all components in the project. If there's a EAR component, get the
+ // utility Jars
+ @SuppressWarnings("restriction")
+ private String[] getUtilityJarClasspath(IProject project) {
+ String[] utilityJarString = new String[0];
+ String[] cClasspath = new String[0];
+ ArrayList<String> utilityJarsClasspath = new ArrayList<String>();
+
+ String component;
+ IVirtualComponent comp = ComponentCore.createComponent(project);
+ if (comp != null) {
+ component = comp.getName();
+ if (J2EEUtils.isEARComponent(comp)) {
+ cClasspath = getClasspathOfEARProject(project, component);
+ for (int j = 0; j < cClasspath.length; j++) {
+ utilityJarsClasspath.add(cClasspath[j]);
+ }
+ utilityJarString = (String[]) utilityJarsClasspath
+ .toArray(new String[utilityJarsClasspath.size()]);
+ }
+ }
+
+ return utilityJarString;
+ }
+
+ private String[] getClasspathOfEARProject(IProject project, String component) {
+ IPath projectPath = project.getProject().getLocation()
+ .addTrailingSeparator().append(component).addTrailingSeparator();
+ return getDirectoryJarFiles(projectPath);
+ }
+
+ private String[] getDirectoryJarFiles(IPath iPath) {
+ File dir = iPath.toFile();
+ Vector<Object> jarsVector = new Vector<Object>();
+ if (dir.exists() && dir.isDirectory()) {
+ String[] filenames = dir.list();
+ for (int i = 0; i < filenames.length; i++) {
+ if (filenames[i].endsWith(".jar"))
+ jarsVector.add(pathToString(iPath) + filenames[i]);
+ }
+ }
+ String[] jars = new String[jarsVector.size()];
+ jarsVector.copyInto(jars);
+ return jars;
+ }
+
+ private String[] getWebInfLib(IProject project) {
+ String[] webinfLibJars = new String[0];
+ ArrayList<String> anArrayList = new ArrayList<String>();
+ try {
+ IVirtualComponent component = ComponentCore
+ .createComponent(project);
+ if (component != null) {
+
+ IVirtualFolder webInfLib = component.getRootFolder().getFolder(
+ new Path("/WEB-INF/lib"));
+ if (webInfLib != null) {
+ IVirtualResource[] resources = webInfLib.members();
+ IResource aResource = null;
+ for (int i = 0; i < resources.length; i++) {
+ aResource = resources[i].getUnderlyingResource();
+ if ("jar".equalsIgnoreCase(aResource.getFileExtension()))
+ anArrayList.add(aResource.getLocation()
+ .toOSString());
+ }
+ if (anArrayList.size() != 0)
+ webinfLibJars = (String[]) anArrayList
+ .toArray(new String[anArrayList.size()]);
+ }
+ }
+ } catch (CoreException e) {
+ }
+ return webinfLibJars;
+ }
+
+ private String[] getClasspathForJavaProject(IJavaProject javaProject) {
+ ArrayList<String> projectClasspath = new ArrayList<String>();
+ try {
+ IClasspathEntry[] buildPath = javaProject
+ .getResolvedClasspath(true);
+ for (int i = 0; i < buildPath.length; i++) {
+ String[] buildPathString = classpathEntryToString(buildPath[i],
+ javaProject.getProject());
+ for (int j = 0; j < buildPathString.length; j++) {
+ projectClasspath.add(buildPathString[j]);
+ }
+ }
+ } catch (JavaModelException jme) {
+ }
+
+ String[] utilityJarsClasspath;
+ IProject project = javaProject.getProject();
+ IProject[] referencingProjects = project.getReferencingProjects();
+ for (int i = 0; i < referencingProjects.length; i++) {
+ utilityJarsClasspath = getUtilityJarClasspath(referencingProjects[i]);
+ for (int j = 0; j < utilityJarsClasspath.length; j++) {
+ projectClasspath.add(utilityJarsClasspath[j]);
+ }
+ }
+
+ return (String[]) projectClasspath.toArray(new String[projectClasspath
+ .size()]);
+ }
+
+ private String[] classpathEntryToString(IClasspathEntry entry,
+ IProject project) {
+ switch (entry.getEntryKind()) {
+ case IClasspathEntry.CPE_LIBRARY: {
+ return new String[] { pathToString(entry.getPath()) };
+ }
+ case IClasspathEntry.CPE_PROJECT: {
+ return getClasspath(ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(entry.getPath().lastSegment()), true);
+ }
+ case IClasspathEntry.CPE_SOURCE: {
+ IPath path = entry.getPath();
+ if (path.segment(0).equals(project.getName()))
+ path = path.removeFirstSegments(1);
+ return new String[] { pathToString(project.getLocation()
+ .addTrailingSeparator().append(path)) };
+ }
+ case IClasspathEntry.CPE_VARIABLE: {
+ return classpathEntryToString(JavaCore
+ .getResolvedClasspathEntry(entry), project);
+ }
+ default: {
+ return new String[] { pathToString(entry.getPath()) };
+ }
+ }
+ }
+
+ private String pathToString(IPath path) {
+ return path.toOSString();
+ }
+}
Property changes on:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
===================================================================
---
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2009-04-25
18:43:22 UTC (rev 14927)
+++
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2009-04-27
04:24:58 UTC (rev 14928)
@@ -4,7 +4,7 @@
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
-* This is free software; you can redistribute it and/or modify it
+ * This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
@@ -23,14 +23,18 @@
import java.io.File;
import java.text.Collator;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import java.util.Locale;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModel;
@@ -53,156 +57,156 @@
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
public class JBossWSCreationUtils {
-
- static final String javaKeyWords[] =
- {
- "abstract", "assert", "boolean",
"break", "byte", "case",
- "catch", "char", "class", "const",
"continue",
- "default", "do", "double", "else",
"extends",
- "false", "final", "finally", "float",
"for",
- "goto", "if", "implements", "import",
"instanceof",
- "int", "interface", "long", "native",
"new",
- "null", "package", "private",
"protected", "public",
- "return", "short", "static",
"strictfp", "super",
- "switch", "synchronized", "this",
"throw", "throws",
- "transient", "true", "try", "void",
"volatile",
- "while"
- };
-
- public static boolean isJavaKeyword(String keyword) {
- if (hasUpperCase(keyword)) {
- return false;
- }
- return (Arrays.binarySearch(javaKeyWords, keyword,
Collator.getInstance(Locale.ENGLISH)) >= 0);
- }
- private static boolean hasUpperCase(String nodeName) {
- if (nodeName == null) {
- return false;
- }
- for (int i = 0; i < nodeName.length(); i++) {
- if (Character.isUpperCase(nodeName.charAt(i))) {
- return true;
- }
- }
- return false;
- }
-
- public static IPath getWorkspace(){
+ static final String javaKeyWords[] = { "abstract", "assert",
"boolean",
+ "break", "byte", "case", "catch",
"char", "class", "const",
+ "continue", "default", "do", "double",
"else", "extends", "false",
+ "final", "finally", "float", "for",
"goto", "if", "implements",
+ "import", "instanceof", "int", "interface",
"long", "native",
+ "new", "null", "package", "private",
"protected", "public",
+ "return", "short", "static", "strictfp",
"super", "switch",
+ "synchronized", "this", "throw", "throws",
"transient", "true",
+ "try", "void", "volatile", "while" };
+
+ public static boolean isJavaKeyword(String keyword) {
+ if (hasUpperCase(keyword)) {
+ return false;
+ }
+ return (Arrays.binarySearch(javaKeyWords, keyword, Collator
+ .getInstance(Locale.ENGLISH)) >= 0);
+ }
+
+ private static boolean hasUpperCase(String nodeName) {
+ if (nodeName == null) {
+ return false;
+ }
+ for (int i = 0; i < nodeName.length(); i++) {
+ if (Character.isUpperCase(nodeName.charAt(i))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static IPath getWorkspace() {
return ResourcesPlugin.getWorkspace().getRoot().getLocation();
}
-
- public static IProject getProjectByName(String project){
+
+ public static IProject getProjectByName(String project) {
String projectString = replaceEscapecharactors(project);
return ResourcesPlugin.getWorkspace().getRoot().getProject(
getProjectNameFromFramewokNameString(projectString));
}
-
- public static IPath getProjectRoot(String project){
+
+ public static IPath getProjectRoot(String project) {
String projectString = replaceEscapecharactors(project);
return ResourcesPlugin.getWorkspace().getRoot().getProject(
- getProjectNameFromFramewokNameString(projectString)).getLocation();
+ getProjectNameFromFramewokNameString(projectString))
+ .getLocation();
}
- public static String pathToWebProjectContainer(String project) {
+ public static String pathToWebProjectContainer(String project) {
IPath projectRoot = getProjectRoot(project);
- IPath currentDynamicWebProjectDir = J2EEUtils.getWebContentPath(
- getProjectByName(project));
- IPath currentDynamicWebProjectDirWithoutProjectRoot = J2EEUtils.getWebContentPath(
- getProjectByName(project)).removeFirstSegments(1).makeAbsolute();
- if(projectRoot.toOSString().contains(getWorkspace().toOSString())){
- return getWorkspace()
- .append(currentDynamicWebProjectDir).toOSString();
- }else{
- return projectRoot
- .append(currentDynamicWebProjectDirWithoutProjectRoot).toOSString();
+ IPath currentDynamicWebProjectDir = J2EEUtils
+ .getWebContentPath(getProjectByName(project));
+ IPath currentDynamicWebProjectDirWithoutProjectRoot = J2EEUtils
+ .getWebContentPath(getProjectByName(project))
+ .removeFirstSegments(1).makeAbsolute();
+ if (projectRoot.toOSString().contains(getWorkspace().toOSString())) {
+ return getWorkspace().append(currentDynamicWebProjectDir)
+ .toOSString();
+ } else {
+ return projectRoot.append(
+ currentDynamicWebProjectDirWithoutProjectRoot).toOSString();
}
-
+
}
-
- public static String pathToWebProjectContainerWEBINF(String project) {
+
+ public static String pathToWebProjectContainerWEBINF(String project) {
IPath projectRoot = getProjectRoot(project);
- IPath webContainerWEBINFDir = J2EEUtils.getWebInfPath(
- getProjectByName(project));
- IPath webContainerWEBINFDirWithoutProjectRoot = J2EEUtils.getWebInfPath(
- getProjectByName(project)).removeFirstSegments(1).makeAbsolute();
- if(projectRoot.toOSString().contains(getWorkspace().toOSString())){
- return getWorkspace()
- .append(webContainerWEBINFDir).toOSString();
- }else{
- return projectRoot
- .append(webContainerWEBINFDirWithoutProjectRoot).toOSString();
+ IPath webContainerWEBINFDir = J2EEUtils
+ .getWebInfPath(getProjectByName(project));
+ IPath webContainerWEBINFDirWithoutProjectRoot = J2EEUtils
+ .getWebInfPath(getProjectByName(project))
+ .removeFirstSegments(1).makeAbsolute();
+ if (projectRoot.toOSString().contains(getWorkspace().toOSString())) {
+ return getWorkspace().append(webContainerWEBINFDir).toOSString();
+ } else {
+ return projectRoot.append(webContainerWEBINFDirWithoutProjectRoot)
+ .toOSString();
}
}
-
-
- private static String replaceEscapecharactors(String vulnarableString){
- if (vulnarableString.indexOf("/")!=-1){
- vulnarableString = vulnarableString.replace('/', File.separator.charAt(0));
+
+ private static String replaceEscapecharactors(String vulnarableString) {
+ if (vulnarableString.indexOf("/") != -1) {
+ vulnarableString = vulnarableString.replace('/', File.separator
+ .charAt(0));
}
return vulnarableString;
}
-
-
- private static String getProjectNameFromFramewokNameString(String
frameworkProjectString){
- if (frameworkProjectString.indexOf(getSplitCharactor())== -1){
+
+ private static String getProjectNameFromFramewokNameString(
+ String frameworkProjectString) {
+ if (frameworkProjectString.indexOf(getSplitCharactor()) == -1) {
return frameworkProjectString;
- }else{
+ } else {
return frameworkProjectString.split(getSplitCharactors())[1];
}
}
-
-
- private static String getSplitCharactor(){
- //Windows check (because from inside wtp in return I received a hard coded path)
- if (File.separatorChar == '\\'){
- return "\\" ;
- }else{
+
+ private static String getSplitCharactor() {
+ // Windows check (because from inside wtp in return I received a hard
+ // coded path)
+ if (File.separatorChar == '\\') {
+ return "\\";
+ } else {
return File.separator;
}
}
-
-
- private static String getSplitCharactors(){
- //Windows check (because from inside wtp in return I received a hard coded path)
- if (File.separatorChar == '\\'){
+
+ private static String getSplitCharactors() {
+ // Windows check (because from inside wtp in return I received a hard
+ // coded path)
+ if (File.separatorChar == '\\') {
return "\\" + File.separator;
- }else{
+ } else {
return File.separator;
}
}
-
- public static String classNameFromQualifiedName(String qualifiedCalssName){
- //This was done due to not splitting with . Strange
- qualifiedCalssName = qualifiedCalssName.replace('.', ':');
- String[] parts = qualifiedCalssName.split(":");
- if (parts.length == 0){
- return "";
- }
- return parts[parts.length-1];
- }
-
+
+ public static String classNameFromQualifiedName(String qualifiedCalssName) {
+ // This was done due to not splitting with . Strange
+ qualifiedCalssName = qualifiedCalssName.replace('.', ':');
+ String[] parts = qualifiedCalssName.split(":");
+ if (parts.length == 0) {
+ return "";
+ }
+ return parts[parts.length - 1];
+ }
+
// JDT utils
/**
* get JavaProject object from project name
*/
- public static IJavaProject getJavaProjectByName(String projectName) throws
JavaModelException {
+ public static IJavaProject getJavaProjectByName(String projectName)
+ throws JavaModelException {
- IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
- model.open(null);
+ IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace()
+ .getRoot());
+ model.open(null);
- IJavaProject[] projects = model.getJavaProjects();
+ IJavaProject[] projects = model.getJavaProjects();
- for (IJavaProject proj : projects) {
- if (proj.getProject().getName().equals(projectName)) {
- return proj;
- }
- }
+ for (IJavaProject proj : projects) {
+ if (proj.getProject().getName().equals(projectName)) {
+ return proj;
+ }
+ }
- return null;
- }
-
- public static ICompilationUnit findUnitByFileName(IJavaElement javaElem,
+ return null;
+ }
+
+ public static ICompilationUnit findUnitByFileName(IJavaElement javaElem,
String filePath) throws Exception {
ICompilationUnit unit = null;
@@ -252,26 +256,30 @@
return null;
}
-
- /**
- * get Java compilation unit by file path
- * @param javaFile the java sour file to look
- * @return ICompilationUnit, JDK compilation unit for this java file.
- */
- public static ICompilationUnit getJavaUnitFromFile(IFile javaFile) {
- try {
- IJavaProject project =
getJavaProjectByName(javaFile.getProject().getName());
- if (project == null) {
- return null;
- }
+ /**
+ * get Java compilation unit by file path
+ *
+ * @param javaFile
+ * the java sour file to look
+ * @return ICompilationUnit, JDK compilation unit for this java file.
+ */
+ public static ICompilationUnit getJavaUnitFromFile(IFile javaFile) {
+ try {
+ IJavaProject project = getJavaProjectByName(javaFile.getProject()
+ .getName());
- return findUnitByFileName(project, javaFile.getFullPath().toString());
- } catch (Exception e) {
- return null;
- }
- }
-
+ if (project == null) {
+ return null;
+ }
+
+ return findUnitByFileName(project, javaFile.getFullPath()
+ .toString());
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
public static boolean validateJBossWSLocation() {
String location = JBossWSCorePlugin.getDefault().getPreferenceStore()
.getString(JBossWSCoreMessages.WS_Location);
@@ -280,7 +288,7 @@
}
return true;
}
-
+
public static String getJBossWSRuntimeLocation(IProject project)
throws CoreException {
@@ -319,11 +327,12 @@
runtimeTypeName = "";
}
if (runtimeTypeName.toUpperCase().indexOf("JBOSS") >= 0) {
- String runtimeLocation = serverRuntime.getLocation().toOSString();
- if(runtimeLocation.endsWith("bin")){
+ String runtimeLocation = serverRuntime.getLocation()
+ .toOSString();
+ if (runtimeLocation.endsWith("bin")) {
return serverRuntime.getLocation().removeLastSegments(1)
- .toOSString();
- }else{
+ .toOSString();
+ } else {
return runtimeLocation;
}
}
@@ -347,23 +356,57 @@
return "";
}
-
- public static IRuntime
getRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime runtime) {
+
+ public static IRuntime getRuntime(
+ org.eclipse.wst.common.project.facet.core.runtime.IRuntime runtime) {
if (runtime == null)
throw new IllegalArgumentException();
-
+
String id = runtime.getProperty("id");
if (id == null)
return null;
-
- org.eclipse.wst.server.core.IRuntime[] runtimes = ServerCore.getRuntimes();
+
+ org.eclipse.wst.server.core.IRuntime[] runtimes = ServerCore
+ .getRuntimes();
int size = runtimes.length;
for (int i = 0; i < size; i++) {
if (id.equals(runtimes[i].getId()))
return runtimes[i];
}
-
+
return null;
}
-
+
+ public static String getJavaProjectSrcLocation(IProject project) throws
JavaModelException {
+ IResource[] rs = getJavaSourceRoots(project);
+ String src = "";
+ if (rs == null || rs.length == 0)
+ return src;
+ for (int i = 0; i < rs.length; i++) {
+ IPath p = rs[i].getLocation();
+ if (p != null) {
+ src = p.toOSString();
+ }
+ }
+ return src;
+ }
+
+ public static IResource[] getJavaSourceRoots(IProject project) throws JavaModelException
{
+ IJavaProject javaProject = JavaCore.create(project);
+ if (javaProject == null)
+ return null;
+ List<IResource> resources = new ArrayList<IResource>();
+ IClasspathEntry[] es = javaProject.getResolvedClasspath(true);
+ for (int i = 0; i < es.length; i++) {
+ if (es[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
+ IResource findMember = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(es[i].getPath());
+ if (findMember != null && findMember.exists()) {
+ resources.add(findMember);
+ }
+ }
+ }
+ return resources.toArray(new IResource[resources.size()]);
+ }
+
}
Modified: branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml
===================================================================
---
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml 2009-04-25
18:43:22 UTC (rev 14927)
+++
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml 2009-04-27
04:24:58 UTC (rev 14928)
@@ -50,7 +50,7 @@
<widgetFactory
class="org.jboss.tools.ws.creation.ui.wsrt.JBossWSProviderInvokeConfigWidgetFactory"
id="JBossWSProviderInvokeConfig"
-
insertBeforeCommandId="org.jboss.tools.ws.creation.core.commands.WSProviderInvokeCommand">
+
insertBeforeCommandId="org.jboss.tools.ws.creation.core.commands.Java2WSCommand">
</widgetFactory>
</extension>
<extension
Modified:
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java
===================================================================
---
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java 2009-04-25
18:43:22 UTC (rev 14927)
+++
branches/jbosstools-3.0.x/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java 2009-04-27
04:24:58 UTC (rev 14928)
@@ -13,10 +13,10 @@
import org.jboss.tools.ws.creation.core.commands.BindingFilesValidationCommand;
import org.jboss.tools.ws.creation.core.commands.ImplementationClassCreationCommand;
import org.jboss.tools.ws.creation.core.commands.InitialCommand;
+import org.jboss.tools.ws.creation.core.commands.Java2WSCommand;
import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
import org.jboss.tools.ws.creation.core.commands.ValidateWSImplCommand;
import org.jboss.tools.ws.creation.core.commands.WSDL2JavaCommand;
-import org.jboss.tools.ws.creation.core.commands.WSProviderInvokeCommand;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
public class JBossWebService extends AbstractWebService {
@@ -57,7 +57,7 @@
else if (ctx.getScenario().getValue() == WebServiceScenario.BOTTOMUP){
commands.add(new InitialCommand(model, this, WebServiceScenario.BOTTOMUP));
commands.add(new ValidateWSImplCommand(model));
- commands.add(new WSProviderInvokeCommand(model));
+ commands.add(new Java2WSCommand(model));
commands.add(new MergeWebXMLCommand(model));
//commands.add(new
JBossWSRuntimeCommand(ResourcesPlugin.getWorkspace().getRoot().getProject(project)));
}
Modified:
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/projects/JavaFirstTestProject/.classpath
===================================================================
---
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/projects/JavaFirstTestProject/.classpath 2009-04-25
18:43:22 UTC (rev 14927)
+++
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/projects/JavaFirstTestProject/.classpath 2009-04-27
04:24:58 UTC (rev 14928)
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JAVA1.5"/>
- <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.web.container"/>
- <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.module.container"/>
- <classpathentry kind="output" path="build/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
Modified:
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java
===================================================================
---
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java 2009-04-25
18:43:22 UTC (rev 14927)
+++
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java 2009-04-27
04:24:58 UTC (rev 14928)
@@ -18,6 +18,7 @@
import org.jboss.tools.ws.core.test.classpath.JBossWSRuntimeManagerTest;
import org.jboss.tools.ws.core.test.command.JBossWSJavaFirstCommandTest;
import org.jboss.tools.ws.core.test.command.JBossWSClientCommandTest;
+import org.jboss.tools.ws.core.test.command.JBossWSTopDownCommandTest;
public class JBossWSCoreAllTests extends TestCase {
public static final String PLUGIN_ID = "org.jboss.tools.common.test";
@@ -27,7 +28,7 @@
suite.addTestSuite(JBossWSRuntimeManagerTest.class);
suite.addTestSuite(JBossWSJavaFirstCommandTest.class);
suite.addTestSuite(JBossWSClientCommandTest.class);
-
+ suite.addTestSuite(JBossWSTopDownCommandTest.class);
return suite;
}
}
\ No newline at end of file
Modified:
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java
===================================================================
---
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java 2009-04-25
18:43:22 UTC (rev 14927)
+++
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java 2009-04-27
04:24:58 UTC (rev 14928)
@@ -69,7 +69,7 @@
protected static final int DEFAULT_STARTUP_TIME = 150000;
protected static final int DEFAULT_SHUTDOWN_TIME = 90000;
- protected static final String JBOSSWS_HOME_DEFAULT =
"D:/softinstall/jboss-4.2.2.GA/jboss-4.2.2.GA";
+ protected static final String JBOSSWS_HOME_DEFAULT =
"/home/fugang/jboss-all/jboss-soa-p.4.3.0/jboss-as";
public static final String JBOSSWS_42_HOME="jbosstools.test.jboss.home.4.2";
public static final String JBOSS_RUNTIME_42 =
"org.jboss.ide.eclipse.as.runtime.42";
public static final String JBOSS_AS_42_HOME = System.getProperty(JBOSSWS_42_HOME,
JBOSSWS_HOME_DEFAULT);
Modified:
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java
===================================================================
---
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java 2009-04-25
18:43:22 UTC (rev 14927)
+++
branches/jbosstools-3.0.x/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java 2009-04-27
04:24:58 UTC (rev 14928)
@@ -22,6 +22,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@@ -49,7 +50,7 @@
import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
import org.jboss.tools.ws.creation.core.commands.RemoveClientJarsCommand;
import org.jboss.tools.ws.creation.core.commands.ValidateWSImplCommand;
-import org.jboss.tools.ws.creation.core.commands.WSProviderInvokeCommand;
+import org.jboss.tools.ws.creation.core.commands.Java2WSCommand;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
import org.jboss.tools.ws.creation.ui.wsrt.JBossWebService;
@@ -61,7 +62,7 @@
protected static final IWorkspace ws = ResourcesPlugin.getWorkspace();
protected static final IWorkbench wb = PlatformUI.getWorkbench();
- protected static final String JBOSSWS_HOME_DEFAULT =
"/home/grid/Software/jboss-4.2.2.GA";
+ protected static final String JBOSSWS_HOME_DEFAULT =
"D:\\softinstall\\jboss-4.2.3GA\\jboss-4.2.3.GA";
private static final String RuntimeName;
private static final boolean isDeployed;
@@ -135,13 +136,13 @@
fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
- WSProviderInvokeCommand command = new WSProviderInvokeCommand(model);
+ Java2WSCommand command = new Java2WSCommand(model);
IStatus status = command.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
+ assertFalse(status.getMessage(), Status.ERROR == status.getSeverity());
assertTrue(project.getFile(
"src/org/example/www/helloworld/jaxws/SayHello.java").exists());
- assertTrue(project.getFile("WebContent/wsdl/HelloWorldService.wsdl")
+ assertTrue(project.getFile("wsdl/HelloWorldService.wsdl")
.exists());
}
@@ -164,7 +165,7 @@
fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
- cmd = new WSProviderInvokeCommand(model);
+ cmd = new Java2WSCommand(model);
status = cmd.execute(null, null);
assertTrue(status.getMessage(), status.isOK());