Author: heiko.braun(a)jboss.com
Date: 2006-12-14 07:31:13 -0500 (Thu, 14 Dec 2006)
New Revision: 1646
Modified:
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSEndpointMetaDataBuilder.java
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSProviderMetaDataBuilder.java
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSServerMetaDataBuilder.java
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
trunk/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java
trunk/src/main/java/org/jboss/ws/metadata/umdm/ClientEndpointMetaData.java
trunk/src/main/java/org/jboss/ws/metadata/umdm/ServerEndpointMetaData.java
Log:
cleanup config parsing routines
Modified:
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSEndpointMetaDataBuilder.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSEndpointMetaDataBuilder.java 2006-12-14
12:31:04 UTC (rev 1645)
+++
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSEndpointMetaDataBuilder.java 2006-12-14
12:31:13 UTC (rev 1646)
@@ -44,7 +44,7 @@
// provide logging
private final Logger log = Logger.getLogger(JAXWSEndpointMetaDataBuilder.class);
- public abstract ServerEndpointMetaData buildEndpoint(UnifiedMetaData wsMetaData,
UnifiedDeploymentInfo udi, Class<?> sepClass, String linkName) throws IOException;
+ public abstract ServerEndpointMetaData buildEndpointMetaData(UnifiedMetaData
wsMetaData, UnifiedDeploymentInfo udi, Class<?> sepClass, String linkName) throws
IOException;
protected void processBindingType(EndpointMetaData epMetaData, Class<?>
wsClass)
{
Modified:
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSProviderMetaDataBuilder.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSProviderMetaDataBuilder.java 2006-12-14
12:31:04 UTC (rev 1645)
+++
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSProviderMetaDataBuilder.java 2006-12-14
12:31:13 UTC (rev 1646)
@@ -67,7 +67,7 @@
*/
@Override
- public ServerEndpointMetaData buildEndpoint(UnifiedMetaData wsMetaData,
UnifiedDeploymentInfo udi, Class<?> sepClass, String linkName) throws IOException
+ public ServerEndpointMetaData buildEndpointMetaData(UnifiedMetaData wsMetaData,
UnifiedDeploymentInfo udi, Class<?> sepClass, String linkName) throws IOException
{
// 5.3 Conformance (Provider implementation): A Provider based service endpoint
implementation MUST
// implement a typed Provider interface.
Modified:
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSServerMetaDataBuilder.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSServerMetaDataBuilder.java 2006-12-14
12:31:04 UTC (rev 1645)
+++
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSServerMetaDataBuilder.java 2006-12-14
12:31:13 UTC (rev 1646)
@@ -56,6 +56,6 @@
{
JAXWSEndpointMetaDataBuilder builder = getEndpointBuilder(beanClass);
if (builder != null)
- builder.buildEndpoint(umd, udi, beanClass, beanName);
+ builder.buildEndpointMetaData(umd, udi, beanClass, beanName);
}
}
Modified:
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2006-12-14
12:31:04 UTC (rev 1645)
+++
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2006-12-14
12:31:13 UTC (rev 1646)
@@ -966,7 +966,7 @@
jaxbCtx = null;
}
- public ServerEndpointMetaData buildEndpoint(UnifiedMetaData wsMetaData,
UnifiedDeploymentInfo udi, Class<?> sepClass, String linkName)
+ public ServerEndpointMetaData buildEndpointMetaData(UnifiedMetaData wsMetaData,
UnifiedDeploymentInfo udi, Class<?> sepClass, String linkName)
{
try
{
Modified: trunk/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java 2006-12-14
12:31:04 UTC (rev 1645)
+++ trunk/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java 2006-12-14
12:31:13 UTC (rev 1646)
@@ -36,7 +36,7 @@
import java.io.IOException;
import java.net.URL;
-/**
+/**
* A factory for the JBossWS endpoint/client configuration
*
* @author Thomas.Diesler(a)jboss.org
@@ -46,7 +46,7 @@
{
// provide logging
private final Logger log = Logger.getLogger(JBossWSConfigFactory.class);
-
+
private static String URN_JAXRPC_CONFIG = "urn:jboss:jaxrpc-config:2.0";
private static String URN_JAXWS_CONFIG = "urn:jboss:jaxws-config:2.0";
@@ -62,27 +62,39 @@
return new JBossWSConfigFactory();
}
- public Object parse(URL configURL) throws IOException, JBossXBException
+ public Object parse(URL configURL)
{
log.debug("parse: " + configURL);
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- unmarshaller.setValidation(true);
- unmarshaller.setSchemaValidation(true);
-
Object wsConfig;
- String nsURI = getNamespaceURI(configURL);
- if (URN_JAXRPC_CONFIG.equals(nsURI))
+ try
{
- wsConfig = unmarshaller.unmarshal(configURL.openStream(), new OMFactoryJAXRPC(),
null);
+
+ Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
+ unmarshaller.setValidation(true);
+ unmarshaller.setSchemaValidation(true);
+
+ String nsURI = getNamespaceURI(configURL);
+ if (URN_JAXRPC_CONFIG.equals(nsURI))
+ {
+ wsConfig = unmarshaller.unmarshal(configURL.openStream(), new
OMFactoryJAXRPC(), null);
+ }
+ else if (URN_JAXWS_CONFIG.equals(nsURI))
+ {
+ wsConfig = unmarshaller.unmarshal(configURL.openStream(), new
OMFactoryJAXWS(), null);
+ }
+ else
+ {
+ throw new WSException("Invalid config namespace: " + nsURI);
+ }
+
}
- else if (URN_JAXWS_CONFIG.equals(nsURI))
+ catch (JBossXBException e)
{
- wsConfig = unmarshaller.unmarshal(configURL.openStream(), new OMFactoryJAXWS(),
null);
+ throw new WSException("Error while parsing configuration", e);
}
- else
- {
- throw new WSException("Invalid config namespace: " + nsURI);
+ catch (IOException e) {
+ throw new WSException("Failed to read config file: " + configURL, e);
}
return wsConfig;
Modified: trunk/src/main/java/org/jboss/ws/metadata/umdm/ClientEndpointMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/umdm/ClientEndpointMetaData.java 2006-12-14
12:31:04 UTC (rev 1645)
+++ trunk/src/main/java/org/jboss/ws/metadata/umdm/ClientEndpointMetaData.java 2006-12-14
12:31:13 UTC (rev 1646)
@@ -69,81 +69,81 @@
if (endpointConfig == null)
{
String configName = getConfigName();
- if (configName == null)
- {
- configName = "Standard Client";
- setConfigName(configName);
- }
-
String configFile = getConfigFile();
- if (configFile == null)
- {
- if (getType() == Type.JAXRPC)
- {
- configFile = "META-INF/standard-jaxrpc-client-config.xml";
- }
- else
- {
- configFile = "META-INF/standard-jaxws-client-config.xml";
- }
- setConfigFile(configFile);
- }
log.debug("getClientConfig: [name=" + configName + ",url=" +
configFile + "]");
- URL configURL = null;
- try
- {
- configURL = new URL(configFile);
- }
- catch (MalformedURLException ex)
- {
- // ignore
- }
-
- // Try to get the URL as resource
- if (configURL == null)
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- configURL = cl.getResource(configFile);
- if (configURL == null)
- throw new WSException("Cannot get resource: " + configFile);
- }
-
// Get the config root
- Object wsConfig;
- try
- {
- JBossWSConfigFactory factory = JBossWSConfigFactory.newInstance();
- wsConfig = factory.parse(configURL);
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception ex)
- {
- throw new WSException("Cannot parse client config", ex);
- }
+ URL configURL = filenameToURL(configFile);
+ JBossWSConfigFactory factory = JBossWSConfigFactory.newInstance();
+ Object wsConfig = factory.parse(configURL);
// Get the client config
if (wsConfig instanceof ConfigRootJAXRPC)
{
endpointConfig =
((ConfigRootJAXRPC)wsConfig).getClientConfigByName(configName);
- if (endpointConfig == null)
- throw new WSException("Cannot obtain client config: " +
configName);
}
else
{
endpointConfig =
((ConfigRootJAXWS)wsConfig).getClientConfigByName(configName);
- if (endpointConfig == null)
- throw new WSException("Cannot obtain client config: " +
configName);
}
+
+ if (endpointConfig == null)
+ throw new WSException("Cannot obtain client config: " +
configName);
}
return endpointConfig;
}
+ public String getConfigName() {
+ String configName = super.getConfigName();
+ if (configName == null)
+ {
+ configName = "Standard Client";
+ setConfigName(configName);
+ }
+ return configName;
+ }
+
+ public String getConfigFile() {
+ String configFile = super.getConfigFile();
+ if (configFile == null)
+ {
+ if (getType() == Type.JAXRPC)
+ {
+ configFile = "META-INF/standard-jaxrpc-client-config.xml";
+ }
+ else
+ {
+ configFile = "META-INF/standard-jaxws-client-config.xml";
+ }
+ setConfigFile(configFile);
+ }
+ return configFile;
+ }
+
+ private URL filenameToURL(String configFile) {
+ URL configURL = null;
+ try
+ {
+ configURL = new URL(configFile);
+ }
+ catch (MalformedURLException ex)
+ {
+ // ignore
+ }
+
+ // Try to get the URL as resource
+ if (configURL == null)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ configURL = cl.getResource(configFile);
+ if (configURL == null)
+ throw new WSException("Cannot get resource: " + configFile);
+ }
+ return configURL;
+ }
+
public String toString()
{
StringBuilder buffer = new StringBuilder("\nClientEndpointMetaData:");
Modified: trunk/src/main/java/org/jboss/ws/metadata/umdm/ServerEndpointMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/umdm/ServerEndpointMetaData.java 2006-12-14
12:31:04 UTC (rev 1645)
+++ trunk/src/main/java/org/jboss/ws/metadata/umdm/ServerEndpointMetaData.java 2006-12-14
12:31:13 UTC (rev 1646)
@@ -137,7 +137,7 @@
{
if (contextRoot != null && contextRoot.startsWith("/") == false)
throw new IllegalArgumentException("context root should start with
'/'");
-
+
this.contextRoot = contextRoot;
}
@@ -150,7 +150,7 @@
{
this.virtualHosts = virtualHosts;
}
-
+
public String getURLPattern()
{
return urlPattern;
@@ -160,7 +160,7 @@
{
if (urlPattern != null && urlPattern.startsWith("/") == false)
throw new IllegalArgumentException("url pattern should start with
'/'");
-
+
this.urlPattern = urlPattern;
}
@@ -190,80 +190,81 @@
if (endpointConfig == null)
{
String configName = getConfigName();
- if (configName == null)
- {
- configName = "Standard Endpoint";
- setConfigName(configName);
- }
-
String configFile = getConfigFile();
- if (configFile == null)
- {
- if (getType() == Type.JAXRPC)
- {
- configFile = "META-INF/standard-jaxrpc-endpoint-config.xml";
- }
- else
- {
- configFile = "META-INF/standard-jaxws-endpoint-config.xml";
- }
- setConfigFile(configFile);
- }
log.debug("getEndpointConfig: [name=" + configName + ",url="
+ configFile + "]");
- URL configURL = null;
- try
- {
- configURL = new URL(configFile);
- }
- catch (MalformedURLException ex)
- {
- // ignore
- }
-
- // Try to get the URL as resource
- if (configURL == null)
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- configURL = cl.getResource(configFile);
- if (configURL == null)
- throw new WSException("Cannot get resource: " + configFile);
- }
-
// Get the config root
- Object wsConfig;
- try
- {
- JBossWSConfigFactory factory = JBossWSConfigFactory.newInstance();
- wsConfig = factory.parse(configURL);
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception ex)
- {
- throw new WSException("Cannot parse client config", ex);
- }
+ URL configURL = filenameToURL(configFile);
+ JBossWSConfigFactory factory = JBossWSConfigFactory.newInstance();
+ Object wsConfig = factory.parse(configURL);
// Get the endpoint config
if (wsConfig instanceof ConfigRootJAXRPC)
{
endpointConfig =
((ConfigRootJAXRPC)wsConfig).getEndpointConfigByName(configName);
- if (endpointConfig == null)
- throw new WSException("Cannot obtain endpoint config: " +
configName);
}
else
{
endpointConfig =
((ConfigRootJAXWS)wsConfig).getEndpointConfigByName(configName);
- if (endpointConfig == null)
- throw new WSException("Cannot obtain endpoint config: " +
configName);
}
+
+ if (endpointConfig == null)
+ throw new WSException("Cannot obtain endpoint config: " +
configName);
}
+
return endpointConfig;
}
+ public String getConfigName() {
+ String configName = super.getConfigName();
+ if (configName == null)
+ {
+ configName = "Standard Endpoint";
+ setConfigName(configName);
+ }
+ return configName;
+ }
+
+ public String getConfigFile() {
+ String configFile = super.getConfigFile();
+ if (configFile == null)
+ {
+ if (getType() == Type.JAXRPC)
+ {
+ configFile = "META-INF/standard-jaxrpc-endpoint-config.xml";
+ }
+ else
+ {
+ configFile = "META-INF/standard-jaxws-endpoint-config.xml";
+ }
+ setConfigFile(configFile);
+ }
+ return configFile;
+ }
+
+ private URL filenameToURL(String configFile) {
+ URL configURL = null;
+ try
+ {
+ configURL = new URL(configFile);
+ }
+ catch (MalformedURLException ex)
+ {
+ // ignore
+ }
+
+ // Try to get the URL as resource
+ if (configURL == null)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ configURL = cl.getResource(configFile);
+ if (configURL == null)
+ throw new WSException("Cannot get resource: " + configFile);
+ }
+ return configURL;
+ }
+
public String toString()
{
StringBuilder buffer = new StringBuilder("\nServerEndpointMetaData:");