### Eclipse Workspace Patch 1.0
#P org.jboss.tools.esb.project.core
Index: src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java
===================================================================
--- src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java	(revision 16969)
+++ src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java	(working copy)
@@ -14,41 +14,42 @@
 import java.util.List;
 
 import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
 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.server.core.IModule;
 import org.eclipse.wst.server.core.model.IModuleResource;
-import org.eclipse.wst.server.core.util.ModuleFile;
-import org.eclipse.wst.server.core.util.ModuleFolder;
-import org.eclipse.wst.server.core.util.ProjectModule;
+import org.jboss.ide.eclipse.as.wtp.core.modules.IJBTModule;
+import org.jboss.ide.eclipse.as.wtp.core.modules.JBTProjectModuleDelegate;
 import org.jboss.tools.esb.core.StatusUtils;
+import org.jboss.tools.esb.core.facet.IJBossESBFacetDataModelProperties;
 
-public class JBossESBModuleDelegate extends ProjectModule {
+public class JBossESBModuleDelegate extends JBTProjectModuleDelegate implements IJBTModule {
 
 	public JBossESBModuleDelegate(IProject project){
 		super(project);
 	}
-	@Override
-	public IModule[] getChildModules() {
-		return null;
-	}
 
 	public IModuleResource[] members() throws CoreException {
+		IProject p = getProject();
+		String prop =p.getPersistentProperty(IJBossESBFacetDataModelProperties.QNAME_ESB_PROJECT_VERSION); 
+		if( prop != null && Float.parseFloat(prop) > 2)
+			return super.members();
+		return legacyMembers();
+	}
+	
+	public IModuleResource[] legacyMembers() throws CoreException {
 		IProject project = getProject();
 		final IVirtualComponent c = ComponentCore.createComponent(project);
 		IVirtualFolder vf = c.getRootFolder();
 		IContainer[] folders = vf.getUnderlyingFolders();
+
 		if(folders == null || folders.length == 0){
 			throw new CoreException(StatusUtils.errorStatus("The project is not a valid JBoss ESB project."));
 		}
@@ -57,8 +58,8 @@
 		//in the JBT CR1, the length of folders will be 1.
 		IContainer contentFolder = folders.length > 1? folders[1] : folders[0];
 		
-		IFolder configFolder = project.getFolder(contentFolder.getProjectRelativePath());
-		IJavaProject javaPrj = JavaCore.create(project);
+		IFolder configFolder = getProject().getFolder(contentFolder.getProjectRelativePath());
+		IJavaProject javaPrj = JavaCore.create(getProject());
 		IPath output = javaPrj.getOutputLocation();		
 		// if the jboss-esb.xml file is not in META-INF folder, try to get it from other folder of the project
 		// block this logic as Max's suggestion
@@ -67,7 +68,7 @@
 		List<IModuleResource> mrs = new ArrayList<IModuleResource>();
 		
 		IModuleResource[] esbContent = getModuleResources(Path.EMPTY, configFolder);
-		IModuleResource[] classes = getModuleResources(Path.EMPTY, project.getWorkspace().getRoot().getFolder(output));
+		IModuleResource[] classes = getModuleResources(Path.EMPTY, getProject().getWorkspace().getRoot().getFolder(output));
 		IModuleResource[] allResource = new IModuleResource[esbContent.length + classes.length + mrs.size()];
 		System.arraycopy(esbContent, 0, allResource, 0, esbContent.length);
 		System.arraycopy(classes, 0, allResource, esbContent.length, classes.length);
@@ -77,40 +78,9 @@
 		}
 		return allResource;
 	}
-	 
-	
-	
-	@Override
-	public IStatus validate() {
-		return null;
-	}
 
 	@Override
-	protected IModuleResource[] getModuleResources(IPath path, IContainer container) throws CoreException {
-		
-		IResource[] resources = container.members();
-		if (resources != null) {
-			int size = resources.length;
-			List<IModuleResource> list = new ArrayList<IModuleResource>(size);
-			for (int i = 0; i < size; i++) {
-				IResource resource = resources[i];
-				if (resource != null && resource.exists()) {
-					String name = resource.getName();
-					if (resource instanceof IContainer) {
-						IContainer container2 = (IContainer) resource;
-						ModuleFolder mf = new ModuleFolder(container2, name, path);
-						mf.setMembers(getModuleResources(path.append(name), container2));
-						list.add(mf);
-					} else if (resource instanceof IFile) {
-						list.add(new ModuleFile((IFile) resource, name, path));
-					}
-				}
-			}
-			IModuleResource[] moduleResources = new IModuleResource[list.size()];
-			list.toArray(moduleResources);
-			return moduleResources;
-		}
-		return new IModuleResource[0];
+	protected String getFactoryId() {
+		return JBossESBModuleFactory.FACTORY_ID;
 	}
-	 
 }
Index: src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java
===================================================================
--- src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java	(revision 16571)
+++ src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java	(working copy)
@@ -11,7 +11,6 @@
 package org.jboss.tools.esb.core.facet;
 
 import java.io.ByteArrayInputStream;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
 import org.eclipse.core.resources.IFile;
@@ -45,12 +44,11 @@
 	public void execute(IProject project, IProjectFacetVersion fv,
 			Object config, IProgressMonitor monitor) throws CoreException {
 		model = (IDataModel) config;
+		final IJavaProject jproj = JavaCore.create(project);
 
 		createProjectStructure(project);
-		
-		
-		final IJavaProject jproj = JavaCore.create(project);
 
+		
 		// Add WTP natures.
 		WtpUtils.addNatures(project);
 
@@ -62,31 +60,26 @@
 		} catch (Exception e) {
 			c = ComponentCore.createComponent(project);
 		}
-		
-		
+
+		String outputLoc = jproj.readOutputLocation().removeFirstSegments(1).toString();
 		c.create(0, null);
-		//String esbContent = model.getStringProperty(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
-		c.setMetaProperty("java-output-path", "/build/classes/");
+		c.setMetaProperty("java-output-path", outputLoc);
 
 		final IVirtualFolder jbiRoot = c.getRootFolder();
 
-		// Create directory structure
-		/*String srcFolder = null;
-		srcFolder = model
-				.getStringProperty(IJBossESBFacetDataModelProperties.ESB_SOURCE_FOLDER);
-		jbiRoot.createLink(new Path("/" + srcFolder), 0, null);*/
-		String resourcesFolder = model
-				.getStringProperty(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
+		// Map the esbcontent to root for deploy
+		String resourcesFolder = model.getStringProperty(
+				IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
 		jbiRoot.createLink(new Path("/" + resourcesFolder), 0, null);
 		
 		
-		final IVirtualFolder jsrc = c.getRootFolder().getFolder("/esbcontent"); //$NON-NLS-1$
-		final IClasspathEntry[] cp = jproj.getRawClasspath();
-		for (int i = 0; i < cp.length; i++) {
-			final IClasspathEntry cpe = cp[i];
+		final IVirtualFolder jsrc = c.getRootFolder().getFolder("/"); //$NON-NLS-1$
+		final IClasspathEntry[] cp2 = jproj.getRawClasspath();
+		for (int i = 0; i < cp2.length; i++) {
+			final IClasspathEntry cpe = cp2[i];
 			if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
 				if( cpe.getPath().removeFirstSegments(1).segmentCount() > 0 )
-					jsrc.createLink(cpe.getPath().removeFirstSegments(1), 0, null);
+					jsrc.createLink(new Path(outputLoc), 0, null);
 			}
 		}
 		
@@ -102,11 +95,6 @@
 		
 		ClasspathHelper.removeClasspathEntries(project, fv);
 		ClasspathHelper.addClasspathEntries(project, fv);
-		
-		//String prjName = model.getStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME);
-		//IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(prjName);
-		
-
 	}
 	
 	private IFile createJBossESBXML(IFolder folder) throws CoreException{
@@ -126,6 +114,7 @@
 	private void createProjectStructure(IProject project) throws CoreException{
 		String strContentFolder = model.getStringProperty(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
 		project.setPersistentProperty(IJBossESBFacetDataModelProperties.QNAME_ESB_CONTENT_FOLDER, strContentFolder);
+		project.setPersistentProperty(IJBossESBFacetDataModelProperties.QNAME_ESB_PROJECT_VERSION, "2.0");
 		IFolder esbContent = project.getFolder(strContentFolder);
 		if(!esbContent.exists()) {
 			esbContent.create(true, true, null);			
Index: src/org/jboss/tools/esb/core/component/ESBVirtualComponent.java
===================================================================
--- src/org/jboss/tools/esb/core/component/ESBVirtualComponent.java	(revision 0)
+++ src/org/jboss/tools/esb/core/component/ESBVirtualComponent.java	(revision 0)
@@ -0,0 +1,7 @@
+package org.jboss.tools.esb.core.component;
+
+import org.jboss.ide.eclipse.as.wtp.core.vcf.JBTVirtualComponent;
+
+public class ESBVirtualComponent extends JBTVirtualComponent {
+
+}
Index: src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java
===================================================================
--- src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java	(revision 16969)
+++ src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java	(working copy)
@@ -10,92 +10,29 @@
  ******************************************************************************/
 package org.jboss.tools.esb.core.module;
 
-import java.util.HashMap;
-
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.internal.ModuleFactory;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
-import org.eclipse.wst.server.core.model.ModuleDelegate;
-import org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate;
+import org.jboss.ide.eclipse.as.wtp.core.modules.JBTProjectModuleDelegate;
+import org.jboss.ide.eclipse.as.wtp.core.modules.JBTProjectModuleFactory;
 import org.jboss.tools.esb.core.ESBProjectConstant;
-import org.jboss.tools.esb.core.ESBProjectCorePlugin;
 import org.jboss.tools.esb.core.facet.IJBossESBFacetDataModelProperties;
 
-public class JBossESBModuleFactory extends ProjectModuleFactoryDelegate {
+public class JBossESBModuleFactory extends JBTProjectModuleFactory {
 	public static final String FACTORY_ID = "org.jboss.tools.esb.project.core.moduleFactory";
 	public static final String MODULE_TYPE = IJBossESBFacetDataModelProperties.JBOSS_ESB_FACET_ID;
-	public static final String MODULE_ID_PREFIX = IJBossESBFacetDataModelProperties.JBOSS_ESB_FACET_ID + ".";
-	private static ModuleFactory factory;
 	private static JBossESBModuleFactory factDelegate;
 
 	public static JBossESBModuleFactory getFactory() {
-		if (factDelegate == null) {
-			ModuleFactory[] factories = ServerPlugin.getModuleFactories();
-			for (int i = 0; i < factories.length; i++) {
-				if (factories[i].getId().equals(FACTORY_ID)) {
-					Object o = factories[i]
-							.getDelegate(new NullProgressMonitor());
-					if (o instanceof JBossESBModuleFactory) {
-						factory = factories[i];
-						factDelegate = (JBossESBModuleFactory) o;
-						return factDelegate;
-					}
-				}
-			}
-		}
+		if (factDelegate == null)
+			factDelegate = (JBossESBModuleFactory)getFactory(FACTORY_ID);
 		return factDelegate;
 	}
 
-	
-	private HashMap<IModule, JBossESBModuleDelegate> moduleToDelegate;
 	public JBossESBModuleFactory() {
-		moduleToDelegate = new HashMap<IModule, JBossESBModuleDelegate>();
-	}
-
-	@Override
-	protected void clearCache(IProject project) {
-		super.clearCache(project);
-		moduleToDelegate.remove(project);
-	}
-	
-	@Override
-	public ModuleDelegate getModuleDelegate(IModule module) {
-		return moduleToDelegate.get(module);
+		super(MODULE_TYPE, ESBProjectConstant.ESB_PROJECT_FACET);
 	}
 
-	protected IModule[] createModules(IProject project) {
-		IFacetedProject facetProject;
-		try {
-			facetProject = ProjectFacetsManager.create(project);
-			if (facetProject == null) {
-				return null;
-			}
-			IProjectFacet esbFacet = ProjectFacetsManager
-					.getProjectFacet(ESBProjectConstant.ESB_PROJECT_FACET);
-
-			if (facetProject.hasProjectFacet(esbFacet)) {
-				IProjectFacetVersion version = facetProject.getProjectFacetVersion(esbFacet);
-				IModule module = createModule(
-						MODULE_ID_PREFIX + project.getName(), 
-						project.getName(), 
-						MODULE_TYPE, 
-						version.getVersionString(), 
-						project);
-				moduleToDelegate.put(module, new JBossESBModuleDelegate(project));
-				return new IModule[] { module };
-			}
-		} catch (CoreException e) {
-			ESBProjectCorePlugin.getDefault().getLog().log(e.getStatus());
-		}
-		return null;
-
+	protected JBTProjectModuleDelegate createDelegate(IProject project) {
+		return new JBossESBModuleDelegate(project);
 	}
 
 }
Index: src/org/jboss/tools/esb/core/facet/IJBossESBFacetDataModelProperties.java
===================================================================
--- src/org/jboss/tools/esb/core/facet/IJBossESBFacetDataModelProperties.java	(revision 16571)
+++ src/org/jboss/tools/esb/core/facet/IJBossESBFacetDataModelProperties.java	(working copy)
@@ -27,6 +27,7 @@
 	
 	public static final QualifiedName QNAME_ESB_CONTENT_FOLDER = new QualifiedName("jboss", ESB_CONTENT_FOLDER);
 	public static final QualifiedName QNAME_ESB_SRC_FOLDER = new QualifiedName("jboss", ESB_SOURCE_FOLDER);
+	public static final QualifiedName QNAME_ESB_PROJECT_VERSION = new QualifiedName("jboss.esb.project", "project.version");
 
 	
 	
Index: META-INF/MANIFEST.MF
===================================================================
--- META-INF/MANIFEST.MF	(revision 16969)
+++ META-INF/MANIFEST.MF	(working copy)
@@ -29,7 +29,8 @@
  org.eclipse.jem.util,
  org.eclipse.wst.common.emfworkbench.integration,
  org.eclipse.emf.ecore,
- org.jboss.ide.eclipse.as.classpath.core
+ org.jboss.ide.eclipse.as.classpath.core,
+ org.jboss.ide.eclipse.as.wtp.core;bundle-version="1.0.0"
 Bundle-ActivationPolicy: lazy
 Bundle-Vendor: %providerName
 Export-Package: org.jboss.tools.esb.core,
Index: plugin.xml
===================================================================
--- plugin.xml	(revision 16571)
+++ plugin.xml	(working copy)
@@ -209,4 +209,14 @@
              containerID="org.jboss.esb.runtime.classpath">
        </filteredClasspathContainer>
     </extension>
+    
+    
+    <extension
+         point="org.eclipse.wst.common.modulecore.componentimpl">
+      <componentimpl
+            typeID="jst.jboss.esb"
+            class="org.jboss.tools.esb.core.component.ESBVirtualComponent">
+      </componentimpl>
+   </extension>
+    
 </plugin>
