Author: Grid.Qian
Date: 2008-05-14 06:34:00 -0400 (Wed, 14 May 2008)
New Revision: 8073
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/MergeWebXMLCommand.java
Modified:
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/messages/JBossWSCreationCore.properties
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java
Log:
JBIDE-2047: modify for merging web.xml
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 2008-05-14
02:47:59 UTC (rev 8072)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2008-05-14
10:34:00 UTC (rev 8073)
@@ -18,7 +18,11 @@
org.eclipse.wst.command.env,
org.eclipse.jst.ws.axis2.consumption.core,
org.apache.ant,
- org.apache.xerces
+ org.apache.xerces,
+ org.eclipse.jst.j2ee,
+ org.eclipse.jst.j2ee.core,
+ org.eclipse.emf.common,
+ org.eclipse.emf.ecore
Eclipse-LazyStart: true
Export-Package: org.jboss.tools.ws.creation.core,
org.jboss.tools.ws.creation.core.commands,
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/MergeWebXMLCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/MergeWebXMLCommand.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/MergeWebXMLCommand.java 2008-05-14
10:34:00 UTC (rev 8073)
@@ -0,0 +1,116 @@
+package org.jboss.tools.ws.creation.core.commands;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jst.j2ee.model.IModelProvider;
+import org.eclipse.jst.j2ee.model.ModelProviderManager;
+import org.eclipse.jst.javaee.core.DisplayName;
+import org.eclipse.jst.javaee.core.JavaeeFactory;
+import org.eclipse.jst.javaee.core.UrlPatternType;
+import org.eclipse.jst.javaee.web.Servlet;
+import org.eclipse.jst.javaee.web.ServletMapping;
+import org.eclipse.jst.javaee.web.WebApp;
+import org.eclipse.jst.javaee.web.WebFactory;
+import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
+import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
+
+public class MergeWebXMLCommand extends AbstractDataModelOperation {
+
+ private ServiceModel model;
+
+ public MergeWebXMLCommand(ServiceModel model) {
+ this.model = model;
+ }
+
+ @Override
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ IEnvironment environment = getEnvironment();
+ IStatus status = null;
+ status = mergeWebXML(getAxisServletDescriptor());
+ if (status.getSeverity() == Status.ERROR) {
+ environment.getStatusHandler().reportError(status);
+ return status;
+ }
+ return Status.OK_STATUS;
+ }
+
+ private IStatus mergeWebXML(final ServletDescriptor servletDescriptor) {
+ IStatus status = Status.OK_STATUS;
+ final IModelProvider provider = ModelProviderManager
+ .getModelProvider(JBossWSCreationUtils.getProjectByName(model
+ .getWebProjectName()));
+ provider.modify(new Runnable() {
+ public void run() {
+ Object object = provider.getModelObject();
+ if (object instanceof org.eclipse.jst.javaee.web.WebApp) {
+ WebApp webApp = (WebApp) object;
+ addServlet(JBossWSCreationUtils.getProjectByName(model
+ .getWebProjectName()), servletDescriptor, webApp);
+ }
+ }
+
+ }, null);
+ return status;
+ }
+
+ private ServletDescriptor getAxisServletDescriptor() {
+
+ ServletDescriptor sd = new ServletDescriptor();
+ sd._name = JBossWSCreationUtils.classNameFromQualifiedName(model
+ .getServiceClass());
+ sd._displayName = sd._name;
+ sd._className = model.getServiceClass();
+ sd._mappings = JBossWSCreationCoreMessages.SEPARATOR_JAVA + sd._name;
+ return sd;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void addServlet(IProject webProject,
+ ServletDescriptor servletDescriptor, WebApp webapp) {
+ List theServlets = webapp.getServlets();
+ for (int i = 0; i < theServlets.size(); i++) {
+ Servlet aServlet = (Servlet) theServlets.get(i);
+ if (aServlet.getServletName().equals(servletDescriptor._name)) {
+ return;
+ }
+ }
+ WebFactory factory = WebFactory.eINSTANCE;
+ Servlet servlet = factory.createServlet();
+ servlet.setServletName(servletDescriptor._name);
+ servlet.setServletClass(servletDescriptor._className);
+ if (servletDescriptor._displayName != null) {
+ DisplayName displayNameObj = JavaeeFactory.eINSTANCE
+ .createDisplayName();
+ displayNameObj.setValue(servletDescriptor._displayName);
+ servlet.getDisplayNames().add(displayNameObj);
+ }
+ webapp.getServlets().add(servlet);
+
+ if (servletDescriptor._mappings != null) {
+ ServletMapping servletMapping = factory.createServletMapping();
+ servletMapping.setServletName(servlet.getServletName());
+ UrlPatternType url = JavaeeFactory.eINSTANCE.createUrlPatternType();
+ url.setValue(servletDescriptor._mappings);
+ servletMapping.getUrlPatterns().add(url);
+ webapp.getServletMappings().add(servletMapping);
+ }
+ }
+
+ public class ServletDescriptor {
+ String _name;
+ String _className;
+ String _displayName;
+ String _mappings;
+ }
+
+}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2008-05-14
02:47:59 UTC (rev 8072)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2008-05-14
10:34:00 UTC (rev 8073)
@@ -9,3 +9,4 @@
ERROR_MESSAGE_INVALID_BINDING_FILE={0} is not a valid JAX-WS or JAXB binding file
ERROR_READ_BINDING_FILE=Exception occurred while reading binding file
+SEPARATOR_JAVA=/
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2008-05-14
02:47:59 UTC (rev 8072)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2008-05-14
10:34:00 UTC (rev 8073)
@@ -16,6 +16,7 @@
public static String ERROR_MESSAGE_INVALID_BINDING_FILE;
public static String ERROR_READ_BINDING_FILE;
+ public static String SEPARATOR_JAVA;
private JBossWSCreationCoreMessages() {
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2008-05-14
02:47:59 UTC (rev 8072)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2008-05-14
10:34:00 UTC (rev 8073)
@@ -152,9 +152,17 @@
}
}
+ 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];
+ }
-
}
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 2008-05-14
02:47:59 UTC (rev 8072)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java 2008-05-14
10:34:00 UTC (rev 8073)
@@ -12,6 +12,7 @@
import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
import org.jboss.tools.ws.creation.core.commands.BindingFilesValidationCommand;
import org.jboss.tools.ws.creation.core.commands.InitialCommand;
+import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
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;
@@ -53,6 +54,7 @@
else if (ctx.getScenario().getValue() == WebServiceScenario.BOTTOMUP){
commands.add(new InitialCommand(model, this, WebServiceScenario.BOTTOMUP));
commands.add(new WSProviderInvokeCommand(model));
+ commands.add(new MergeWebXMLCommand(model));
//commands.add(new
JbossWSRuntimeCommand(ResourcesPlugin.getWorkspace().getRoot().getProject(project)));
}
Show replies by date