Author: Grid.Qian
Date: 2009-04-16 03:48:52 -0400 (Thu, 16 Apr 2009)
New Revision: 14767
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/.settings/
trunk/ws/plugins/org.jboss.tools.ws.creation.core/.settings/org.eclipse.jdt.core.prefs
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java
Removed:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/.classpath
trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
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/WSDL2JavaCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java
Log:
JBIDE-3783:can't generate WS from a java class in the java project not dynamic web
project
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/.classpath
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/.classpath 2009-04-16 07:47:06 UTC
(rev 14766)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/.classpath 2009-04-16 07:48:52 UTC
(rev 14767)
@@ -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>
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/.settings/org.eclipse.jdt.core.prefs 2009-04-16
07:48:52 UTC (rev 14767)
@@ -0,0 +1,7 @@
+#Tue Mar 03 14:01:40 CST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2009-04-16
07:47:06 UTC (rev 14766)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2009-04-16
07:48:52 UTC (rev 14767)
@@ -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:
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-04-16
07:47:06 UTC (rev 14766)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2009-04-16
07:48:52 UTC (rev 14767)
@@ -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;
@@ -54,12 +57,17 @@
.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 +79,18 @@
new String[] { path.toOSString() }));
}
- String args = getCommandlineArgs();
- command.append(" -k ").append(args).append(" ");
+ command.add("-k");
+ addCommandlineArgs(command);
if(model.getWsdlURI() != null){
- command.append(model.getWsdlURI());
+ command.add(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));
+
+ command.add("-o");
+ StringBuffer opDir = new StringBuffer();
+ opDir.append(projectRoot).append(Path.SEPARATOR).append(javaProject.getOutputLocation().removeFirstSegments(1).toOSString());
+ command.add(opDir.toString());
+
+ Process proc = DebugPlugin.exec(command.toArray(new String[command.size()]), new
File(commandLocation));
StringBuffer errorResult = new StringBuffer();
StringBuffer inputResult = new StringBuffer();
@@ -107,15 +115,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);
@@ -160,7 +169,7 @@
}
}
- abstract protected String getCommandlineArgs();
+ abstract protected void addCommandlineArgs(List<String> command) throws
Exception;
abstract protected String getCommandLineFileName_linux();
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/Java2WSCommand.java 2009-04-16
07:48:52 UTC (rev 14767)
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * 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);
+
+ command.add("-s");
+ command.add(projectRoot + Path.SEPARATOR + "src");
+
+ 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
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSDL2JavaCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSDL2JavaCommand.java 2009-04-16
07:47:06 UTC (rev 14766)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSDL2JavaCommand.java 2009-04-16
07:48:52 UTC (rev 14767)
@@ -26,39 +26,41 @@
protected String getCommandLineFileName_win() {
return WSCONSUEM_FILE_NAME_WIN;
}
-
+
@Override
- protected String getCommandlineArgs() {
- String commandLine;
+ protected void addCommandlineArgs(List<String> command) {
String project = model.getWebProjectName();
String projectRoot = JBossWSCreationUtils.getProjectRoot(project).toOSString();
- commandLine = "-s " + projectRoot + Path.SEPARATOR + "src";
+ command.add("-s");
+ command.add(projectRoot + Path.SEPARATOR + "src");
+
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:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java 2009-04-16
07:47:06 UTC (rev 14766)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java 2009-04-16
07:48:52 UTC (rev 14767)
@@ -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:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/ClasspathParser.java 2009-04-16
07:48:52 UTC (rev 14767)
@@ -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();
+ }
+}
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml 2009-04-16 07:47:06 UTC
(rev 14766)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml 2009-04-16 07:48:52 UTC
(rev 14767)
@@ -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:
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java 2009-04-16
07:47:06 UTC (rev 14766)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java 2009-04-16
07:48:52 UTC (rev 14767)
@@ -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)));
}