Author: asoldano
Date: 2013-12-03 18:49:41 -0500 (Tue, 03 Dec 2013)
New Revision: 18122
Modified:
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/AbstractHandlerChainsMetaDataParser.java
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/AbstractCommonConfig.java
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/ClientConfig.java
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/CommonConfig.java
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/ConfigMetaDataParser.java
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/EndpointConfig.java
spi/branches/JBWS-3739/src/test/java/org/jboss/test/wsf/spi/metadata/config/ConfigMDParserTestCase.java
Log:
[JBWS-3708] Turn client/endpoint config into immutable objects
Modified:
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/AbstractHandlerChainsMetaDataParser.java
===================================================================
---
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/AbstractHandlerChainsMetaDataParser.java 2013-12-03
14:47:28 UTC (rev 18121)
+++
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/AbstractHandlerChainsMetaDataParser.java 2013-12-03
23:49:41 UTC (rev 18122)
@@ -71,7 +71,7 @@
protected UnifiedHandlerChainsMetaData parseHandlerChains(XMLStreamReader reader,
String nsUri,
String handlerChainsElementNS, String handlerChainsElementName) throws
XMLStreamException
{
- List<UnifiedHandlerChainMetaData> handlerChains = new
LinkedList<UnifiedHandlerChainMetaData>();
+ List<UnifiedHandlerChainMetaData> handlerChains = new
ArrayList<UnifiedHandlerChainMetaData>(1);
while (reader.hasNext())
{
switch (reader.nextTag())
Modified:
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/AbstractCommonConfig.java
===================================================================
---
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/AbstractCommonConfig.java 2013-12-03
14:47:28 UTC (rev 18121)
+++
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/AbstractCommonConfig.java 2013-12-03
23:49:41 UTC (rev 18122)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2013, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -21,7 +21,7 @@
*/
package org.jboss.wsf.spi.metadata.config;
-import java.util.HashMap;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -37,32 +37,52 @@
*/
public abstract class AbstractCommonConfig implements CommonConfig
{
- private String configName;
- private Map<String, Feature> features = new HashMap<String, Feature>(2);
- private Map<String, String> properties = new HashMap<String, String>(4);
- private List<UnifiedHandlerChainMetaData> preHandlerChains;
- private List<UnifiedHandlerChainMetaData> postHandlerChains;
+ private final String configName;
+ private final Map<String, Feature> features;
+ private final Map<String, String> properties;
+ private final List<UnifiedHandlerChainMetaData> preHandlerChains;
+ private final List<UnifiedHandlerChainMetaData> postHandlerChains;
+
+ protected AbstractCommonConfig(String configName,
+ List<UnifiedHandlerChainMetaData>
preHandlerChains,
+ List<UnifiedHandlerChainMetaData>
postHandlerChains,
+ Map<String, String> properties,
+ Map<String, Feature> features)
+ {
+ super();
+ this.configName = configName;
+ if (features != null && !features.isEmpty()) {
+ this.features = Collections.unmodifiableMap(features);
+ } else {
+ this.features = Collections.emptyMap();
+ }
+ if (properties != null && !properties.isEmpty()) {
+ this.properties = Collections.unmodifiableMap(properties);
+ } else {
+ this.properties = Collections.emptyMap();
+ }
+ if (preHandlerChains != null && !preHandlerChains.isEmpty()) {
+ this.preHandlerChains = Collections.unmodifiableList(preHandlerChains);
+ } else {
+ this.preHandlerChains = Collections.emptyList();
+ }
+ if (postHandlerChains != null && !postHandlerChains.isEmpty()) {
+ this.postHandlerChains = Collections.unmodifiableList(postHandlerChains);
+ } else {
+ this.postHandlerChains = Collections.emptyList();
+ }
+ }
public List<UnifiedHandlerChainMetaData> getPostHandlerChains()
{
return postHandlerChains;
}
- public void setPostHandlerChains(List<UnifiedHandlerChainMetaData>
postHandlerChain)
- {
- this.postHandlerChains = postHandlerChain;
- }
-
public List<UnifiedHandlerChainMetaData> getPreHandlerChains()
{
return preHandlerChains;
}
- public void setPreHandlerChains(List<UnifiedHandlerChainMetaData>
preHandlerChains)
- {
- this.preHandlerChains = preHandlerChains;
- }
-
public List<UnifiedHandlerChainMetaData> getHandlers(HandlerType type)
{
List<UnifiedHandlerChainMetaData> handlerChains;
@@ -79,30 +99,11 @@
return configName;
}
- public void setConfigName(String configName)
- {
- this.configName = configName;
- }
-
public boolean hasFeature(String name)
{
return features.containsKey(name);
}
- public void setFeature(Feature feature, boolean enabled) {
-
- if(enabled) {
- features.put(feature.getName(), feature);
- }
- else
- features.remove(feature.getName());
- }
-
- public void setProperty(String name, String value)
- {
- properties.put(name, value);
- }
-
public String getProperty(String name)
{
return properties.get(name);
Modified:
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/ClientConfig.java
===================================================================
---
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/ClientConfig.java 2013-12-03
14:47:28 UTC (rev 18121)
+++
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/ClientConfig.java 2013-12-03
23:49:41 UTC (rev 18122)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2013, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -21,6 +21,11 @@
*/
package org.jboss.wsf.spi.metadata.config;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
+
/**
* A JBossWS client configuration
*
@@ -30,4 +35,11 @@
public class ClientConfig extends AbstractCommonConfig
{
public static final String STANDARD_CLIENT_CONFIG =
"Standard-Client-Config";
+
+ public ClientConfig(String configName, List<UnifiedHandlerChainMetaData>
preHandlerChains,
+ List<UnifiedHandlerChainMetaData> postHandlerChains, Map<String,
String> properties,
+ Map<String, Feature> features)
+ {
+ super(configName, preHandlerChains, postHandlerChains, properties, features);
+ }
}
Modified:
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/CommonConfig.java
===================================================================
---
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/CommonConfig.java 2013-12-03
14:47:28 UTC (rev 18121)
+++
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/CommonConfig.java 2013-12-03
23:49:41 UTC (rev 18122)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2013, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -40,24 +40,14 @@
public List<UnifiedHandlerChainMetaData> getPostHandlerChains();
- public void setPostHandlerChains(List<UnifiedHandlerChainMetaData>
postHandlerChain);
-
public List<UnifiedHandlerChainMetaData> getPreHandlerChains();
- public void setPreHandlerChains(List<UnifiedHandlerChainMetaData>
preHandlerChains);
-
public List<UnifiedHandlerChainMetaData> getHandlers(HandlerType type);
public String getConfigName();
- public void setConfigName(String configName);
-
public boolean hasFeature(String name);
- public void setFeature(Feature feature, boolean enabled);
-
- public void setProperty(String name, String value);
-
public String getProperty(String name);
public Map<String, String> getProperties();
Modified:
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/ConfigMetaDataParser.java
===================================================================
---
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/ConfigMetaDataParser.java 2013-12-03
14:47:28 UTC (rev 18121)
+++
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/ConfigMetaDataParser.java 2013-12-03
23:49:41 UTC (rev 18122)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2013, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -44,6 +44,10 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamConstants;
@@ -52,6 +56,7 @@
import org.jboss.wsf.spi.Loggers;
import org.jboss.wsf.spi.metadata.AbstractHandlerChainsMetaDataParser;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainsMetaData;
import org.jboss.wsf.spi.util.StAXUtils;
@@ -153,14 +158,10 @@
}
case XMLStreamConstants.START_ELEMENT : {
if (match(reader, JBOSSWS_JAXWS_CONFIG_NS_4_0, ENDPOINT_CONFIG)) {
- EndpointConfig epConfig = new EndpointConfig();
- parseConfig(reader, epConfig, ENDPOINT_CONFIG);
- configRoot.addEndpointConfig(epConfig);
+ configRoot.addEndpointConfig(parseEndpointConfig(reader));
}
else if (match(reader, JBOSSWS_JAXWS_CONFIG_NS_4_0, CLIENT_CONFIG)) {
- ClientConfig clConfig = new ClientConfig();
- parseConfig(reader, clConfig, CLIENT_CONFIG);
- configRoot.addClientConfig(clConfig);
+ configRoot.addClientConfig(parseClientConfig(reader));
}
else
{
@@ -172,8 +173,23 @@
throw MESSAGES.reachedEndOfXMLDocUnexpectedly(getDescriptorForLogs());
}
- private void parseConfig(XMLStreamReader reader, CommonConfig config, String
configElement) throws XMLStreamException
+ private EndpointConfig parseEndpointConfig(final XMLStreamReader reader) throws
XMLStreamException
{
+ return (EndpointConfig)parseConfig(reader, ENDPOINT_CONFIG);
+ }
+
+ private ClientConfig parseClientConfig(final XMLStreamReader reader) throws
XMLStreamException
+ {
+ return (ClientConfig)parseConfig(reader, CLIENT_CONFIG);
+ }
+
+ private CommonConfig parseConfig(final XMLStreamReader reader, final String
configElement) throws XMLStreamException
+ {
+ String configName = null;
+ List<UnifiedHandlerChainMetaData> pre = null;
+ List<UnifiedHandlerChainMetaData> post = null;
+ List<Feature> features = new ArrayList<Feature>(1);
+ List<Prop> properties = new ArrayList<Prop>(1);
while (reader.hasNext())
{
switch (reader.nextTag())
@@ -181,7 +197,24 @@
case XMLStreamConstants.END_ELEMENT : {
if (match(reader, JBOSSWS_JAXWS_CONFIG_NS_4_0, configElement))
{
- return;
+ Map<String, String> props = null;
+ if (!properties.isEmpty()) {
+ props = new HashMap<String, String>(properties.size(), 1);
+ for (Prop ps : properties)
+ {
+ props.put(ps.getName(), ps.getValue());
+ }
+ }
+ Map<String, Feature> featuresMap = null;
+ if (!features.isEmpty()) {
+ featuresMap = new HashMap<String, Feature>(features.size(),
1);
+ for (Feature f : features)
+ {
+ featuresMap.put(f.getName(), f);
+ }
+ }
+ return CLIENT_CONFIG.equals(configElement) ? new
ClientConfig(configName, pre, post, props,
+ featuresMap) : new EndpointConfig(configName, pre, post, props,
featuresMap);
}
else
{
@@ -190,21 +223,21 @@
}
case XMLStreamConstants.START_ELEMENT : {
if (match(reader, JBOSSWS_JAXWS_CONFIG_NS_4_0, CONFIG_NAME)) {
- config.setConfigName(elementAsString(reader));
+ configName = elementAsString(reader);
}
else if (match(reader, JBOSSWS_JAXWS_CONFIG_NS_4_0, PRE_HANDLER_CHAINS))
{
UnifiedHandlerChainsMetaData uhcmd = parseHandlerChains(reader,
JAVAEE_NS, JBOSSWS_JAXWS_CONFIG_NS_4_0, PRE_HANDLER_CHAINS);
- config.setPreHandlerChains(uhcmd.getHandlerChains());
+ pre = uhcmd.getHandlerChains();
}
else if (match(reader, JBOSSWS_JAXWS_CONFIG_NS_4_0, POST_HANDLER_CHAINS))
{
UnifiedHandlerChainsMetaData uhcmd = parseHandlerChains(reader,
JAVAEE_NS, JBOSSWS_JAXWS_CONFIG_NS_4_0, POST_HANDLER_CHAINS);
- config.setPostHandlerChains(uhcmd.getHandlerChains());
+ post = uhcmd.getHandlerChains();
}
else if (match(reader, JBOSSWS_JAXWS_CONFIG_NS_4_0, FEATURE)) {
- config.setFeature(parseFeature(reader), true);
+ features.add(parseFeature(reader));
}
else if (match(reader, JBOSSWS_JAXWS_CONFIG_NS_4_0, PROPERTY)) {
- parseProperty(reader, config);
+ properties.add(parseProperty(reader));
}
else
{
@@ -216,7 +249,7 @@
throw MESSAGES.reachedEndOfXMLDocUnexpectedly(getDescriptorForLogs());
}
- private void parseProperty(XMLStreamReader reader, CommonConfig config) throws
XMLStreamException
+ private Prop parseProperty(XMLStreamReader reader) throws XMLStreamException
{
String name = null;
String value = null;
@@ -231,8 +264,7 @@
{
throw MESSAGES.couldNotGetPropertyName(getDescriptorForLogs());
}
- config.setProperty(name, value);
- return;
+ return new Prop(name, value);
}
else
{
@@ -256,6 +288,28 @@
throw MESSAGES.reachedEndOfXMLDocUnexpectedly(getDescriptorForLogs());
}
+ private class Prop {
+ private final String name;
+ private final String value;
+
+ public Prop(String name, String value)
+ {
+ super();
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+ }
+
private Feature parseFeature(XMLStreamReader reader) throws XMLStreamException
{
Feature feature = null;
Modified:
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/EndpointConfig.java
===================================================================
---
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/EndpointConfig.java 2013-12-03
14:47:28 UTC (rev 18121)
+++
spi/branches/JBWS-3739/src/main/java/org/jboss/wsf/spi/metadata/config/EndpointConfig.java 2013-12-03
23:49:41 UTC (rev 18122)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2013, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -21,6 +21,11 @@
*/
package org.jboss.wsf.spi.metadata.config;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
+
/**
* A JBossWS endpoint configuration
*
@@ -30,4 +35,11 @@
public class EndpointConfig extends AbstractCommonConfig
{
public static final String STANDARD_ENDPOINT_CONFIG =
"Standard-Endpoint-Config";
+
+ public EndpointConfig(String configName, List<UnifiedHandlerChainMetaData>
preHandlerChains,
+ List<UnifiedHandlerChainMetaData> postHandlerChains, Map<String,
String> properties,
+ Map<String, Feature> features)
+ {
+ super(configName, preHandlerChains, postHandlerChains, properties, features);
+ }
}
Modified:
spi/branches/JBWS-3739/src/test/java/org/jboss/test/wsf/spi/metadata/config/ConfigMDParserTestCase.java
===================================================================
---
spi/branches/JBWS-3739/src/test/java/org/jboss/test/wsf/spi/metadata/config/ConfigMDParserTestCase.java 2013-12-03
14:47:28 UTC (rev 18121)
+++
spi/branches/JBWS-3739/src/test/java/org/jboss/test/wsf/spi/metadata/config/ConfigMDParserTestCase.java 2013-12-03
23:49:41 UTC (rev 18122)
@@ -51,8 +51,8 @@
ClientConfig cc = clientConfigs.get(0);
assertEquals("Standard Client", cc.getConfigName());
assertTrue(cc.getProperties().isEmpty());
- assertNull(cc.getPreHandlerChains());
- assertNull(cc.getPostHandlerChains());
+ assertTrue(cc.getPreHandlerChains() == null ||
cc.getPreHandlerChains().isEmpty());
+ assertTrue(cc.getPostHandlerChains() == null ||
cc.getPostHandlerChains().isEmpty());
List<EndpointConfig> endpointConfigs = metadata.getEndpointConfig();
assertEquals(2, endpointConfigs.size());
@@ -67,8 +67,8 @@
assertEquals("value2", ec.getProperty("name2"));
ec =
metadata.getEndpointConfigByName(".NET friendly Endpoint");
- assertNull(ec.getPreHandlerChains());
- assertNull(ec.getPostHandlerChains());
+ assertTrue(ec.getPreHandlerChains() == null ||
ec.getPreHandlerChains().isEmpty());
+ assertTrue(ec.getPostHandlerChains() == null ||
ec.getPostHandlerChains().isEmpty());
assertTrue(ec.getProperties().isEmpty());
assertTrue(ec.hasFeature("http://org.jboss.ws/binding/wsdl/dotnet"));
}