[299432] J2EE Deployment framework doesn't allow facet exclusions
diff --git a/plugins/org.eclipse.jst.j2ee.ui/property_files/j2ee_ui.properties b/plugins/org.eclipse.jst.j2ee.ui/property_files/j2ee_ui.properties index f6efa74..1047824 100644 --- a/plugins/org.eclipse.jst.j2ee.ui/property_files/j2ee_ui.properties +++ b/plugins/org.eclipse.jst.j2ee.ui/property_files/j2ee_ui.properties
@@ -151,7 +151,7 @@ DEPLOY_PROJECT_NOT_FOUND=Cannot get handle to the project. DEPLOY_RUNTIME_NOT_FOUND=Target runtime not configured for project {0}. DEPLOY_RUNTIME_CONFIGURED=Target runtime configured successfully for project {0}. -DEPLOY_PROJECT_NOT_SUPPORTED=Project {0} cannot be deployed on the configured target runtime. +DEPLOY_PROJECT_NOT_SUPPORTED=Project {0} cannot be deployed with configured runtime or installed facets. NewModuleSelectionPage.appClient=Application Client NewModuleSelectionPage.ejb=Enterprise Java Bean
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistry.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistry.java index d079995..ec9f9b9 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistry.java +++ b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistry.java
@@ -22,6 +22,7 @@ import java.util.List; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.emf.ecore.EObject; import org.eclipse.jem.util.emf.workbench.ProjectUtilities; @@ -31,6 +32,9 @@ import org.eclipse.wst.common.componentcore.ComponentCore; import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; 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.IRuntime; /** @@ -45,6 +49,7 @@ */ private static DeployerRegistry INSTANCE; private HashMap deployModuleExtensions = new HashMap(); + private HashMap facetExceptions = new HashMap(); public DeployerRegistry() { super(); @@ -52,10 +57,11 @@ /** * @param deployer + * @param facetExclusions * @param serverTarget * @param natureID */ - public void register(IConfigurationElement deployer, List serverTargets, List natures) { + public void register(IConfigurationElement deployer, List serverTargets, List natures, List facetExclusions) { HashMap targetDeployers; for (Iterator iter = natures.iterator(); iter.hasNext();) { String natureID = (String) iter.next(); @@ -65,6 +71,22 @@ getTargetDeployers(targetDeployers, runtimeID).add(deployer); } } + //Now register exclusions if any + List facets = getFacetExceptions(deployer); + for (Iterator iterator = facetExclusions.iterator(); iterator.hasNext();) { + String facetID = (String) iterator.next(); + if (!facets.contains(facetID)) + facets.add(facetID); + } + } + + /** + * @param deployer + * @param serverTarget + * @param natureID + */ + public void register(IConfigurationElement deployer, List serverTargets, List natures) { + register(deployer, serverTargets, natures, new ArrayList()); } private List getDeployers(String natureID, String serverTarget) { @@ -187,8 +209,51 @@ typeID = J2EEProjectUtilities.JCA; else if (J2EEProjectUtilities.isUtilityProject(project)) typeID = J2EEProjectUtilities.UTILITY; - String runtimeID = runtime.getRuntimeType().getId(); - return getDeployers(typeID, runtimeID); + + String runtimeID = null; + if (runtime == null) + runtimeID = "None"; + else + runtimeID = runtime.getRuntimeType().getId(); + List deployers = getDeployers(typeID, runtimeID); + return getFilteredDeployers(project,deployers); + } + + private List getFilteredDeployers(IProject project, List deployers) { + IFacetedProject fProj = null; + try { + fProj = ProjectFacetsManager.create(project); + } catch (CoreException e) { + org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin.logError(e); + } + if (fProj == null) return deployers; + List filteredDeployers = new ArrayList(); + for (Iterator iterator = deployers.iterator(); iterator.hasNext();) { + boolean excludeDeployer = false; + IConfigurationElement deployer = (IConfigurationElement) iterator.next(); + List exclusions = getFacetExceptions(deployer); + if (exclusions.isEmpty()) + filteredDeployers.add(deployer); + else { + for (Iterator iterator2 = exclusions.iterator(); iterator2.hasNext();) { + String exclusion = (String) iterator2.next(); + IProjectFacet facet = ProjectFacetsManager.getProjectFacet(exclusion); + if (facet != null && fProj.hasProjectFacet(facet)) { + excludeDeployer = true; + } + } + if (!excludeDeployer) + filteredDeployers.add(deployer); + } + + } + return filteredDeployers; + } + + private List getFacetExceptions(IConfigurationElement deployer) { + if (facetExceptions.get(deployer) == null) + facetExceptions.put(deployer, new ArrayList()); + return (List)facetExceptions.get(deployer); } }
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistryReader.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistryReader.java index c384cfc..0fd1a13 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistryReader.java +++ b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deploy/DeployerRegistryReader.java
@@ -44,6 +44,8 @@ static final String NATURE = "nature"; //$NON-NLS-1$ static final String COMPONENT_TYPE_ID = "component_type"; //$NON-NLS-1$ static final String COMPONENT = "component"; //$NON-NLS-1$ + static final String FACET_EXCLUSIONS = "facetExclusions"; //$NON-NLS-1$ + static final String FACET_ID = "facet_id"; //$NON-NLS-1$ public DeployerRegistryReader() { super(J2EEPlugin.PLUGIN_ID, J2EE_DEPLOYER_EXTENSION_POINT); @@ -59,6 +61,7 @@ return false; List runtimeList = new ArrayList(); List natureandcomponents = new ArrayList(); + List facetExclusions = new ArrayList(); IConfigurationElement[] runtimes = element.getChildren(RUNTIME); for (int i = 0; i < runtimes.length; i++) { IConfigurationElement runtime = runtimes[i]; @@ -77,10 +80,16 @@ String compType = component.getAttribute(COMPONENT_TYPE_ID); natureandcomponents.add(compType); } + IConfigurationElement[] exclusions = element.getChildren(FACET_EXCLUSIONS); + for (int i = 0; i < exclusions.length; i++) { + IConfigurationElement exclusion = exclusions[i]; + String compType = exclusion.getAttribute(FACET_ID); + facetExclusions.add(compType); + } String deployer = element.getAttribute(DEPLOYER_CLASS); if (deployer != null) { - DeployerRegistry.instance().register(element, runtimeList, natureandcomponents); + DeployerRegistry.instance().register(element, runtimeList, natureandcomponents,facetExclusions); return true; } return false;
diff --git a/plugins/org.eclipse.jst.j2ee/schema/DeployerExtension.exsd b/plugins/org.eclipse.jst.j2ee/schema/DeployerExtension.exsd index 5f66b36..6b52a64 100644 --- a/plugins/org.eclipse.jst.j2ee/schema/DeployerExtension.exsd +++ b/plugins/org.eclipse.jst.j2ee/schema/DeployerExtension.exsd
@@ -1,6 +1,6 @@ <?xml version='1.0' encoding='UTF-8'?> <!-- Schema file written by PDE --> -<schema targetNamespace="org.eclipse.jst.j2ee"> +<schema targetNamespace="org.eclipse.jst.j2ee" xmlns="http://www.w3.org/2001/XMLSchema"> <annotation> <appInfo> <meta.schema plugin="org.eclipse.jst.j2ee" id="DeployerExtension" name="J2EE Deployer Extension"/> @@ -11,6 +11,11 @@ </annotation> <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> <complexType> <sequence> <element ref="deployer"/> @@ -47,6 +52,7 @@ <element ref="nature"/> <element ref="component"/> </choice> + <element ref="facetExclusions" minOccurs="0" maxOccurs="unbounded"/> </sequence> <attribute name="deployer_class" type="string" use="required"> <annotation> @@ -94,6 +100,18 @@ </complexType> </element> + <element name="facetExclusions"> + <complexType> + <attribute name="facet_id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + <annotation> <appInfo> <meta.section type="since"/> @@ -103,32 +121,8 @@ </documentation> </annotation> - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - - </documentation> - </annotation> - <annotation> - <appInfo> - <meta.section type="apiInfo"/> - </appInfo> - <documentation> - - </documentation> - </annotation> - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - - </documentation> - </annotation> <annotation> <appInfo>