You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2014/11/26 19:59:37 UTC
[1/2] tomee git commit: TOMEE-1458 @WebServiceRef cxf config support
Repository: tomee
Updated Branches:
refs/heads/develop 5e71da640 -> 13f9589b5
TOMEE-1458 @WebServiceRef cxf config support
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/613a9ab1
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/613a9ab1
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/613a9ab1
Branch: refs/heads/develop
Commit: 613a9ab184f60983c4756c4aea51b5386a62a368
Parents: 5e71da6
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed Nov 26 19:58:06 2014 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Wed Nov 26 19:58:06 2014 +0100
----------------------------------------------------------------------
.../org/apache/openejb/assembler/DeployerEjb.java | 3 ++-
.../openejb/assembler/classic/Assembler.java | 6 +++---
.../openejb/assembler/classic/EjbJarBuilder.java | 2 +-
.../assembler/classic/EnterpriseBeanBuilder.java | 3 ++-
.../openejb/assembler/classic/JndiEncBuilder.java | 14 ++++++++++----
.../openejb/config/ConfigurationFactory.java | 10 +++++++---
.../core/ivm/naming/JaxWsServiceReference.java | 18 +++++++++++++++++-
.../openejb/testing/ApplicationComposers.java | 10 ++++++++++
.../openejb/web/LightweightWebAppBuilder.java | 4 ++--
.../openejb/server/cxf/ConfigureCxfSecurity.java | 3 ++-
.../org/apache/openejb/server/cxf/CxfService.java | 7 +++++++
.../tomee/catalina/TomcatWebAppBuilder.java | 6 +++---
.../java/org/apache/tomee/common/WsFactory.java | 6 +++++-
13 files changed, 71 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/613a9ab1/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java
index dbcc2c0..2258d3a 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java
@@ -120,7 +120,8 @@ public class DeployerEjb implements Deployer {
public DeployerEjb() {
deploymentLoader = new DeploymentLoader();
- configurationFactory = new ConfigurationFactory();
+ final ConfigurationFactory component = SystemInstance.get().getComponent(ConfigurationFactory.class);
+ configurationFactory = component == null ? new ConfigurationFactory() : component;
assembler = (Assembler) SystemInstance.get().getComponent(org.apache.openejb.spi.Assembler.class);
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/613a9ab1/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index 051fce3..71d1be2 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -683,11 +683,11 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
injections.addAll(injectionBuilder.buildInjections(appInfo.globalJndiEnc));
injections.addAll(injectionBuilder.buildInjections(appInfo.appJndiEnc));
- final JndiEncBuilder globalBuilder = new JndiEncBuilder(appInfo.globalJndiEnc, injections, appInfo.appId, null, GLOBAL_UNIQUE_ID, classLoader);
+ final JndiEncBuilder globalBuilder = new JndiEncBuilder(appInfo.globalJndiEnc, injections, appInfo.appId, null, GLOBAL_UNIQUE_ID, classLoader, appInfo.properties);
final Map<String, Object> globalBindings = globalBuilder.buildBindings(JndiEncBuilder.JndiScope.global);
final Context globalJndiContext = globalBuilder.build(globalBindings);
- final JndiEncBuilder appBuilder = new JndiEncBuilder(appInfo.appJndiEnc, injections, appInfo.appId, null, appInfo.appId, classLoader);
+ final JndiEncBuilder appBuilder = new JndiEncBuilder(appInfo.appJndiEnc, injections, appInfo.appId, null, appInfo.appId, classLoader, appInfo.properties);
final Map<String, Object> appBindings = appBuilder.buildBindings(JndiEncBuilder.JndiScope.app);
final Context appJndiContext = appBuilder.build(appBindings);
@@ -872,7 +872,7 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
final List<Injection> clientInjections = injectionBuilder.buildInjections(clientInfo.jndiEnc);
// build the enc
- final JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(clientInfo.jndiEnc, clientInjections, "Bean", clientInfo.moduleId, null, clientInfo.uniqueId, classLoader);
+ final JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(clientInfo.jndiEnc, clientInjections, "Bean", clientInfo.moduleId, null, clientInfo.uniqueId, classLoader, new Properties());
// if there is at least a remote client classes
// or if there is no local client classes
// then, we can set the client flag
http://git-wip-us.apache.org/repos/asf/tomee/blob/613a9ab1/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java
index d02bed5..68c14a3 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java
@@ -49,7 +49,7 @@ public class EjbJarBuilder {
final InjectionBuilder injectionBuilder = new InjectionBuilder(classLoader);
final List<Injection> moduleInjections = injectionBuilder.buildInjections(ejbJar.moduleJndiEnc);
moduleInjections.addAll(appInjections);
- final Context moduleJndiContext = new JndiEncBuilder(ejbJar.moduleJndiEnc, moduleInjections, null, ejbJar.moduleName, ejbJar.moduleUri, ejbJar.uniqueId, classLoader)
+ final Context moduleJndiContext = new JndiEncBuilder(ejbJar.moduleJndiEnc, moduleInjections, null, ejbJar.moduleName, ejbJar.moduleUri, ejbJar.uniqueId, classLoader, context.getProperties())
.build(JndiEncBuilder.JndiScope.module);
final HashMap<String, BeanContext> deployments = new HashMap<String, BeanContext>();
http://git-wip-us.apache.org/repos/asf/tomee/blob/613a9ab1/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java
index ca5b1fa..414d5ea 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java
@@ -145,7 +145,8 @@ class EnterpriseBeanBuilder {
}
// build the enc
- final JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(bean.jndiEnc, injections, transactionType, moduleContext.getId(), null, moduleContext.getUniqueId(), moduleContext.getClassLoader());
+ final JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(bean.jndiEnc, injections, transactionType, moduleContext.getId(), null,
+ moduleContext.getUniqueId(), moduleContext.getClassLoader(), moduleContext.getAppContext() == null ? moduleContext.getProperties() : moduleContext.getAppContext().getProperties());
final Context compJndiContext = jndiEncBuilder.build(JndiEncBuilder.JndiScope.comp);
bind(compJndiContext, "module", moduleContext.getModuleJndiContext());
bind(compJndiContext, "app", moduleContext.getAppContext().getAppJndiContext());
http://git-wip-us.apache.org/repos/asf/tomee/blob/613a9ab1/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
index 938ca46..89ba559 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
@@ -90,6 +90,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.TreeMap;
import java.util.concurrent.Callable;
@@ -114,16 +115,20 @@ public class JndiEncBuilder {
private final String uniqueId;
private final Collection<Injection> injections;
private final ClassLoader classLoader;
+ private final Properties properties;
private boolean useCrossClassLoaderRef = true;
private boolean client;
- public JndiEncBuilder(final JndiEncInfo jndiEnc, final Collection<Injection> injections, final String moduleId, final URI moduleUri, final String uniqueId, final ClassLoader classLoader) throws OpenEJBException {
- this(jndiEnc, injections, null, moduleId, moduleUri, uniqueId, classLoader);
+ public JndiEncBuilder(final JndiEncInfo jndiEnc, final Collection<Injection> injections, final String moduleId, final URI moduleUri,
+ final String uniqueId, final ClassLoader classLoader, final Properties properties) throws OpenEJBException {
+ this(jndiEnc, injections, null, moduleId, moduleUri, uniqueId, classLoader, properties);
}
- public JndiEncBuilder(final JndiEncInfo jndiEnc, final Collection<Injection> injections, final String transactionType, final String moduleId, final URI moduleUri, final String uniqueId, final ClassLoader classLoader) throws OpenEJBException {
+ public JndiEncBuilder(final JndiEncInfo jndiEnc, final Collection<Injection> injections, final String transactionType,
+ final String moduleId, final URI moduleUri, final String uniqueId, final ClassLoader classLoader, final Properties properties) throws OpenEJBException {
this.jndiEnc = jndiEnc;
+ this.properties = properties;
this.injections = injections;
beanManagedTransactions = transactionType != null && transactionType.equalsIgnoreCase("Bean");
@@ -500,7 +505,8 @@ public class JndiEncBuilder {
wsdlUrl,
portRefs,
handlerChains,
- injections);
+ injections,
+ properties);
bindings.put(normalize(referenceInfo.referenceName), reference);
} else {
final ServiceRefData serviceRefData = new ServiceRefData(referenceInfo.id,
http://git-wip-us.apache.org/repos/asf/tomee/blob/613a9ab1/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
index 7544c15..94fac6c 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
@@ -201,6 +201,7 @@ public class ConfigurationFactory implements OpenEjbConfigurationFactory {
if (SystemInstance.get().getComponent(ClassLoaderEnricher.class) == null) {
SystemInstance.get().setComponent(ClassLoaderEnricher.class, new ClassLoaderEnricher());
}
+ SystemInstance.get().setComponent(ConfigurationFactory.class, this);
// annotation deployer encapsulate some logic, to be able to push to it some config
// we give the ability here to get the internal deployer to push the config values
@@ -695,11 +696,14 @@ public class ConfigurationFactory implements OpenEjbConfigurationFactory {
return configureService(container, infoClass);
}
- private void loadPropertiesDeclaredConfiguration(final Openejb openejb) {
+ public static void loadPropertiesDeclaredConfiguration(final Openejb openejb) {
final Properties sysProps = new Properties(System.getProperties());
sysProps.putAll(SystemInstance.get().getProperties());
+ fillOpenEjb(openejb, sysProps);
+ }
+ public static void fillOpenEjb(final Openejb openejb, final Properties sysProps) {
for (final Map.Entry<Object, Object> entry : sysProps.entrySet()) {
final Object o = entry.getValue();
@@ -725,7 +729,7 @@ public class ConfigurationFactory implements OpenEjbConfigurationFactory {
}
}
- protected Object toConfigDeclaration(final String name, String value) throws URISyntaxException, OpenEJBException {
+ protected static Object toConfigDeclaration(final String name, String value) throws URISyntaxException, OpenEJBException {
// value = value.replaceFirst("(.)#", "$1%23");
value = value.replaceFirst("(provider=[^#=&]+)#", "$1%23");
@@ -734,7 +738,7 @@ public class ConfigurationFactory implements OpenEjbConfigurationFactory {
return toConfigDeclaration(name, uri);
}
- public Object toConfigDeclaration(final String id, final URI uri) throws OpenEJBException {
+ public static Object toConfigDeclaration(final String id, final URI uri) throws OpenEJBException {
final String serviceType;
try {
serviceType = uri.getHost();
http://git-wip-us.apache.org/repos/asf/tomee/blob/613a9ab1/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java
index a4a6b0f..34d6b64 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java
@@ -40,6 +40,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
public class JaxWsServiceReference extends Reference {
@@ -51,11 +52,17 @@ public class JaxWsServiceReference extends Reference {
private final URL wsdlUrl;
private final List<HandlerChainData> handlerChains = new ArrayList<HandlerChainData>();
private final Collection<Injection> injections;
+ private final Properties properties;
private PortAddressRegistry portAddressRegistry;
private final List<PortRefData> portRefs = new ArrayList<PortRefData>();
- public JaxWsServiceReference(final String id, final QName serviceQName, final Class<? extends Service> serviceClass, final QName portQName, final Class<?> referenceClass, final URL wsdlUrl, final List<PortRefData> portRefs, final List<HandlerChainData> handlerChains, final Collection<Injection> injections) {
+ public JaxWsServiceReference(final String id, final QName serviceQName, final Class<? extends Service> serviceClass,
+ final QName portQName, final Class<?> referenceClass, final URL wsdlUrl,
+ final List<PortRefData> portRefs, final List<HandlerChainData> handlerChains,
+ final Collection<Injection> injections,
+ final Properties properties) {
this.id = id;
+ this.properties = properties;
this.serviceQName = serviceQName;
this.serviceClass = serviceClass;
this.portQName = portQName;
@@ -156,6 +163,11 @@ public class JaxWsServiceReference extends Reference {
portRefs);
ServiceRefData.putServiceRefData(port, serviceRefData);
+ final WebServiceClientCustomizer customizer = SystemInstance.get().getComponent(WebServiceClientCustomizer.class);
+ if (customizer != null) {
+ customizer.customize(port, properties == null ? new Properties() : properties);
+ }
+
return port;
}
@@ -168,4 +180,8 @@ public class JaxWsServiceReference extends Reference {
}
return portAddressRegistry;
}
+
+ public interface WebServiceClientCustomizer {
+ void customize(Object port, Properties properties);
+ }
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/613a9ab1/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
index f4d129f..7fbd01f 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
@@ -701,6 +701,16 @@ public final class ApplicationComposers {
appModule = newModule;
}
+ // config for the app
+ for (final Map.Entry<Object, List<Method>> method : findAnnotatedMethods(configs, ApplicationConfiguration.class).entrySet()) {
+ for (final Method m : method.getValue()) {
+ final Object o = m.invoke(method.getKey());
+ if (Properties.class.isInstance(o)) {
+ appModule.getProperties().putAll(Properties.class.cast(o));
+ }
+ }
+ }
+
// copy ejb into beans if cdi is activated and init finder
for (final EjbModule ejb : appModule.getEjbModules()) {
final EnterpriseBean[] enterpriseBeans = ejb.getEjbJar().getEnterpriseBeans();
http://git-wip-us.apache.org/repos/asf/tomee/blob/613a9ab1/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java
index a64116c..9a8d0e9 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java
@@ -112,11 +112,11 @@ public class LightweightWebAppBuilder implements WebAppBuilder {
final Map<String, Object> bindings = new HashMap<String, Object>();
bindings.putAll(appContext.getBindings());
- bindings.putAll(new JndiEncBuilder(webAppInfo.jndiEnc, injections, webAppInfo.moduleId, "Bean", null, webAppInfo.uniqueId, classLoader).buildBindings(JndiEncBuilder.JndiScope.comp));
+ bindings.putAll(new JndiEncBuilder(webAppInfo.jndiEnc, injections, webAppInfo.moduleId, "Bean", null, webAppInfo.uniqueId, classLoader, appInfo.properties).buildBindings(JndiEncBuilder.JndiScope.comp));
final WebContext webContext = new WebContext(appContext);
webContext.setBindings(bindings);
- webContext.getBindings().putAll(new JndiEncBuilder(webAppInfo.jndiEnc, injections, webAppInfo.moduleId, "Bean", null, webAppInfo.uniqueId, classLoader).buildBindings(JndiEncBuilder.JndiScope.comp));
+ webContext.getBindings().putAll(new JndiEncBuilder(webAppInfo.jndiEnc, injections, webAppInfo.moduleId, "Bean", null, webAppInfo.uniqueId, classLoader, appInfo.properties).buildBindings(JndiEncBuilder.JndiScope.comp));
webContext.setJndiEnc(WebInitialContext.create(bindings, appContext.getGlobalJndiContext()));
webContext.setClassLoader(classLoader);
webContext.setId(webAppInfo.moduleId);
http://git-wip-us.apache.org/repos/asf/tomee/blob/613a9ab1/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ConfigureCxfSecurity.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ConfigureCxfSecurity.java b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ConfigureCxfSecurity.java
index a67f986..810f04f 100644
--- a/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ConfigureCxfSecurity.java
+++ b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ConfigureCxfSecurity.java
@@ -19,6 +19,7 @@ package org.apache.openejb.server.cxf;
import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.InterceptorProvider;
import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.openejb.core.webservices.PortData;
@@ -99,7 +100,7 @@ public class ConfigureCxfSecurity {
return cl.loadClass(validator).newInstance();
}
- public static final void setupWSS4JChain(Endpoint endpoint, Map<String, Object> inProps, Map<String, Object> outProps) {
+ public static final void setupWSS4JChain(InterceptorProvider endpoint, Map<String, Object> inProps, Map<String, Object> outProps) {
if (null != inProps && !inProps.isEmpty()) {
endpoint.getInInterceptors().add(new SAAJInInterceptor());
http://git-wip-us.apache.org/repos/asf/tomee/blob/613a9ab1/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
index 23ff1f3..a3fa5a5 100644
--- a/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
+++ b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
@@ -22,8 +22,11 @@ import org.apache.cxf.binding.soap.SoapTransportFactory;
import org.apache.cxf.transport.DestinationFactory;
import org.apache.openejb.BeanContext;
import org.apache.openejb.assembler.classic.util.ServiceConfiguration;
+import org.apache.openejb.core.ivm.naming.JaxWsServiceReference;
import org.apache.openejb.core.webservices.PortData;
+import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.server.cxf.client.SaajInterceptor;
+import org.apache.openejb.server.cxf.client.WebServiceInjectionConfigurator;
import org.apache.openejb.server.cxf.ejb.EjbWsContainer;
import org.apache.openejb.server.cxf.pojo.PojoWsContainer;
import org.apache.openejb.server.cxf.transport.util.CxfUtil;
@@ -53,6 +56,10 @@ public class CxfService extends WsService {
SaajInterceptor.registerInterceptors();
transportFactory = new SoapTransportFactory();
+
+ if (SystemInstance.get().getComponent(JaxWsServiceReference.WebServiceClientCustomizer.class) == null) {
+ SystemInstance.get().setComponent(JaxWsServiceReference.WebServiceClientCustomizer.class, new WebServiceInjectionConfigurator());
+ }
}
@Override
http://git-wip-us.apache.org/repos/asf/tomee/blob/613a9ab1/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
index ba0bcc2..62eb28b 100644
--- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
@@ -1303,7 +1303,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
// jndi bindings
webContext.getBindings().putAll(appContext.getBindings());
- webContext.getBindings().putAll(getJndiBuilder(classLoader, webAppInfo, injections).buildBindings(JndiEncBuilder.JndiScope.comp));
+ webContext.getBindings().putAll(getJndiBuilder(classLoader, webAppInfo, injections, appContext.getProperties()).buildBindings(JndiEncBuilder.JndiScope.comp));
final JavaeeInstanceManager instanceManager = new JavaeeInstanceManager(webContext);
standardContext.setInstanceManager(instanceManager);
@@ -1496,8 +1496,8 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
return (TomEEWebappClassLoader) old;
}
- private JndiEncBuilder getJndiBuilder(final ClassLoader classLoader, final WebAppInfo webAppInfo, final Set<Injection> injections) throws OpenEJBException {
- return new JndiEncBuilder(webAppInfo.jndiEnc, injections, webAppInfo.moduleId, "Bean", null, webAppInfo.uniqueId, classLoader);
+ private JndiEncBuilder getJndiBuilder(final ClassLoader classLoader, final WebAppInfo webAppInfo, final Set<Injection> injections, final Properties props) throws OpenEJBException {
+ return new JndiEncBuilder(webAppInfo.jndiEnc, injections, webAppInfo.moduleId, "Bean", null, webAppInfo.uniqueId, classLoader, props);
}
/**
http://git-wip-us.apache.org/repos/asf/tomee/blob/613a9ab1/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java b/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java
index 84f2d82..5e657cb 100644
--- a/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java
+++ b/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java
@@ -33,6 +33,7 @@ import java.net.URL;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
+import java.util.Properties;
public class WsFactory extends AbstractObjectFactory {
public Object getObjectInstance(final Object object, final Name name, final Context context, final Hashtable environment) throws Exception {
@@ -103,6 +104,8 @@ public class WsFactory extends AbstractObjectFactory {
injections = Collections.emptyList();
}
+ final Properties properties = new Properties();
+ properties.putAll(environment);
final JaxWsServiceReference serviceReference = new JaxWsServiceReference(serviceId,
serviceQName,
serviceClass, portQName,
@@ -110,7 +113,8 @@ public class WsFactory extends AbstractObjectFactory {
wsdlUrl,
portRefs,
handlerChains,
- injections);
+ injections,
+ properties);
value = serviceReference.getObject();
}
[2/2] tomee git commit: TOMEE-1458 @WebServiceRef cxf config support
- missing files
Posted by rm...@apache.org.
TOMEE-1458 @WebServiceRef cxf config support - missing files
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/13f9589b
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/13f9589b
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/13f9589b
Branch: refs/heads/develop
Commit: 13f9589b50be2093c791434403281b2d69a550f2
Parents: 613a9ab
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed Nov 26 19:58:53 2014 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Wed Nov 26 19:58:53 2014 +0100
----------------------------------------------------------------------
.../testing/ApplicationConfiguration.java | 28 +++++
.../client/WebServiceInjectionConfigurator.java | 113 +++++++++++++++++++
.../server/cxf/WebServiceInjectionTest.java | 85 ++++++++++++++
3 files changed, 226 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/13f9589b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationConfiguration.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationConfiguration.java b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationConfiguration.java
new file mode 100644
index 0000000..09819b2
--- /dev/null
+++ b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationConfiguration.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.openejb.testing;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ApplicationConfiguration {
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/13f9589b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/WebServiceInjectionConfigurator.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/WebServiceInjectionConfigurator.java b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/WebServiceInjectionConfigurator.java
new file mode 100644
index 0000000..78565a1
--- /dev/null
+++ b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/WebServiceInjectionConfigurator.java
@@ -0,0 +1,113 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.server.cxf.client;
+
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.assembler.classic.OpenEjbConfiguration;
+import org.apache.openejb.assembler.classic.ServiceInfo;
+import org.apache.openejb.config.ConfigurationFactory;
+import org.apache.openejb.config.sys.Openejb;
+import org.apache.openejb.config.sys.Service;
+import org.apache.openejb.core.ivm.naming.JaxWsServiceReference;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+
+import static java.util.Arrays.asList;
+import static org.apache.openejb.server.cxf.ConfigureCxfSecurity.getPropsFromProperties;
+import static org.apache.openejb.server.cxf.ConfigureCxfSecurity.setupWSS4JChain;
+import static org.apache.openejb.server.cxf.transport.util.CxfUtil.configureInterceptors;
+
+/**
+ * Used to configure a @WebServiceRef.
+ * Config uses application.properties.
+ * Format is:
+ *
+ * # global for all clients
+ * cxf.jaxws.client.out-interceptors = com.foo.MyInInterceptor
+ * # specific
+ * cxf.jaxws.client.{ns}MyPort.out-interceptors = com.foo.MyInInterceptor
+ *
+ * Services can be defines in tomee.xml or application.properties.
+ *
+ * Note: resources.xml are ignored for now (to be enhanced)
+ */
+public class WebServiceInjectionConfigurator implements JaxWsServiceReference.WebServiceClientCustomizer {
+ @Override
+ public void customize(final Object o, final Properties properties) {
+ try {
+ configure(ClientProxy.getClient(o), properties);
+ } catch (final Exception e) {
+ Logger.getInstance(LogCategory.CXF, WebServiceInjectionConfigurator.class.getName())
+ .error(e.getMessage(), e);
+ }
+ }
+
+ private void configure(final Client client, final Properties properties) {
+ if (properties == null) {
+ return;
+ }
+
+ for (final String suffix : asList("", client.getEndpoint().getEndpointInfo().getName().toString() + ".")) {
+ // wss4j which is historically quite particular
+ setupWSS4JChain(client,
+ getPropsFromProperties(properties, "cxf.jaxws.client.wss4j.in." + suffix),
+ getPropsFromProperties(properties, "cxf.jaxws.client.wss4j.out." + suffix));
+
+ // here (ie at runtime) we have no idea which services were linked to the app
+ // so using tomee.xml ones for now (not that shocking since we externalize the config with this class)
+ final OpenEjbConfiguration config = SystemInstance.get().getComponent(OpenEjbConfiguration.class);
+ final List<ServiceInfo> services = new ArrayList<ServiceInfo>(config.facilities != null && config.facilities.services != null ? config.facilities.services : Collections.<ServiceInfo>emptyList());
+ services.addAll(getServices(properties));
+ configureInterceptors(client, "cxf.jaxws.client." + suffix, services, properties);
+ }
+ }
+
+ private Collection<ServiceInfo> getServices(final Properties properties) {
+ final ConfigurationFactory cf = SystemInstance.get().getComponent(ConfigurationFactory.class);
+ if (cf == null || !ConfigurationFactory.class.isInstance(cf)) {
+ return Collections.emptyList();
+ }
+
+ final Openejb openejb = new Openejb();
+ ConfigurationFactory.fillOpenEjb(openejb, properties);
+
+ final List<Service> services = openejb.getServices();
+ if (services.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ final Collection<ServiceInfo> info = new ArrayList<ServiceInfo>(services.size());
+ for (final Service s : services) {
+ try {
+ info.add(cf.configureService(s, ServiceInfo.class));
+ } catch (final OpenEJBException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ return info;
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/13f9589b/server/openejb-cxf/src/test/java/org/apache/openejb/server/cxf/WebServiceInjectionTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf/src/test/java/org/apache/openejb/server/cxf/WebServiceInjectionTest.java b/server/openejb-cxf/src/test/java/org/apache/openejb/server/cxf/WebServiceInjectionTest.java
new file mode 100644
index 0000000..159e40c
--- /dev/null
+++ b/server/openejb-cxf/src/test/java/org/apache/openejb/server/cxf/WebServiceInjectionTest.java
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.server.cxf;
+
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.ApplicationConfiguration;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.Module;
+import org.apache.openejb.testng.PropertiesBuilder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ejb.Singleton;
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceRef;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@EnableServices("jax-ws")
+@RunWith(ApplicationComposer.class)
+public class WebServiceInjectionTest {
+ @Module
+ @Classes(innerClassesAsBean = true)
+ public WebApp module() {
+ return new WebApp();
+ }
+
+ @WebServiceRef
+ private MyWsApi api;
+
+ @Test
+ public void checkInjection() {
+ // assertEquals("ok", api.test()); // local call so skip it but check config which is actually the only interesting thing
+ final Client client = ClientProxy.getClient(api);
+ assertNotNull(client);
+ assertEquals(1, client.getOutInterceptors().size());
+ assertTrue(LoggingOutInterceptor.class.isInstance(client.getOutInterceptors().iterator().next()));
+ }
+
+ @ApplicationConfiguration
+ public Properties props() {
+ // return new PropertiesBuilder().p("cxf.jaxws.client.out-interceptors", LoggingOutInterceptor.class.getName()).build();
+ // return new PropertiesBuilder().p("cxf.jaxws.client.{http://cxf.server.openejb.apache.org/}MyWebservicePort.out-interceptors", LoggingOutInterceptor.class.getName()).build();
+ return new PropertiesBuilder()
+ .p("cxf.jaxws.client.{http://cxf.server.openejb.apache.org/}MyWebservicePort.out-interceptors", "loo")
+ .p("loo", "new://Service?class-name=" + LoggingOutInterceptor.class.getName())
+ .build();
+ }
+
+ @WebService
+ public static interface MyWsApi {
+ String test();
+ }
+
+ @WebService
+ @Singleton
+ public static class MyWebservice implements MyWsApi {
+ @Override
+ public String test() {
+ return "ok";
+ }
+ }
+}