Author: dennyxu
Date: 2008-11-13 22:35:58 -0500 (Thu, 13 Nov 2008)
New Revision: 11776
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleArtifactAdapter.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java
Removed:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java
Modified:
trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF
trunk/esb/plugins/org.jboss.tools.esb.project.core/plugin.xml
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java
Log:
JBIDE-3192: ESB deployment doesn't pick up all classes
Modified: trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF 2008-11-14
01:51:23 UTC (rev 11775)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF 2008-11-14
03:35:58 UTC (rev 11776)
@@ -28,7 +28,8 @@
org.jboss.ide.eclipse.as.classpath.core,
org.eclipse.wst.web;bundle-version="1.1.204",
org.eclipse.jem.util;bundle-version="2.0.100",
- org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.1.201"
+ org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.1.201",
+ org.eclipse.emf.ecore;bundle-version="2.4.1"
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Export-Package: org.jboss.tools.esb.core,
Modified: trunk/esb/plugins/org.jboss.tools.esb.project.core/plugin.xml
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/plugin.xml 2008-11-14 01:51:23 UTC
(rev 11775)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/plugin.xml 2008-11-14 03:35:58 UTC
(rev 11776)
@@ -142,8 +142,30 @@
<extension
point="org.eclipse.wst.server.core.moduleArtifactAdapters">
<moduleArtifactAdapter
- id="org.jboss.tools.esb.project.core.moduleArtifactAdapter1">
- <enablement></enablement>
+
class="org.jboss.tools.esb.core.module.JBossESBModuleArtifactAdapter"
+ id="org.jboss.tools.esb.project.core.moduleArtifactAdapter">
+ <enablement>
+ <with
+ variable="selection">
+ <or>
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ <test
+ forcePluginActivation="true"
+
property="org.eclipse.wst.common.project.facet.core.projectFacet"
+ value="jst.jboss.esb">
+ </test>
+ </adapt>
+ <adapt
+ type="org.eclipse.core.resources.IFile">
+ <test
+ forcePluginActivation="true"
+
property="org.eclipse.wst.common.project.facet.core.projectFacet"
+ value="jst.jboss.esb">
+ </test>
+ </adapt>
+ </or>
+ </with></enablement>
</moduleArtifactAdapter>
</extension>
</plugin>
Modified:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java 2008-11-14
01:51:23 UTC (rev 11775)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java 2008-11-14
03:35:58 UTC (rev 11776)
@@ -12,6 +12,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jst.common.project.facet.WtpUtils;
@@ -43,26 +44,34 @@
// Setup the flexible project structure.
final IVirtualComponent c = ComponentCore.createComponent(project);
c.create(0, null);
- String esbContent =
model.getStringProperty(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
- c.setMetaProperty("java-output-path", "/" + esbContent +
"/build/classes/");
+ //String esbContent =
model.getStringProperty(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
+ c.setMetaProperty("java-output-path", "/build/classes/");
final IVirtualFolder jbiRoot = c.getRootFolder();
// Create directory structure
- String srcFolder = null;
+ /*String srcFolder = null;
srcFolder = model
.getStringProperty(IJBossESBFacetDataModelProperties.ESB_SOURCE_FOLDER);
- jbiRoot.createLink(new Path("/" + srcFolder), 0, null);
+ jbiRoot.createLink(new Path("/" + srcFolder), 0, null);*/
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];
+ if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
+ if( cpe.getPath().removeFirstSegments(1).segmentCount() > 0 )
+ jsrc.createLink(cpe.getPath().removeFirstSegments(1), 0, null);
+ }
+ }
//addESBNature(project);
- String runtimeId = model
- .getStringProperty(IJBossESBFacetDataModelProperties.RUNTIME_ID);
+
JBossClassPathCommand command = new JBossClassPathCommand(project,
model);
IStatus status = command.executeOverride(monitor);
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleArtifactAdapter.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleArtifactAdapter.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleArtifactAdapter.java 2008-11-14
03:35:58 UTC (rev 11776)
@@ -0,0 +1,91 @@
+package org.jboss.tools.esb.core.module;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+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.ProjectFacetsManager;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.model.ModuleArtifactAdapterDelegate;
+import org.eclipse.wst.server.core.util.WebResource;
+import org.jboss.tools.esb.core.ESBProjectConstant;
+
+public class JBossESBModuleArtifactAdapter extends
+ ModuleArtifactAdapterDelegate {
+
+ public JBossESBModuleArtifactAdapter() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public IModuleArtifact getModuleArtifact(Object obj) {
+
+ IResource resource = null;
+ if (obj instanceof IResource)
+ resource = (IResource) obj;
+ else if (obj instanceof IAdaptable)
+ resource = (IResource) ((IAdaptable) obj).getAdapter(IResource.class);
+
+ if (resource == null)
+ return null;
+
+ if (resource instanceof IProject) {
+ IProject project = (IProject) resource;
+ if (isESBProject(project))
+ return new WebResource(getModule(project), new Path("")); //$NON-NLS-1$
+ return null;
+ }
+ IProject project = ProjectUtilities.getProject(resource);
+ if (project != null && !isESBProject(project))
+ return null;
+
+ IVirtualComponent comp = ComponentCore.createComponent(project);
+ // determine path
+ IPath rootPath = comp.getRootFolder().getProjectRelativePath();
+ IPath resourcePath = resource.getProjectRelativePath();
+
+ // Check to make sure the resource is under the Application directory
+ if (resourcePath.matchingFirstSegments(rootPath) != rootPath.segmentCount())
+ return null;
+
+
+ // return Web resource type
+ return new WebResource(getModule(project), resourcePath);
+
+ }
+
+ protected static IModule getModule(IProject project) {
+ if (isESBProject(project))
+ return ServerUtil.getModule(project);
+ return null;
+ }
+
+ protected static boolean isESBProject(IProject project) {
+ return isProjectOfType(project, ESBProjectConstant.ESB_PROJECT_FACET);
+ }
+
+ protected static boolean isProjectOfType(IProject project, String typeID) {
+ IFacetedProject facetedProject = null;
+ try {
+ facetedProject = ProjectFacetsManager.create(project);
+ } catch (CoreException e) {
+ return false;
+ }
+
+ if (facetedProject != null &&
ProjectFacetsManager.isProjectFacetDefined(typeID)) {
+ IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(typeID);
+ return projectFacet != null && facetedProject.hasProjectFacet(projectFacet);
+ }
+ return false;
+ }
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java 2008-11-14
03:35:58 UTC (rev 11776)
@@ -0,0 +1,106 @@
+package org.jboss.tools.esb.core.module;
+
+import java.util.ArrayList;
+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.tools.esb.core.StatusUtils;
+
+public class JBossESBModuleDelegate extends ProjectModule {
+
+ public JBossESBModuleDelegate(IProject project){
+ super(project);
+ }
+ @Override
+ public IModule[] getChildModules() {
+ return null;
+ }
+
+ public IModuleResource[] members() 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."));
+ }
+
+ //this is because of the beta1 workspace meta data, so try to get esbcontent folder
name by this way,
+ //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);
+ 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
+ //List<IModuleResource> mrs = getConfigModuleFile(project, configFolder);
+
+ List<IModuleResource> mrs = new ArrayList<IModuleResource>();
+
+ IModuleResource[] esbContent = getModuleResources(Path.EMPTY, configFolder);
+ IModuleResource[] classes = getModuleResources(Path.EMPTY,
project.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);
+ if(mrs.size() > 0){
+ IModuleResource[] mr = mrs.toArray(new IModuleResource[]{});
+ System.arraycopy(mr, 0, allResource, esbContent.length + classes.length, mr.length);
+ }
+ 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];
+ }
+
+}
Deleted:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java 2008-11-14
01:51:23 UTC (rev 11775)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java 2008-11-14
03:35:58 UTC (rev 11776)
@@ -1,143 +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.esb.core.module;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.ModuleCoreNature;
-import org.eclipse.wst.common.componentcore.internal.StructureEdit;
-import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-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.ProjectFacetsManager;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.model.ModuleDelegate;
-import org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate;
-import org.jboss.tools.esb.core.ESBProjectConstant;
-import org.jboss.tools.esb.core.ESBProjectCorePlugin;
-import org.jboss.tools.esb.core.StatusUtils;
-
-public class JBossESBModuleFactory extends ProjectModuleFactoryDelegate {
-
- private static final String ID =
"org.jboss.tools.esb.project.core.moduleFactory"; //$NON-NLS-1$
- protected ArrayList moduleDelegates = new ArrayList();
-
- /*
- * @see DeployableProjectFactoryDelegate#getFactoryID()
- */
- public static String getFactoryId() {
- return ID;
- }
- protected IModule[] createModules(ModuleCoreNature nature) {
-
- IProject project = nature.getProject();
- try {
- IVirtualComponent comp = ComponentCore.createComponent(project);
- return createModuleDelegates(comp);
- } catch (Exception e) {
- ESBProjectCorePlugin.getDefault().getLog().log(StatusUtils.errorStatus(e));
- }
- return null;
- }
- /**
- * Returns true if the project represents a deployable project of this type.
- *
- * @param project
- * org.eclipse.core.resources.IProject
- * @return boolean
- */
- protected boolean isValidModule(IProject project) {
- try {
- IFacetedProject facetedProject = ProjectFacetsManager.create(project);
- if (facetedProject == null)
- return false;
- IProjectFacet webFacet =
ProjectFacetsManager.getProjectFacet(ESBProjectConstant.ESB_PROJECT_FACET);
- return facetedProject.hasProjectFacet(webFacet);
- } catch (Exception e) {
- return false;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.eclipse.wst.server.core.model.ModuleFactoryDelegate#getModuleDelegate(org.eclipse.wst.server.core.IModule)
- */
- public ModuleDelegate getModuleDelegate(IModule module) {
- for (Iterator iter = moduleDelegates.iterator(); iter.hasNext();) {
- ModuleDelegate element = (ModuleDelegate) iter.next();
- if (module == element.getModule())
- return element;
- }
- return null;
-
- }
-
- protected IModule[] createModules(IProject project) {
- try {
- if (project.exists()) {
- ModuleCoreNature nature = (ModuleCoreNature)
project.getNature(IModuleConstants.MODULE_NATURE_ID);
- if (nature != null)
- return createModules(nature);
- }
- } catch (CoreException e) {
- ESBProjectCorePlugin.getDefault().getLog().log(StatusUtils.errorStatus(e));
- }
- return null;
- }
-
- protected IModule[] createModuleDelegates(IVirtualComponent component) throws
CoreException {
- JBossESBModuleDeployable moduleDelegate = null;
- IModule module = null;
- try {
- if(isValidModule(component.getProject())) {
- moduleDelegate = new JBossESBModuleDeployable(component.getProject(),component);
- module = createModule(component.getName(),
component.getName(),ESBProjectConstant.ESB_PROJECT_FACET, moduleDelegate.getVersion(),
moduleDelegate.getProject());
- moduleDelegate.initialize(module);
- }
- } catch (Exception e) {
- ESBProjectCorePlugin.getDefault().getLog().log(StatusUtils.errorStatus(e));
- } finally {
- if (module != null) {
- if (getModuleDelegate(module) == null)
- moduleDelegates.add(moduleDelegate);
- }
- }
- if (module == null)
- return null;
- return new IModule[] {module};
- }
-
- /**
- * Returns the list of resources that the module should listen to
- * for state changes. The paths should be project relative paths.
- * Subclasses can override this method to provide the paths.
- *
- * @return a possibly empty array of paths
- */
- protected IPath[] getListenerPaths() {
- return new IPath[] {
- new Path(".project"), // nature //$NON-NLS-1$
- new Path(StructureEdit.MODULE_META_FILE_NAME), // component
- new Path(".settings/org.eclipse.wst.common.project.facet.core.xml") //
facets //$NON-NLS-1$
- };
- }
-
-}