Author: asoldano
Date: 2014-10-03 05:03:48 -0400 (Fri, 03 Oct 2014)
New Revision: 18966
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java
Log:
[JBWS-3836] Convention for automatic predefined client/endpoint configuration retrieval
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2014-10-03
09:00:51 UTC (rev 18965)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2014-10-03
09:03:48 UTC (rev 18966)
@@ -556,7 +556,7 @@
protected <T> T createPort(QName portName, EndpointReferenceType epr,
Class<T> serviceEndpointInterface,
WebServiceFeature... features) {
T port = super.createPort(portName, epr, serviceEndpointInterface, features);
- setupClient(port, features);
+ setupClient(port, serviceEndpointInterface, features);
return port;
}
@@ -567,18 +567,21 @@
Mode mode,
WebServiceFeature... features) {
Dispatch<T> dispatch = super.createDispatch(portName, type, context, mode,
features);
- setupClient(dispatch, features);
+ setupClient(dispatch, type, features);
return dispatch;
}
- protected void setupClient(Object obj, WebServiceFeature... features) {
+ protected void setupClient(Object obj, Class<?> seiClass,
WebServiceFeature... features) {
Binding binding = ((BindingProvider)obj).getBinding();
Client client = obj instanceof DispatchImpl<?> ?
((DispatchImpl<?>)obj).getClient() : ClientProxy.getClient(obj);
client.getOutInterceptors().add(new HandlerChainSortInterceptor(binding));
if (ClassLoaderProvider.isSet()) { //optimization for avoiding checking for a
server config when we know for sure we're out-of-container
ServerConfig sc = getServerConfig();
if (sc != null) {
- ClientConfig config =
sc.getClientConfig(ClientConfig.STANDARD_CLIENT_CONFIG);
+ ClientConfig config = sc.getClientConfig(seiClass.getName());
+ if (config == null) {
+ config = sc.getClientConfig(ClientConfig.STANDARD_CLIENT_CONFIG);
+ }
if (config != null) {
CXFClientConfigurer helper = new CXFClientConfigurer();
helper.setupConfigHandlers(binding, config);
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java 2014-10-03
09:00:51 UTC (rev 18965)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java 2014-10-03
09:03:48 UTC (rev 18966)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2013, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2014, 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.
*
@@ -22,6 +22,7 @@
package org.jboss.wsf.stack.cxf.configuration;
import java.io.IOException;
+import java.net.URL;
import java.security.AccessController;
import java.util.List;
@@ -32,6 +33,7 @@
import org.jboss.ws.api.util.ServiceLoader;
import org.jboss.ws.common.management.AbstractServerConfig;
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
+import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
import org.jboss.wsf.spi.management.ServerConfig;
@@ -122,8 +124,9 @@
// ** Endpoint configuration setup **
// 1) default values
- String configName =
org.jboss.wsf.spi.metadata.config.EndpointConfig.STANDARD_ENDPOINT_CONFIG;
- String configFile = null;
+ //String configName =
org.jboss.wsf.spi.metadata.config.EndpointConfig.STANDARD_ENDPOINT_CONFIG;
+ String configName = implementor.getClass().getName();
+ String configFile =
org.jboss.wsf.spi.metadata.config.EndpointConfig.DEFAULT_ENDPOINT_CONFIG_FILE;
boolean specifiedConfig = false;
// 2) annotation contribution
EndpointConfig epConfigAnn =
implementor.getClass().getAnnotation(EndpointConfig.class);
@@ -150,32 +153,66 @@
configFile = epConfigFile;
}
// 4) setup of configuration
- if (configFile == null)
- {
- //use endpoint configs from AS domain
- ServerConfig sc = getServerConfig();
- org.jboss.wsf.spi.metadata.config.EndpointConfig config =
sc.getEndpointConfig(configName);
- if (config != null) {
- endpoint.setEndpointConfig(config);
- }
- if (config == null && specifiedConfig) {
- throw Messages.MESSAGES.couldNotFindEndpointConfigName(configName);
- }
- }
- else
- {
+ if (configFile !=
org.jboss.wsf.spi.metadata.config.EndpointConfig.DEFAULT_ENDPOINT_CONFIG_FILE) {
//look for provided endpoint config file
try
{
UnifiedVirtualFile vf = deploymentRoot.findChild(configFile);
- ConfigRoot config = ConfigMetaDataParser.parse(vf.toURL());
- endpoint.setEndpointConfig(config.getEndpointConfigByName(configName));
+ ConfigRoot configRoot = ConfigMetaDataParser.parse(vf.toURL());
+ org.jboss.wsf.spi.metadata.config.EndpointConfig config =
configRoot.getEndpointConfigByName(configName);
+ if (config == null && !specifiedConfig) {
+ config =
configRoot.getEndpointConfigByName(org.jboss.wsf.spi.metadata.config.EndpointConfig.STANDARD_ENDPOINT_CONFIG);
+ }
+ if (config != null) {
+ endpoint.setEndpointConfig(config);
+ }
}
catch (IOException e)
{
throw Messages.MESSAGES.couldNotReadConfigFile(configFile);
}
}
+ else
+ {
+ org.jboss.wsf.spi.metadata.config.EndpointConfig config = null;
+ URL url = implementor.getClass().getResource("/" + configFile);
+ if (url == null) {
+ UnifiedVirtualFile vf = deploymentRoot.findChildFailSafe(configFile);
+ if (vf != null) {
+ url = vf.toURL();
+ }
+ }
+ if (url != null) {
+ //the default file exists
+ try
+ {
+ ConfigRoot configRoot = ConfigMetaDataParser.parse(url);
+ config = configRoot.getEndpointConfigByName(configName);
+ if (config == null && !specifiedConfig) {
+ config =
configRoot.getEndpointConfigByName(org.jboss.wsf.spi.metadata.config.EndpointConfig.STANDARD_ENDPOINT_CONFIG);
+ }
+ }
+ catch (IOException e)
+ {
+ throw Messages.MESSAGES.couldNotReadConfigFile(configFile);
+ }
+ }
+ if (config == null) {
+ //use endpoint configs from AS domain
+ ServerConfig sc = getServerConfig();
+ config = sc.getEndpointConfig(configName);
+ if (config == null && !specifiedConfig) {
+ config =
sc.getEndpointConfig(org.jboss.wsf.spi.metadata.config.EndpointConfig.STANDARD_ENDPOINT_CONFIG);
+ }
+ if (config == null && specifiedConfig) {
+ throw Messages.MESSAGES.couldNotFindEndpointConfigName(configName);
+ }
+ }
+ if (config != null) {
+ endpoint.setEndpointConfig(config);
+ }
+ }
+
//JASPI
final JASPIAuthenticationProvider jaspiProvider = (JASPIAuthenticationProvider)
ServiceLoader.loadService(
JASPIAuthenticationProvider.class.getName(), null,
ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader());