[429710] The cxf-beans.xml file is not filled properly.
diff --git a/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/SpringUtils.java b/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/SpringUtils.java
index 8926f06..59ee2f1 100644
--- a/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/SpringUtils.java
+++ b/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/SpringUtils.java
@@ -190,6 +190,22 @@
}
@SuppressWarnings("unchecked")
+ private static Element getElement(Document doc, String elementName, Namespace namespace, String id) throws IOException {
+ Element beans = doc.getRootElement();
+ List<Element> endpoints = beans.getChildren(elementName, namespace);
+ for (Element element : endpoints) {
+ if (element != null && element.getAttribute("id") != null) { //$NON-NLS-1$
+ Attribute idAttribute = element.getAttribute("id"); //$NON-NLS-1$
+ if (idAttribute.getValue().equals(id)) {
+ return element;
+ }
+ }
+ }
+ return null;
+ }
+
+ /*
+ @SuppressWarnings("unchecked")
private static boolean isBeanDefined(CXFDataModel cxfDataModel, String projectName, String elementName,
Namespace namespace, String id) throws IOException {
IFile springConfigFile = null;
@@ -225,7 +241,8 @@
}
return false;
}
-
+ */
+
@SuppressWarnings("unchecked")
public static String getEndpointAddress(IProject project, String jaxwsEndpointId) throws IOException {
IFile springConfigFile = null;
@@ -357,46 +374,64 @@
.toFile());
try {
Document doc = builder.build(springConfigInputSteam);
- Element beans = doc.getRootElement();
-
- Element jaxwsEndpoint = new Element("endpoint", JAXWS_NS); //$NON-NLS-1$
-
String id = getJAXWSEndpointID(model);
- model.setConfigId(id);
- jaxwsEndpoint.setAttribute("id", id); //$NON-NLS-1$
- jaxwsEndpoint.setAttribute("implementor", model.getFullyQualifiedJavaClassName()); //$NON-NLS-1$
+ Element element = getElement(doc, "endpoint", JAXWS_NS, id);
+ if (element != null) {
+ Namespace tns = null;
+ for (Object ns : element.getAdditionalNamespaces()) {
+ Namespace namespace = (Namespace) ns;
+ if (namespace.getPrefix().equals("tns") && !namespace.getURI().equals(model.getTargetNamespace())) {
+ tns = namespace;
+ }
+ }
+ if (tns != null) {
+ element.removeNamespaceDeclaration(tns);
+
+ tns = Namespace.getNamespace("tns", model.getTargetNamespace()); //$NON-NLS-1$
+ element.addNamespaceDeclaration(tns);
+
+ writeConfig(doc, springConfigFile);
+ }
+
+ } else {
+ Element beans = doc.getRootElement();
- if (model.getConfigWsdlLocation() != null) {
- jaxwsEndpoint.setAttribute("wsdlLocation", model.getConfigWsdlLocation()); //$NON-NLS-1$
+ Element jaxwsEndpoint = new Element("endpoint", JAXWS_NS); //$NON-NLS-1$
- if (model.getEndpointName() != null && model.getServiceName() != null) {
- jaxwsEndpoint.setAttribute("endpointName", "tns:" + model.getEndpointName()); //$NON-NLS-1$ //$NON-NLS-2$
- jaxwsEndpoint.setAttribute("serviceName", "tns:" + model.getServiceName()); //$NON-NLS-1$ //$NON-NLS-2$
+ model.setConfigId(id);
+ jaxwsEndpoint.setAttribute("id", id); //$NON-NLS-1$
- Namespace XMLNS_TNS = Namespace.getNamespace("tns", model.getTargetNamespace()); //$NON-NLS-1$
- jaxwsEndpoint.addNamespaceDeclaration(XMLNS_TNS);
+ jaxwsEndpoint.setAttribute("implementor", model.getFullyQualifiedJavaClassName()); //$NON-NLS-1$
+
+ if (model.getConfigWsdlLocation() != null) {
+ jaxwsEndpoint.setAttribute("wsdlLocation", model.getConfigWsdlLocation()); //$NON-NLS-1$
+
+ if (model.getEndpointName() != null && model.getServiceName() != null) {
+ jaxwsEndpoint.setAttribute("endpointName", "tns:" + model.getEndpointName()); //$NON-NLS-1$ //$NON-NLS-2$
+ jaxwsEndpoint.setAttribute("serviceName", "tns:" + model.getServiceName()); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Namespace XMLNS_TNS = Namespace.getNamespace("tns", model.getTargetNamespace()); //$NON-NLS-1$
+ jaxwsEndpoint.addNamespaceDeclaration(XMLNS_TNS);
+ }
}
- }
- if (model.getEndpointName() != null) {
- jaxwsEndpoint.setAttribute("address", "/" + model.getEndpointName()); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- jaxwsEndpoint.setAttribute("address", "/" + id); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ if (model.getEndpointName() != null) {
+ jaxwsEndpoint.setAttribute("address", "/" + model.getEndpointName()); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ jaxwsEndpoint.setAttribute("address", "/" + id); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ Element jaxwsFeatures = new Element("features", JAXWS_NS); //$NON-NLS-1$
+ Element bean = new Element("bean", SPRING_BEANS_NS); //$NON-NLS-1$
+ bean.setAttribute("class", "org.apache.cxf.feature.LoggingFeature"); //$NON-NLS-1$ //$NON-NLS-2$
+ jaxwsFeatures.addContent(bean);
+ jaxwsEndpoint.addContent(jaxwsFeatures);
- Element jaxwsFeatures = new Element("features", JAXWS_NS); //$NON-NLS-1$
- Element bean = new Element("bean", SPRING_BEANS_NS); //$NON-NLS-1$
- bean.setAttribute("class", "org.apache.cxf.feature.LoggingFeature"); //$NON-NLS-1$ //$NON-NLS-2$
- jaxwsFeatures.addContent(bean);
- jaxwsEndpoint.addContent(jaxwsFeatures);
-
- if (!isBeanDefined(model, projectName, "endpoint", JAXWS_NS, id)) { //$NON-NLS-1$
beans.addContent(jaxwsEndpoint);
writeConfig(doc, springConfigFile);
- }
+ }
} catch (JDOMException jdome) {
CXFCorePlugin.log(jdome);
} finally {
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.jst.ws.cxf.creation.core/META-INF/MANIFEST.MF
index d5d7ad9..9139793 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.core/META-INF/MANIFEST.MF
@@ -28,7 +28,9 @@
org.eclipse.emf.ecore;bundle-version="[2.4.0,3.0.0)",
org.eclipse.jem;bundle-version="[2.0.0,2.1.0)",
org.eclipse.wst.command.env;bundle-version="[1.0.305,1.1.0)",
- org.eclipse.jst.jee;bundle-version="[1.0.100,1.1.0)"
+ org.eclipse.jst.jee;bundle-version="[1.0.100,1.1.0)",
+ org.eclipse.jdt.apt.core;bundle-version="[3.3.100,4.0.0)",
+ javax.jws;bundle-version="[2.0.0,2.1.0)"
Bundle-ActivationPolicy: lazy
Ant-Version: Apache Ant 1.7.0
Created-By: 1.5.0_14-b03 (Sun Microsystems Inc.)
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSCommand.java b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSCommand.java
index 84491f9..822c9d3 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSCommand.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSCommand.java
@@ -27,6 +27,9 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
import org.eclipse.jst.ws.internal.cxf.core.CXFCorePlugin;
import org.eclipse.jst.ws.internal.cxf.core.context.Java2WSPersistentContext;
import org.eclipse.jst.ws.internal.cxf.core.model.CXFDataModel;
@@ -38,6 +41,7 @@
import org.eclipse.jst.ws.internal.cxf.core.utils.LaunchUtils;
import org.eclipse.jst.ws.internal.cxf.core.utils.SpringUtils;
import org.eclipse.jst.ws.internal.cxf.creation.core.CXFCreationCorePlugin;
+import org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils;
import org.eclipse.jst.ws.jaxws.core.utils.JDTUtils;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
@@ -95,6 +99,7 @@
}
if (isImplementationSelected() || isGenerateServer()) {
+ model.setTargetNamespace(getTargetNamespace(startingPoint));
SpringUtils.createJAXWSEndpoint(model);
}
@@ -112,6 +117,36 @@
return status;
}
+
+ private String getTargetNamespace(IType type) throws JavaModelException {
+ if (type.isClass()) {
+ IType sei = findServiceEndpointInterface(type);
+ if (sei != null) {
+ return findTargetNamespace(sei);
+ }
+ }
+ return findTargetNamespace(type);
+ }
+
+ private IType findServiceEndpointInterface(IType type) {
+ Annotation wsa = AnnotationUtils.getAnnotation(type, javax.jws.WebService.class);
+ if (wsa != null) {
+ String sei = AnnotationUtils.getStringValue(wsa, JAXWSUtils.ENDPOINT_INTERFACE);
+ if (sei != null) {
+ return JDTUtils.findType(type.getJavaProject(), sei);
+ }
+ }
+ return null;
+ }
+
+ private String findTargetNamespace(IType type) {
+ Annotation wsa = AnnotationUtils.getAnnotation(type, javax.jws.WebService.class);
+ if (wsa != null) {
+ return AnnotationUtils.getStringValue(wsa, JAXWSUtils.TARGET_NAMESPACE);
+ }
+
+ return JDTUtils.getTargetNamespaceFromPackageName(type.getPackageFragment().getElementName());
+ }
private boolean isImplementationSelected() {
return model.getFullyQualifiedJavaClassName() != null &&
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSDefaultingCommand.java b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSDefaultingCommand.java
index 3587317..34b571f 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSDefaultingCommand.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSDefaultingCommand.java
@@ -47,9 +47,6 @@
model.setUseServiceEndpointInterface(startingPointType.isInterface());
model.setExtractInterface(false);
- String packageName = startingPointType.getPackageFragment().getElementName();
- model.setTargetNamespace(JDTUtils.getTargetNamespaceFromPackageName(packageName));
-
model.setAnnotationProcessingEnabled(context.isAnnotationProcessingEnabled());
model.setGenerateWebMethodAnnotation(context.isGenerateWebMethodAnnotation());
model.setGenerateWebParamAnnotation(context.isGenerateWebParamAnnotation());
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.jst.ws.jaxws.core/META-INF/MANIFEST.MF
index 4fa2698..faf5d8f 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/META-INF/MANIFEST.MF
@@ -23,7 +23,7 @@
org.eclipse.wst.common.modulecore;bundle-version="[1.1.0,1.3.0)"
Export-Package: org.eclipse.jst.ws.internal.jaxws.core;x-friends:="org.eclipse.jst.ws.jaxws.core.tests,org.eclipse.jst.ws.jaxws.ui,org.eclipse.jst.ws.jaxws.dom.runtime.tests",
org.eclipse.jst.ws.internal.jaxws.core.annotations.validation;x-friends:="org.eclipse.jst.ws.annotations.core",
- org.eclipse.jst.ws.internal.jaxws.core.utils;x-friends:="org.eclipse.jst.ws.jaxws.ui",
+ org.eclipse.jst.ws.internal.jaxws.core.utils;x-friends:="org.eclipse.jst.ws.jaxws.ui,org.eclipse.jst.ws.cxf.creation.core",
org.eclipse.jst.ws.jaxws.core.utils
Import-Package: javax.activation,
javax.jws,