Author: alessio.soldano(a)jboss.com
Date: 2011-04-29 07:02:20 -0400 (Fri, 29 Apr 2011)
New Revision: 14212
Added:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/ClientConfig.java
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/CommonConfig.java
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/ConfigMetaDataParser.java
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/ConfigRoot.java
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/EndpointConfig.java
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/Feature.java
spi/trunk/src/main/resources/
spi/trunk/src/main/resources/schema/
spi/trunk/src/main/resources/schema/jbossws-jaxws-config_4_0.xsd
spi/trunk/src/test/java/org/jboss/test/wsf/spi/metadata/config/
spi/trunk/src/test/java/org/jboss/test/wsf/spi/metadata/config/ConfigMDParserTestCase.java
spi/trunk/src/test/resources/metadata/config/
spi/trunk/src/test/resources/metadata/config/test-jaxws-config.xml
Modified:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/AbstractHandlerChainsMetaDataParser.java
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/ParserConstants.java
Log:
[JBWS-3283] Providing a stax parser of jaxws endpoint config descriptors and adding the
minimal required metadata for them in spi
Modified:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/AbstractHandlerChainsMetaDataParser.java
===================================================================
---
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/AbstractHandlerChainsMetaDataParser.java 2011-04-28
22:20:13 UTC (rev 14211)
+++
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/AbstractHandlerChainsMetaDataParser.java 2011-04-29
11:02:20 UTC (rev 14212)
@@ -44,13 +44,19 @@
{
protected UnifiedHandlerChainsMetaData parseHandlerChains(XMLStreamReader reader,
String nsUri) throws XMLStreamException
{
+ return this.parseHandlerChains(reader, nsUri, nsUri, HANDLER_CHAINS);
+ }
+
+ protected UnifiedHandlerChainsMetaData parseHandlerChains(XMLStreamReader reader,
String nsUri,
+ String handlerChainsElementNS, String handlerChainsElementName) throws
XMLStreamException
+ {
UnifiedHandlerChainsMetaData handlerChains = new UnifiedHandlerChainsMetaData();
while (reader.hasNext())
{
switch (reader.nextTag())
{
case XMLStreamConstants.END_ELEMENT : {
- if (match(reader, nsUri, HANDLER_CHAINS))
+ if (match(reader, handlerChainsElementNS, handlerChainsElementName))
{
return handlerChains;
}
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/ParserConstants.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/ParserConstants.java 2011-04-28
22:20:13 UTC (rev 14211)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/ParserConstants.java 2011-04-29
11:02:20 UTC (rev 14212)
@@ -101,4 +101,30 @@
public static final String ENABLED = "enabled";
public static final String REQUIRED = "required";
+
+ public static final String JBOSSWS_JAXWS_CONFIG_NS =
"urn:jboss:jbossws-jaxws-config:4.0";
+
+ public static final String JAXWS_CONFIG = "jaxws-config";
+
+ public static final String ENDPOINT_CONFIG = "endpoint-config";
+
+ public static final String CLIENT_CONFIG = "client-config";
+
+ public static final String CONFIG_NAME = "config-name";
+
+ public static final String PRE_HANDLER_CHAINS = "pre-handler-chains";
+
+ public static final String POST_HANDLER_CHAINS = "post-handler-chains";
+
+ public static final String FEATURE = "feature";
+
+ public static final String PROPERTY = "property";
+
+ public static final String PROPERTY_NAME = "property-name";
+
+ public static final String PROPERTY_VALUE = "property-value";
+
+ public static final String FEATURE_NAME = "feature-name";
+
+ public static final String FEATURE_DATA = "feature-data";
}
Added: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/ClientConfig.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/ClientConfig.java
(rev 0)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/ClientConfig.java 2011-04-29
11:02:20 UTC (rev 14212)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.
+ *
+ * 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.wsf.spi.metadata.config;
+
+/**
+ * A JBossWS client configuration
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 29-Apr-2011
+ */
+public class ClientConfig extends CommonConfig
+{
+}
Added: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/CommonConfig.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/CommonConfig.java
(rev 0)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/CommonConfig.java 2011-04-29
11:02:20 UTC (rev 14212)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.
+ *
+ * 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.wsf.spi.metadata.config;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
+
+/**
+ * A common configuration
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 29-Apr-2011
+ */
+public abstract class CommonConfig
+{
+ private String configName;
+ private Map<String, Feature> features = new HashMap<String, Feature>();
+ private Map<String, String> properties = new HashMap<String, String>();
+ private List<UnifiedHandlerChainMetaData> preHandlerChains;
+ private List<UnifiedHandlerChainMetaData> postHandlerChains;
+
+ 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;
+ if (type == HandlerType.PRE)
+ handlerChains = getPreHandlerChains();
+ else if (type == HandlerType.POST)
+ handlerChains = getPostHandlerChains();
+ else throw new IllegalArgumentException("Invalid handler type: " +
type);
+ return handlerChains;
+ }
+
+ public String getConfigName()
+ {
+ 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);
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+}
Added:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/ConfigMetaDataParser.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/ConfigMetaDataParser.java
(rev 0)
+++
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/ConfigMetaDataParser.java 2011-04-29
11:02:20 UTC (rev 14212)
@@ -0,0 +1,270 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.
+ *
+ * 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.wsf.spi.metadata.config;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.jboss.wsf.spi.metadata.ParserConstants.*;
+import static org.jboss.wsf.spi.util.StAXUtils.elementAsString;
+import static org.jboss.wsf.spi.util.StAXUtils.match;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.metadata.AbstractHandlerChainsMetaDataParser;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainsMetaData;
+import org.jboss.wsf.spi.util.StAXUtils;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * The parser for the configuration metadata
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 29-Apr-2011
+ */
+public class ConfigMetaDataParser extends AbstractHandlerChainsMetaDataParser
+{
+ private ConfigMetaDataParser()
+ {
+ super();
+ }
+
+ public static ConfigRoot parse(InputStream is) throws IOException
+ {
+ try
+ {
+ XMLStreamReader xmlr = StAXUtils.createXMLStreamReader(is);
+ return parse(xmlr);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new IOException(e);
+ }
+ }
+
+ public static ConfigRoot parse(XMLStreamReader reader) throws XMLStreamException
+ {
+ int iterate;
+ try
+ {
+ iterate = reader.nextTag();
+ }
+ catch (XMLStreamException e)
+ {
+ // skip non-tag elements
+ iterate = reader.nextTag();
+ }
+ ConfigRoot configRoot = null;
+ switch (iterate)
+ {
+ case END_ELEMENT : {
+ // we're done
+ break;
+ }
+ case START_ELEMENT : {
+
+ if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, JAXWS_CONFIG))
+ {
+ ConfigMetaDataParser parser = new ConfigMetaDataParser();
+ configRoot = parser.parseConfigRoot(reader);
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected element: " +
reader.getLocalName());
+ }
+ }
+ }
+ return configRoot;
+ }
+
+ private ConfigRoot parseConfigRoot(XMLStreamReader reader) throws XMLStreamException
+ {
+ ConfigRoot configRoot = new ConfigRoot();
+ while (reader.hasNext())
+ {
+ switch (reader.nextTag())
+ {
+ case XMLStreamConstants.END_ELEMENT : {
+ if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, JAXWS_CONFIG))
+ {
+ return configRoot;
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected end tag: " +
reader.getLocalName());
+ }
+ }
+ case XMLStreamConstants.START_ELEMENT : {
+ if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, ENDPOINT_CONFIG)) {
+ EndpointConfig epConfig = new EndpointConfig();
+ parseConfig(reader, epConfig, ENDPOINT_CONFIG);
+ configRoot.addEndpointConfig(epConfig);
+ }
+ else if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, CLIENT_CONFIG)) {
+ ClientConfig clConfig = new ClientConfig();
+ parseConfig(reader, clConfig, CLIENT_CONFIG);
+ configRoot.addClientConfig(clConfig);
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected element: " +
reader.getLocalName());
+ }
+ }
+ }
+ }
+ throw new IllegalStateException("Reached end of xml document
unexpectedly");
+ }
+
+ private void parseConfig(XMLStreamReader reader, CommonConfig config, String
configElement) throws XMLStreamException
+ {
+ while (reader.hasNext())
+ {
+ switch (reader.nextTag())
+ {
+ case XMLStreamConstants.END_ELEMENT : {
+ if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, configElement))
+ {
+ return;
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected end tag: " +
reader.getLocalName());
+ }
+ }
+ case XMLStreamConstants.START_ELEMENT : {
+ if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, CONFIG_NAME)) {
+ config.setConfigName(elementAsString(reader));
+ }
+ else if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, PRE_HANDLER_CHAINS)) {
+ UnifiedHandlerChainsMetaData uhcmd = parseHandlerChains(reader,
JAVAEE_NS, JBOSSWS_JAXWS_CONFIG_NS, PRE_HANDLER_CHAINS);
+ config.setPreHandlerChains(uhcmd.getHandlerChains());
+ }
+ else if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, POST_HANDLER_CHAINS)) {
+ UnifiedHandlerChainsMetaData uhcmd = parseHandlerChains(reader,
JAVAEE_NS, JBOSSWS_JAXWS_CONFIG_NS, POST_HANDLER_CHAINS);
+ config.setPostHandlerChains(uhcmd.getHandlerChains());
+ }
+ else if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, FEATURE)) {
+ config.setFeature(parseFeature(reader), true);
+ }
+ else if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, PROPERTY)) {
+ parseProperty(reader, config);
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected element: " +
reader.getLocalName());
+ }
+ }
+ }
+ }
+ throw new IllegalStateException("Reached end of xml document
unexpectedly");
+ }
+
+ private void parseProperty(XMLStreamReader reader, CommonConfig config) throws
XMLStreamException
+ {
+ String name = null;
+ String value = null;
+ while (reader.hasNext())
+ {
+ switch (reader.nextTag())
+ {
+ case XMLStreamConstants.END_ELEMENT : {
+ if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, PROPERTY))
+ {
+ if (name == null)
+ {
+ throw new IllegalStateException("Could not get property
name!");
+ }
+ config.setProperty(name, value);
+ return;
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected end tag: " +
reader.getLocalName());
+ }
+ }
+ case XMLStreamConstants.START_ELEMENT : {
+ if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, PROPERTY_NAME)) {
+ name = elementAsString(reader);
+ }
+ else if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, PROPERTY_VALUE)) {
+ value = elementAsString(reader);
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected element: " +
reader.getLocalName());
+ }
+ }
+ }
+ }
+ throw new IllegalStateException("Reached end of xml document
unexpectedly");
+ }
+
+ private Feature parseFeature(XMLStreamReader reader) throws XMLStreamException
+ {
+ Feature feature = null;
+ while (reader.hasNext())
+ {
+ switch (reader.nextTag())
+ {
+ case XMLStreamConstants.END_ELEMENT : {
+ if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, FEATURE))
+ {
+ if (feature == null)
+ {
+ throw new IllegalStateException("Could not read feature
name!");
+ }
+ return feature;
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected end tag: " +
reader.getLocalName());
+ }
+ }
+ case XMLStreamConstants.START_ELEMENT : {
+ if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, FEATURE_NAME)) {
+ feature = new Feature(elementAsString(reader));
+ }
+ else if (match(reader, JBOSSWS_JAXWS_CONFIG_NS, FEATURE_DATA)) {
+ //not implemented yet
+ Logger.getLogger(this.getClass()).warn("Feature data not supported
yet!");
+ while (reader.hasNext()) {
+ reader.next();
+ if (reader.isEndElement() && match(reader,
JBOSSWS_JAXWS_CONFIG_NS, FEATURE_DATA))
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected element: " +
reader.getLocalName());
+ }
+ }
+ }
+ }
+ throw new IllegalStateException("Reached end of xml document
unexpectedly");
+ }
+}
Added: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/ConfigRoot.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/ConfigRoot.java
(rev 0)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/ConfigRoot.java 2011-04-29
11:02:20 UTC (rev 14212)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.
+ *
+ * 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.wsf.spi.metadata.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A JBossWS configuration
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 29-Apr-2011
+ */
+public class ConfigRoot
+{
+ private List<ClientConfig> clientConfigList = new
ArrayList<ClientConfig>();
+ private List<EndpointConfig> endpointConfigList = new
ArrayList<EndpointConfig>();
+
+ public List<ClientConfig> getClientConfig()
+ {
+ return clientConfigList;
+ }
+
+ public void addClientConfig(ClientConfig clientConfig)
+ {
+ this.clientConfigList.add(clientConfig);
+ }
+
+ public void addEndpointConfig(EndpointConfig endpointConfig)
+ {
+ this.endpointConfigList.add(endpointConfig);
+ }
+
+ public void setClientConfig(List<ClientConfig> clientConfig)
+ {
+ this.clientConfigList = clientConfig;
+ }
+
+ public List<EndpointConfig> getEndpointConfig()
+ {
+ return endpointConfigList;
+ }
+
+ public void setEndpointConfig(List<EndpointConfig> endpointConfig)
+ {
+ this.endpointConfigList = endpointConfig;
+ }
+
+ public ClientConfig getClientConfigByName(String configName)
+ {
+ ClientConfig config = null;
+ for(ClientConfig aux : clientConfigList)
+ {
+ if (aux.getConfigName().equals(configName))
+ {
+ config = aux;
+ break;
+ }
+ }
+
+ if (config == null && clientConfigList.size() == 1)
+ config = clientConfigList.get(0);
+
+ return config;
+ }
+
+ public EndpointConfig getEndpointConfigByName(String configName)
+ {
+ EndpointConfig config = null;
+ for(EndpointConfig aux : endpointConfigList)
+ {
+ if (aux.getConfigName().equals(configName))
+ {
+ config = aux;
+ break;
+ }
+ }
+
+ if (config == null && endpointConfigList.size() == 1)
+ config = endpointConfigList.get(0);
+
+ return config;
+ }
+
+ public CommonConfig getConfigByName(String name)
+ {
+ CommonConfig config = getClientConfigByName(name);
+ if(null == config)
+ config = getEndpointConfigByName(name);
+ return config;
+ }
+}
Added: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/EndpointConfig.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/EndpointConfig.java
(rev 0)
+++
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/EndpointConfig.java 2011-04-29
11:02:20 UTC (rev 14212)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.
+ *
+ * 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.wsf.spi.metadata.config;
+
+/**
+ * A JBossWS endpoint configuration
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 29-Apr-2011
+ */
+public class EndpointConfig extends CommonConfig
+{
+}
Added: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/Feature.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/Feature.java
(rev 0)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/config/Feature.java 2011-04-29
11:02:20 UTC (rev 14212)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.
+ *
+ * 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.wsf.spi.metadata.config;
+
+public class Feature
+{
+ private String name;
+
+ private Object data;
+
+ public Feature(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Object getData()
+ {
+ return data;
+ }
+
+ public void setData(Object data)
+ {
+ this.data = data;
+ }
+}
Added: spi/trunk/src/main/resources/schema/jbossws-jaxws-config_4_0.xsd
===================================================================
--- spi/trunk/src/main/resources/schema/jbossws-jaxws-config_4_0.xsd
(rev 0)
+++ spi/trunk/src/main/resources/schema/jbossws-jaxws-config_4_0.xsd 2011-04-29 11:02:20
UTC (rev 14212)
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsd:schema
xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jboss:jbossws-jaxws-config:4.0"
+ xmlns:tns="urn:jboss:jbossws-jaxws-config:4.0"
+
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.1">
+
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ This is the schema definition for JBossWS JAXWS configurations.
+ It relies on the handler definitions that are part of the standard J2EE-1.5
deployment descriptors.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <xsd:import
namespace="http://java.sun.com/xml/ns/javaee"
schemaLocation="javaee_web_services_1_2.xsd"/>
+
+ <xsd:element name="jaxws-config"
type="tns:jaxwsConfigType"/>
+ <xsd:complexType name="jaxwsConfigType">
+ <xsd:sequence>
+ <xsd:element name="endpoint-config"
type="tns:endpointConfigType" minOccurs="0"
maxOccurs="unbounded"/>
+ <xsd:element name="client-config"
type="tns:clientConfigType" minOccurs="0"
maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="endpointConfigType">
+ <xsd:complexContent>
+ <xsd:extension base="tns:commonConfigType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="clientConfigType">
+ <xsd:complexContent>
+ <xsd:extension base="tns:commonConfigType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="commonConfigType">
+ <xsd:sequence>
+ <xsd:element name="config-name" type="xsd:string"/>
+ <xsd:element name="pre-handler-chains"
type="javaee:handler-chainsType" minOccurs="0"/>
+ <xsd:element name="post-handler-chains"
type="javaee:handler-chainsType" minOccurs="0"/>
+ <xsd:element name="feature" type="tns:featureType""
minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="property" type="tns:propertyType"
minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="featureType">
+ <xsd:sequence>
+ <xsd:element name="feature-name" type="xsd:string"/>
+ <xsd:element name="feature-data" type="xsd:any"
minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="propertyType">
+ <xsd:sequence>
+ <xsd:element name="property-name" type="xsd:string"/>
+ <xsd:element name="property-value"
type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+</xsd:schema>
Added:
spi/trunk/src/test/java/org/jboss/test/wsf/spi/metadata/config/ConfigMDParserTestCase.java
===================================================================
---
spi/trunk/src/test/java/org/jboss/test/wsf/spi/metadata/config/ConfigMDParserTestCase.java
(rev 0)
+++
spi/trunk/src/test/java/org/jboss/test/wsf/spi/metadata/config/ConfigMDParserTestCase.java 2011-04-29
11:02:20 UTC (rev 14212)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.
+ *
+ * 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.test.wsf.spi.metadata.config;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.jboss.wsf.spi.metadata.config.ClientConfig;
+import org.jboss.wsf.spi.metadata.config.ConfigMetaDataParser;
+import org.jboss.wsf.spi.metadata.config.ConfigRoot;
+import org.jboss.wsf.spi.metadata.config.EndpointConfig;
+
+/**
+ * Test the UnifiedHandlersChainsMetaDataParser
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 29-Apr-2011
+ */
+public class ConfigMDParserTestCase extends TestCase
+{
+ public void testParse() throws Exception
+ {
+ InputStream is = new FileInputStream(new
File("src/test/resources/metadata/config/test-jaxws-config.xml"));
+ ConfigRoot metadata = ConfigMetaDataParser.parse(is);
+
+ List<ClientConfig> clientConfigs = metadata.getClientConfig();
+ assertEquals(1, clientConfigs.size());
+ ClientConfig cc = clientConfigs.get(0);
+ assertEquals("Standard Client", cc.getConfigName());
+ assertTrue(cc.getProperties().isEmpty());
+ assertNull(cc.getPreHandlerChains());
+ assertNull(cc.getPostHandlerChains());
+
+ List<EndpointConfig> endpointConfigs = metadata.getEndpointConfig();
+ assertEquals(2, endpointConfigs.size());
+
+ EndpointConfig ec = metadata.getEndpointConfigByName("Standard
Endpoint");
+ assertEquals(1, ec.getPreHandlerChains().size());
+ assertEquals(1, ec.getPreHandlerChains().get(0).getHandlers().size());
+ assertEquals(1, ec.getPostHandlerChains().size());
+ assertEquals(2, ec.getPostHandlerChains().get(0).getHandlers().size());
+ assertEquals(2, ec.getProperties().size());
+ assertEquals("value1", ec.getProperty("name1"));
+ assertEquals("value2", ec.getProperty("name2"));
+
+ ec =
metadata.getEndpointConfigByName(".NET friendly Endpoint");
+ assertNull(ec.getPreHandlerChains());
+ assertNull(ec.getPostHandlerChains());
+ assertTrue(ec.getProperties().isEmpty());
+ assertTrue(ec.hasFeature("http://org.jboss.ws/binding/wsdl/dotnet"));
+ }
+}
\ No newline at end of file
Added: spi/trunk/src/test/resources/metadata/config/test-jaxws-config.xml
===================================================================
--- spi/trunk/src/test/resources/metadata/config/test-jaxws-config.xml
(rev 0)
+++ spi/trunk/src/test/resources/metadata/config/test-jaxws-config.xml 2011-04-29 11:02:20
UTC (rev 14212)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0
schema/jbossws-jaxws-config_4_0.xsd">
+
+ <endpoint-config>
+ <config-name>Standard Endpoint</config-name>
+ <pre-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>Recording Handler</javaee:handler-name>
+
<javaee:handler-class>org.jboss.wsf.framework.invocation.RecordingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </pre-handler-chains>
+ <post-handler-chains>
+ <javaee:handler-chain>
+ <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
+ <javaee:handler>
+ <javaee:handler-name>WSAddressing Handler</javaee:handler-name>
+
<javaee:handler-class>org.jboss.ws.extensions.addressing.jaxws.WSAddressingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ <javaee:handler>
+ <javaee:handler-name>Recording Handler</javaee:handler-name>
+
<javaee:handler-class>org.jboss.wsf.framework.invocation.RecordingServerHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </post-handler-chains>
+ <property>
+ <property-name>name1</property-name>
+ <property-value>value1</property-value>
+ </property>
+ <property>
+ <property-name>name2</property-name>
+ <property-value>value2</property-value>
+ </property>
+ </endpoint-config>
+
+ <endpoint-config>
+ <
config-name>.NET friendly Endpoint</config-name>
+ <feature>
+ <feature-name>http://org.jboss.ws/binding/wsdl/dotnet</feature-name>
+ <feature-data>
+ foo-bar
+ <foo>foo</foo>
+ <bar>bar</bar>
+ </feature-data>
+ </feature>
+ </endpoint-config>
+
+ <client-config>
+ <config-name>Standard Client</config-name>
+ </client-config>
+
+</jaxws-config>
\ No newline at end of file