Skip to content

Commit

Permalink
WFLY-5819 EJB clustering 1.1 schema propagates unused clustered attri…
Browse files Browse the repository at this point in the history
…bute
  • Loading branch information
pferraro committed Dec 16, 2015
1 parent c654359 commit bae4a99
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 112 deletions.
@@ -0,0 +1,57 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.ejb3.clustering;

import org.jboss.as.clustering.controller.Schema;

/**
* @author Paul Ferraro
*/
public enum ClusteringSchema implements Schema<ClusteringSchema> {

VERSION_1_0(1, 0),
VERSION_1_1(1, 1),
;
private final int major;
private final int minor;

ClusteringSchema(int major, int minor) {
this.major = major;
this.minor = minor;
}

@Override
public int major() {
return this.major;
}

@Override
public int minor() {
return this.minor;
}

@Override
public String getNamespaceUri() {
return String.format("urn:clustering:%d.%d", this.major, this.minor);
}
}
Expand Up @@ -37,32 +37,49 @@
*/ */
public class EJBBoundClusteringMetaDataParser extends AbstractEJBBoundMetaDataParser<EJBBoundClusteringMetaData> { public class EJBBoundClusteringMetaDataParser extends AbstractEJBBoundMetaDataParser<EJBBoundClusteringMetaData> {


public static final String NAMESPACE_URI_1_0 = "urn:clustering:1.0"; private final ClusteringSchema schema;
private static final String ROOT_ELEMENT_CLUSTERING = "clustering";
private static final String CLUSTERED_ELEMENT = "clustered"; public EJBBoundClusteringMetaDataParser(ClusteringSchema schema) {
this.schema = schema;
}


@Override @Override
public EJBBoundClusteringMetaData parse(final XMLStreamReader xmlStreamReader, final PropertyReplacer propertyReplacer) throws XMLStreamException { public EJBBoundClusteringMetaData parse(final XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException {
final String element = xmlStreamReader.getLocalName();
// we only parse <clustering> (root) element // we only parse <clustering> (root) element
if (!ROOT_ELEMENT_CLUSTERING.equals(element)) { if (!reader.getLocalName().equals("clustering")) {
throw unexpectedElement(xmlStreamReader); throw unexpectedElement(reader);
}
if (this.schema == ClusteringSchema.VERSION_1_0) {
EjbLogger.ROOT_LOGGER.deprecatedNamespace(reader.getNamespaceURI(), reader.getLocalName());
} }
EJBBoundClusteringMetaData metaData = new EJBBoundClusteringMetaData(); EJBBoundClusteringMetaData metaData = new EJBBoundClusteringMetaData();
this.processElements(metaData, xmlStreamReader, propertyReplacer); this.processElements(metaData, reader, propertyReplacer);
return metaData; return metaData;
} }


@Override @Override
protected void processElement(final EJBBoundClusteringMetaData metaData, final XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { protected void processElement(final EJBBoundClusteringMetaData metaData, final XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException {
if (NAMESPACE_URI_1_0.equals(reader.getNamespaceURI())) { if (this.schema.getNamespaceUri().equals(reader.getNamespaceURI())) {
EjbLogger.ROOT_LOGGER.deprecatedNamespace(NAMESPACE_URI_1_0, ROOT_ELEMENT_CLUSTERING); switch (reader.getLocalName()) {
final String localName = reader.getLocalName(); case "clustered": {
if (localName.equals(CLUSTERED_ELEMENT)) { if (this.schema.since(ClusteringSchema.VERSION_1_1)) {
requireNoAttributes(reader); throw unexpectedElement(reader);
getElementText(reader, propertyReplacer); }
} else { break;
throw unexpectedElement(reader); }
case "clustered-singleton":
if (this.schema.since(ClusteringSchema.VERSION_1_1)) {
requireNoAttributes(reader);
final String text = getElementText(reader, propertyReplacer);
if (text != null) {
final boolean isClusteredSingleton = Boolean.parseBoolean(text.trim());
metaData.setClusteredSingleton(isClusteredSingleton);
}
break;
}
default: {
throw unexpectedElement(reader);
}
} }
} else { } else {
super.processElement(metaData, reader, propertyReplacer); super.processElement(metaData, reader, propertyReplacer);
Expand Down

This file was deleted.

Expand Up @@ -25,6 +25,7 @@


import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
Expand All @@ -39,15 +40,15 @@
import org.jboss.as.ee.metadata.MetadataCompleteMarker; import org.jboss.as.ee.metadata.MetadataCompleteMarker;
import org.jboss.as.ee.structure.JBossDescriptorPropertyReplacement; import org.jboss.as.ee.structure.JBossDescriptorPropertyReplacement;
import org.jboss.as.ee.structure.SpecDescriptorPropertyReplacement; import org.jboss.as.ee.structure.SpecDescriptorPropertyReplacement;
import org.jboss.as.ejb3.clustering.EJBBoundClusteringMetaDataParser11;
import org.jboss.as.ejb3.logging.EjbLogger;
import org.jboss.as.ejb3.cache.EJBBoundCacheParser; import org.jboss.as.ejb3.cache.EJBBoundCacheParser;
import org.jboss.as.ejb3.clustering.ClusteringSchema;
import org.jboss.as.ejb3.clustering.EJBBoundClusteringMetaDataParser; import org.jboss.as.ejb3.clustering.EJBBoundClusteringMetaDataParser;
import org.jboss.as.ejb3.deliveryactive.parser.EJBBoundMdbDeliveryMetaDataParser; import org.jboss.as.ejb3.deliveryactive.parser.EJBBoundMdbDeliveryMetaDataParser;
import org.jboss.as.ejb3.deliveryactive.parser.EJBBoundMdbDeliveryMetaDataParser11; import org.jboss.as.ejb3.deliveryactive.parser.EJBBoundMdbDeliveryMetaDataParser11;
import org.jboss.as.ejb3.deployment.EjbDeploymentAttachmentKeys; import org.jboss.as.ejb3.deployment.EjbDeploymentAttachmentKeys;
import org.jboss.as.ejb3.deployment.EjbJarDescription; import org.jboss.as.ejb3.deployment.EjbJarDescription;
import org.jboss.as.ejb3.interceptor.ContainerInterceptorsParser; import org.jboss.as.ejb3.interceptor.ContainerInterceptorsParser;
import org.jboss.as.ejb3.logging.EjbLogger;
import org.jboss.as.ejb3.pool.EJBBoundPoolParser; import org.jboss.as.ejb3.pool.EJBBoundPoolParser;
import org.jboss.as.ejb3.resourceadapterbinding.parser.EJBBoundResourceAdapterBindingMetaDataParser; import org.jboss.as.ejb3.resourceadapterbinding.parser.EJBBoundResourceAdapterBindingMetaDataParser;
import org.jboss.as.ejb3.security.parser.EJBBoundSecurityMetaDataParser; import org.jboss.as.ejb3.security.parser.EJBBoundSecurityMetaDataParser;
Expand Down Expand Up @@ -292,8 +293,7 @@ private static EjbJarMetaData parseJBossEjb3Xml(final DeploymentUnit deploymentU


static Map<String, AbstractMetaDataParser<?>> createJbossEjbJarParsers() { static Map<String, AbstractMetaDataParser<?>> createJbossEjbJarParsers() {
Map<String, AbstractMetaDataParser<?>> parsers = new HashMap<String, AbstractMetaDataParser<?>>(); Map<String, AbstractMetaDataParser<?>> parsers = new HashMap<String, AbstractMetaDataParser<?>>();
parsers.put(EJBBoundClusteringMetaDataParser.NAMESPACE_URI_1_0, new EJBBoundClusteringMetaDataParser()); EnumSet.allOf(ClusteringSchema.class).forEach((ClusteringSchema schema) -> parsers.put(schema.getNamespaceUri(), new EJBBoundClusteringMetaDataParser(schema)));
parsers.put(EJBBoundClusteringMetaDataParser11.NAMESPACE_URI_1_1, EJBBoundClusteringMetaDataParser11.INSTANCE);
parsers.put(EJBBoundSecurityMetaDataParser.LEGACY_NAMESPACE_URI, EJBBoundSecurityMetaDataParser.INSTANCE); parsers.put(EJBBoundSecurityMetaDataParser.LEGACY_NAMESPACE_URI, EJBBoundSecurityMetaDataParser.INSTANCE);
parsers.put(EJBBoundSecurityMetaDataParser.NAMESPACE_URI_1_0, EJBBoundSecurityMetaDataParser.INSTANCE); parsers.put(EJBBoundSecurityMetaDataParser.NAMESPACE_URI_1_0, EJBBoundSecurityMetaDataParser.INSTANCE);
parsers.put(EJBBoundSecurityMetaDataParser11.NAMESPACE_URI_1_1, EJBBoundSecurityMetaDataParser11.INSTANCE); parsers.put(EJBBoundSecurityMetaDataParser11.NAMESPACE_URI_1_1, EJBBoundSecurityMetaDataParser11.INSTANCE);
Expand Down
Expand Up @@ -47,7 +47,6 @@
import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder;
import org.jboss.as.controller.transform.description.TransformationDescription; import org.jboss.as.controller.transform.description.TransformationDescription;
import org.jboss.as.controller.transform.description.TransformationDescriptionBuilder; import org.jboss.as.controller.transform.description.TransformationDescriptionBuilder;
import org.jboss.as.ejb3.clustering.ClusteredSingletonService;
import org.jboss.as.ejb3.deployment.processors.EJBDefaultSecurityDomainProcessor; import org.jboss.as.ejb3.deployment.processors.EJBDefaultSecurityDomainProcessor;
import org.jboss.as.ejb3.deployment.processors.merging.MissingMethodPermissionsDenyAccessMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.MissingMethodPermissionsDenyAccessMergingProcessor;
import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.as.ejb3.logging.EjbLogger;
Expand Down Expand Up @@ -159,7 +158,7 @@ public class EJB3SubsystemRootResourceDefinition extends SimpleResourceDefinitio
.build(); .build();


public static final RuntimeCapability<Void> CLUSTERED_SINGLETON_CAPABILITY = RuntimeCapability.Builder.of( public static final RuntimeCapability<Void> CLUSTERED_SINGLETON_CAPABILITY = RuntimeCapability.Builder.of(
"org.wildfly.ejb3.clustered.singleton", ClusteredSingletonService.class).build(); "org.wildfly.ejb3.clustered.singleton", Void.class).build();


private static final EJBDefaultSecurityDomainProcessor defaultSecurityDomainDeploymentProcessor = new EJBDefaultSecurityDomainProcessor(null); private static final EJBDefaultSecurityDomainProcessor defaultSecurityDomainDeploymentProcessor = new EJBDefaultSecurityDomainProcessor(null);
private static final MissingMethodPermissionsDenyAccessMergingProcessor missingMethodPermissionsDenyAccessMergingProcessor = new MissingMethodPermissionsDenyAccessMergingProcessor(); private static final MissingMethodPermissionsDenyAccessMergingProcessor missingMethodPermissionsDenyAccessMergingProcessor = new MissingMethodPermissionsDenyAccessMergingProcessor();
Expand Down
6 changes: 0 additions & 6 deletions ejb3/src/main/resources/schema/jboss-ejb-clustering_1_1.xsd
Expand Up @@ -37,12 +37,6 @@
<xs:complexContent> <xs:complexContent>
<xs:extension base="javaee:jboss-assembly-descriptor-bean-entryType"> <xs:extension base="javaee:jboss-assembly-descriptor-bean-entryType">
<xs:choice> <xs:choice>
<xs:element name="clustered" type="xs:boolean">
<xs:annotation>
<xs:documentation>Deprecated: this element is deprecated and will be ignored
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="clustered-singleton" type="xs:boolean"> <xs:element name="clustered-singleton" type="xs:boolean">
<xs:annotation> <xs:annotation>
<xs:documentation>Indicates that the mdb will be active in a single node of the cluster. <xs:documentation>Indicates that the mdb will be active in a single node of the cluster.
Expand Down

0 comments on commit bae4a99

Please sign in to comment.