### Eclipse Workspace Patch 1.0
#P org.jboss.tools.ws.creation.ui
Index: src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java
===================================================================
--- src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java	(revision 20434)
+++ src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java	(working copy)
@@ -1,3 +1,13 @@
+/******************************************************************************* 
+ * Copyright (c) 2010 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.ui.wsrt;
 
 import java.util.Vector;
@@ -5,6 +15,7 @@
 import org.eclipse.wst.command.internal.env.core.ICommandFactory;
 import org.eclipse.wst.command.internal.env.core.SimpleCommandFactory;
 import org.eclipse.wst.common.environment.IEnvironment;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
 import org.eclipse.wst.ws.internal.wsrt.AbstractWebService;
 import org.eclipse.wst.ws.internal.wsrt.IContext;
 import org.eclipse.wst.ws.internal.wsrt.ISelection;
@@ -10,6 +21,7 @@
 import org.eclipse.wst.ws.internal.wsrt.ISelection;
 import org.eclipse.wst.ws.internal.wsrt.WebServiceInfo;
 import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
+import org.jboss.tools.ws.creation.core.commands.AddApplicationXMLCommand;
 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;
@@ -19,6 +31,10 @@
 import org.jboss.tools.ws.creation.core.commands.WSDL2JavaCommand;
 import org.jboss.tools.ws.creation.core.data.ServiceModel;
 
+/**
+ * @author Grid Qian
+ */
+@SuppressWarnings("restriction")
 public class JBossWebService extends AbstractWebService {
 
 	public JBossWebService(WebServiceInfo info){
@@ -28,8 +44,9 @@
 	@Override
 	public ICommandFactory assemble(IEnvironment env, IContext ctx,
 			ISelection sel, String project, String earProject) {
-		// TODO Auto-generated method stub
-		return null;
+		Vector<AbstractDataModelOperation> commands = new Vector<AbstractDataModelOperation>();
+		commands.add(new AddApplicationXMLCommand(earProject));
+		return new SimpleCommandFactory(commands);
 	}
 
 	@Override
@@ -35,11 +52,10 @@
 	@Override
 	public ICommandFactory deploy(IEnvironment env, IContext ctx,
 			ISelection sel, String project, String earProject) {
-		// TODO Auto-generated method stub
 		return null;
 	}
 
-	@SuppressWarnings({ "restriction", "unchecked" })
+	@SuppressWarnings({ "unchecked" })
 	@Override
 	public ICommandFactory develop(IEnvironment env, IContext ctx,
 			ISelection sel, String project, String earProject) {
@@ -68,7 +84,6 @@
 	@Override
 	public ICommandFactory install(IEnvironment env, IContext ctx,
 			ISelection sel, String project, String earProject) {
-		// TODO Auto-generated method stub
 		return null;
 	}
 
@@ -75,7 +90,6 @@
 	@Override
 	public ICommandFactory run(IEnvironment env, IContext ctx, ISelection sel,
 			String project, String earProject) {
-		// TODO Auto-generated method stub
 		return null;
 	}
 
Index: src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebServiceClient.java
===================================================================
--- src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebServiceClient.java	(revision 20434)
+++ src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebServiceClient.java	(working copy)
@@ -1,5 +1,5 @@
 /******************************************************************************* 
- * Copyright (c) 2008 Red Hat, Inc. 
+ * Copyright (c) 2008, 2010 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, 
@@ -33,9 +33,9 @@
 /**
  * @author Grid Qian
  */
+@SuppressWarnings({ "restriction", "unused" })
 public class JBossWebServiceClient extends AbstractWebServiceClient {
 
-	@SuppressWarnings("restriction")
 	public JBossWebServiceClient(WebServiceClientInfo info) {
 		super(info);
 	}
@@ -52,7 +52,7 @@
 
 	public ICommandFactory develop(IEnvironment env, IContext ctx,
 			ISelection sel, String project, String earProject) {
-		Vector<AbstractDataModelOperation> commands = new Vector();
+		Vector<AbstractDataModelOperation> commands = new Vector<AbstractDataModelOperation>();
 		ServiceModel model = new ServiceModel();
 		model.setWebProjectName(project);
 		commands.add(new InitialClientCommand(model, this, WebServiceScenario.CLIENT));
@@ -71,7 +71,6 @@
 	@Override
 	public ICommandFactory install(IEnvironment env, IContext ctx,
 			ISelection sel, String project, String earProject) {
-		// TODO Auto-generated method stub
 		return null;
 	}
 
#P org.jboss.tools.ws.creation.core
Index: META-INF/MANIFEST.MF
===================================================================
--- META-INF/MANIFEST.MF	(revision 20434)
+++ META-INF/MANIFEST.MF	(working copy)
@@ -19,6 +19,7 @@
  org.apache.xerces,
  org.eclipse.jst.j2ee;visibility:=reexport,
  org.eclipse.jst.j2ee.core;visibility:=reexport,
+ org.eclipse.jst.jee,
  org.eclipse.emf.common,
  org.eclipse.emf.ecore,
  org.eclipse.jdt.core,
@@ -28,11 +29,12 @@
  org.eclipse.wst.common.project.facet.core,
  org.eclipse.wst.server.core,
  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.launching;bundle-version="3.4.0",
- org.eclipse.debug.core;bundle-version="3.4.0"
+ org.jboss.ide.eclipse.as.classpath.core,
+ org.eclipse.jst.server.core,
+ org.eclipse.jdt,
+ org.eclipse.jdt.launching,
+ org.eclipse.debug.core,
+ org.eclipse.jst.jee.web
 Bundle-ActivationPolicy: lazy
 Export-Package: org.jboss.tools.ws.creation.core,
  org.jboss.tools.ws.creation.core.commands,
Index: src/org/jboss/tools/ws/creation/core/commands/AddApplicationXMLCommand.java
===================================================================
--- src/org/jboss/tools/ws/creation/core/commands/AddApplicationXMLCommand.java	(revision 0)
+++ src/org/jboss/tools/ws/creation/core/commands/AddApplicationXMLCommand.java	(revision 0)
@@ -0,0 +1,98 @@
+/******************************************************************************* 
+ * Copyright (c) 2010 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 org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jst.jee.project.facet.EarCreateDeploymentFilesDataModelProvider;
+import org.eclipse.jst.jee.project.facet.ICreateDeploymentFilesDataModelProperties;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+
+/**
+ * @author Grid Qian
+ */
+public class AddApplicationXMLCommand extends AbstractDataModelOperation {
+
+	private String earProject;
+	IStatus status;
+	
+	private static String APPLICATION_XML = "application.xml"; //$NON-NLS-1$
+	
+	public AddApplicationXMLCommand(String earProject){
+		this.earProject = earProject;
+	}
+
+	@Override
+	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+			throws ExecutionException {
+		status = Status.OK_STATUS;
+		IProject pro = ResourcesPlugin.getWorkspace().getRoot().getProject(earProject);
+		
+		// we only are concerned with creating the application.xml if it doesn't exist.
+		// the WTP code updates any existing application.xml appropriately if it finds it.
+		if(!hasApplicationXML(pro)){
+			IVirtualComponent vc = ComponentCore.createComponent(pro);
+			IDataModel model = DataModelFactory.createDataModel(new EarCreateDeploymentFilesDataModelProvider());
+			model.setProperty(ICreateDeploymentFilesDataModelProperties.GENERATE_DD, vc);
+			model.setProperty(ICreateDeploymentFilesDataModelProperties.TARGET_PROJECT, pro);
+			IDataModelOperation op = model.getDefaultOperation();
+			try {
+				op.execute(new NullProgressMonitor(), null);
+			} catch (ExecutionException e1) {
+				// Ignore
+			}	
+		}
+		return status;
+	}
+
+	private boolean hasApplicationXML(IProject pro) {
+		// we are looking for this recursively because though application.xml
+		// is always in META-INF, it's not always in "earcontent" since the
+		// earcontent folder name can be custom
+		File file = findFileByPath(APPLICATION_XML, pro.getLocation().toOSString());
+        if(file == null){
+        	return false;
+        }
+		return true;
+	}
+
+	private static File findFileByPath(String name, String path) {
+		File ret = null;
+		File folder = new File(path);
+		if (folder.isDirectory()) {
+			File[] files = folder.listFiles();
+			for (File file : files) {
+				ret = findFileByPath(name, file.getAbsolutePath());
+				if (ret != null) {
+					break;
+				}
+			}
+		} else {
+			if (name.equals(folder.getName())) {
+				ret = folder;
+			}
+		}
+		return ret;
+	}
+}
