You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by rm...@apache.org on 2018/12/06 08:39:47 UTC
svn commit: r1848271 - in /openwebbeans/meecrowave/trunk: integration-tests/
integration-tests/no-cxf/ integration-tests/no-cxf/src/
integration-tests/no-cxf/src/test/ integration-tests/no-cxf/src/test/java/
integration-tests/no-cxf/src/test/java/org/ ...
Author: rmannibucau
Date: Thu Dec 6 08:39:47 2018
New Revision: 1848271
URL: http://svn.apache.org/viewvc?rev=1848271&view=rev
Log:
MEECROWAVE-162 support to run without cxf and johnzon
Added:
openwebbeans/meecrowave/trunk/integration-tests/no-cxf/
openwebbeans/meecrowave/trunk/integration-tests/no-cxf/pom.xml
openwebbeans/meecrowave/trunk/integration-tests/no-cxf/src/
openwebbeans/meecrowave/trunk/integration-tests/no-cxf/src/test/
openwebbeans/meecrowave/trunk/integration-tests/no-cxf/src/test/java/
openwebbeans/meecrowave/trunk/integration-tests/no-cxf/src/test/java/org/
openwebbeans/meecrowave/trunk/integration-tests/no-cxf/src/test/java/org/apache/
openwebbeans/meecrowave/trunk/integration-tests/no-cxf/src/test/java/org/apache/meecrowave/
openwebbeans/meecrowave/trunk/integration-tests/no-cxf/src/test/java/org/apache/meecrowave/nocxf/
openwebbeans/meecrowave/trunk/integration-tests/no-cxf/src/test/java/org/apache/meecrowave/nocxf/itest/
openwebbeans/meecrowave/trunk/integration-tests/no-cxf/src/test/java/org/apache/meecrowave/nocxf/itest/RunWithoutCxfTest.java
openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/Cxfs.java
openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/logging/jul/AbstractDelegatingLogger.java
Modified:
openwebbeans/meecrowave/trunk/integration-tests/pom.xml
openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java
openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/ConfigurableBus.java
openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/JAXWSCdiExtension.java
openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/logging/jul/Log4j2Logger.java
openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/MeecrowaveExtension.java
openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/OWBAutoSetup.java
Added: openwebbeans/meecrowave/trunk/integration-tests/no-cxf/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/integration-tests/no-cxf/pom.xml?rev=1848271&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/integration-tests/no-cxf/pom.xml (added)
+++ openwebbeans/meecrowave/trunk/integration-tests/no-cxf/pom.xml Thu Dec 6 08:39:47 2018
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>integration-tests</artifactId>
+ <groupId>org.apache.meecrowave</groupId>
+ <version>1.2.5-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>no-cxf</artifactId>
+ <name>Meecrowave :: Integration Tests :: No CXF</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.meecrowave</groupId>
+ <artifactId>meecrowave-core</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-json_1.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jsonb_1.0_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jaxrs_2.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: openwebbeans/meecrowave/trunk/integration-tests/no-cxf/src/test/java/org/apache/meecrowave/nocxf/itest/RunWithoutCxfTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/integration-tests/no-cxf/src/test/java/org/apache/meecrowave/nocxf/itest/RunWithoutCxfTest.java?rev=1848271&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/integration-tests/no-cxf/src/test/java/org/apache/meecrowave/nocxf/itest/RunWithoutCxfTest.java (added)
+++ openwebbeans/meecrowave/trunk/integration-tests/no-cxf/src/test/java/org/apache/meecrowave/nocxf/itest/RunWithoutCxfTest.java Thu Dec 6 08:39:47 2018
@@ -0,0 +1,58 @@
+/*
+ * 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.meecrowave.nocxf.itest;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.net.URL;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.logging.log4j.core.util.IOUtils;
+import org.apache.meecrowave.Meecrowave;
+import org.junit.Test;
+
+public class RunWithoutCxfTest {
+
+ @Test
+ public void runServlet() throws IOException {
+ try (final Meecrowave container = new Meecrowave(new Meecrowave.Builder() {{
+ addServletContextInitializer((c, ctx) -> ctx.addServlet("test", new HttpServlet() {
+ @Override
+ protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException {
+ resp.getWriter()
+ .write("servlet :)");
+ }
+ }).addMapping("/test"));
+ }}.randomHttpPort()).bake()) {
+ final String url = "http://localhost:" + container.getConfiguration().getHttpPort() + "/test";
+ final StringWriter output = new StringWriter();
+ try (final InputStream stream = new URL(url).openStream()) {
+ IOUtils.copy(new InputStreamReader(stream), output);
+ }
+ assertEquals("servlet :)", output.toString().trim());
+ }
+ }
+}
Modified: openwebbeans/meecrowave/trunk/integration-tests/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/integration-tests/pom.xml?rev=1848271&r1=1848270&r2=1848271&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/integration-tests/pom.xml (original)
+++ openwebbeans/meecrowave/trunk/integration-tests/pom.xml Thu Dec 6 08:39:47 2018
@@ -42,6 +42,7 @@
<module>webservices</module>
<module>ssl</module>
<module>sse</module>
+ <module>no-cxf</module>
</modules>
<build>
Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java?rev=1848271&r1=1848270&r2=1848271&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java Thu Dec 6 08:39:47 2018
@@ -100,12 +100,11 @@ import org.apache.catalina.startup.Catal
import org.apache.catalina.startup.MeecrowaveContextConfig;
import org.apache.catalina.startup.Tomcat;
import org.apache.coyote.http2.Http2Protocol;
-import org.apache.cxf.BusFactory;
-import org.apache.johnzon.core.BufferStrategy;
import org.apache.meecrowave.api.StartListening;
import org.apache.meecrowave.api.StopListening;
import org.apache.meecrowave.cxf.ConfigurableBus;
import org.apache.meecrowave.cxf.CxfCdiAutoSetup;
+import org.apache.meecrowave.cxf.Cxfs;
import org.apache.meecrowave.io.IO;
import org.apache.meecrowave.lang.Substitutor;
import org.apache.meecrowave.logging.jul.Log4j2Logger;
@@ -188,7 +187,10 @@ public class Meecrowave implements AutoC
}
final ProvidedLoader loader = new ProvidedLoader(classLoader, configuration.isTomcatWrapLoader());
- final Consumer<Context> builtInCustomizer = c -> c.setLoader(loader);
+ final Consumer<Context> builtInCustomizer = c -> {
+ c.setLoader(loader);
+ configuration.getInitializers().forEach(i -> c.addServletContainerInitializer(i, emptySet()));
+ };
return deployWebapp(new DeploymentMeta(meta.context, meta.docBase, ofNullable(meta.consumer).map(c -> (Consumer<Context>) ctx -> {
builtInCustomizer.accept(ctx);
c.accept(ctx);
@@ -277,7 +279,9 @@ public class Meecrowave implements AutoC
final AtomicReference<Runnable> releaseSCI = new AtomicReference<>();
final ServletContainerInitializer meecrowaveInitializer = (c, ctx1) -> {
new OWBAutoSetup().onStartup(c, ctx1);
- new CxfCdiAutoSetup().onStartup(c, ctx1);
+ if (Cxfs.IS_PRESENT) {
+ new CxfCdiAutoSetup().onStartup(c, ctx1);
+ }
new TomcatAutoInitializer().onStartup(c, ctx1);
if (configuration.isInjectServletContainerInitializer()) {
@@ -715,7 +719,7 @@ public class Meecrowave implements AutoC
beforeStart();
- if (configuration.initializeClientBus && BusFactory.getDefaultBus(false) == null) {
+ if (configuration.initializeClientBus && Cxfs.IS_PRESENT && !Cxfs.hasDefaultBus()) {
clientBus = new ConfigurableBus();
clientBus.initProviders(configuration,
ofNullable(Thread.currentThread().getContextClassLoader()).orElseGet(ClassLoader::getSystemClassLoader));
@@ -975,9 +979,7 @@ public class Meecrowave implements AutoC
} catch (final LifecycleException e) {
throw new IllegalStateException(e);
} finally {
- if (BusFactory.getDefaultBus(false) == clientBus) { // after if runnables or listeners trigger CXF
- BusFactory.setDefaultBus(null);
- }
+ Cxfs.resetDefaultBusIfEquals(clientBus); // after if runnables or listeners trigger CXF
tomcat = null; // ensure we can call close() N times and not have side effects
contexts.clear();
if (clearCatalinaSystemProperties) {
@@ -1255,7 +1257,7 @@ public class Meecrowave implements AutoC
private boolean jaxrsLogProviders = false;
@CliOption(name = "jsonp-buffer-strategy", description = "JSON-P JAX-RS provider buffer strategy (see johnzon)")
- private String jsonpBufferStrategy = BufferStrategy.QUEUE.name();
+ private String jsonpBufferStrategy = "QUEUE";
@CliOption(name = "jsonp-max-string-length", description = "JSON-P JAX-RS provider max string limit size (see johnzon)")
private int jsonpMaxStringLen = 64 * 1024;
@@ -1370,6 +1372,9 @@ public class Meecrowave implements AutoC
private final Map<Class<?>, Object> extensions = new HashMap<>();
private final Collection<Consumer<Tomcat>> instanceCustomizers = new ArrayList<>();
+ @CliOption(name = "servlet-container-initializer", description = "ServletContainerInitializer instances.")
+ private Collection<ServletContainerInitializer> initializers = new ArrayList<>();
+
public Builder() { // load defaults
extensions.put(ValueTransformers.class, new ValueTransformers());
StreamSupport.stream(ServiceLoader.load(Meecrowave.ConfigurationCustomizer.class).spliterator(), false)
@@ -2097,6 +2102,14 @@ public class Meecrowave implements AutoC
configurationCustomizer.accept(this);
}
+ public void addServletContextInitializer(final ServletContainerInitializer initializer) {
+ initializers.add(initializer);
+ }
+
+ public Collection<ServletContainerInitializer> getInitializers() {
+ return initializers;
+ }
+
public String getJaxrsDefaultProviders() {
return jaxrsDefaultProviders;
}
Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/ConfigurableBus.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/ConfigurableBus.java?rev=1848271&r1=1848270&r2=1848271&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/ConfigurableBus.java (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/ConfigurableBus.java Thu Dec 6 08:39:47 2018
@@ -19,7 +19,6 @@
package org.apache.meecrowave.cxf;
import static java.util.Collections.singletonList;
-import static java.util.Optional.of;
import static java.util.Optional.ofNullable;
import static java.util.stream.Collectors.toList;
@@ -33,6 +32,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -99,10 +99,10 @@ public class ConfigurableBus extends Ext
final JsonReaderFactory readerFactory = provider.createReaderFactory(
new HashMap<String, Object>() {{
put(JsonParserFactoryImpl.SUPPORTS_COMMENTS, builder.isJsonpSupportsComment());
- of(builder.getJsonpMaxStringLen()).filter(v -> v > 0)
+ Optional.of(builder.getJsonpMaxStringLen()).filter(v -> v > 0)
.ifPresent(s -> put(JsonParserFactoryImpl.MAX_STRING_LENGTH,
s));
- of(builder.getJsonpMaxReadBufferLen()).filter(v -> v > 0)
+ Optional.of(builder.getJsonpMaxReadBufferLen()).filter(v -> v > 0)
.ifPresent(s -> put(JsonParserFactoryImpl.BUFFER_LENGTH,
s));
ofNullable(builder.getJsonpBufferStrategy()).ifPresent(
@@ -111,7 +111,7 @@ public class ConfigurableBus extends Ext
final JsonWriterFactory writerFactory = provider.createWriterFactory(
new HashMap<String, Object>() {{
put(JsonGenerator.PRETTY_PRINTING, builder.isJsonpPrettify());
- of(builder.getJsonpMaxWriteBufferLen()).filter(v -> v > 0)
+ Optional.of(builder.getJsonpMaxWriteBufferLen()).filter(v -> v > 0)
.ifPresent(v -> put(
JsonGeneratorFactoryImpl
.GENERATOR_BUFFER_LENGTH,
Added: openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/Cxfs.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/Cxfs.java?rev=1848271&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/Cxfs.java (added)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/Cxfs.java Thu Dec 6 08:39:47 2018
@@ -0,0 +1,50 @@
+/*
+ * 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.meecrowave.cxf;
+
+import org.apache.cxf.BusFactory;
+
+public class Cxfs {
+ public static final boolean IS_PRESENT;
+
+ static {
+ boolean present;
+ try {
+ Cxfs.class.getClassLoader().loadClass("org.apache.cxf.BusFactory");
+ present = true;
+ } catch (ClassNotFoundException e) {
+ present = false;
+ }
+ IS_PRESENT = present;
+ }
+
+ private Cxfs() {
+ // no-op
+ }
+
+ public static boolean hasDefaultBus() {
+ return org.apache.cxf.BusFactory.getDefaultBus(false) != null;
+ }
+
+ public static void resetDefaultBusIfEquals(final ConfigurableBus clientBus) {
+ if (clientBus != null && BusFactory.getDefaultBus(false) == clientBus) {
+ BusFactory.setDefaultBus(null);
+ }
+ }
+}
Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/JAXWSCdiExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/JAXWSCdiExtension.java?rev=1848271&r1=1848270&r2=1848271&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/JAXWSCdiExtension.java (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/JAXWSCdiExtension.java Thu Dec 6 08:39:47 2018
@@ -18,8 +18,6 @@
*/
package org.apache.meecrowave.cxf;
-import org.apache.cxf.Bus;
-import org.apache.cxf.endpoint.AbstractEndpointFactory;
import org.apache.meecrowave.Meecrowave;
import org.apache.meecrowave.logging.tomcat.LogFacade;
import org.apache.webbeans.component.OwbBean;
@@ -32,7 +30,8 @@ import javax.enterprise.inject.spi.BeanM
import javax.enterprise.inject.spi.BeforeShutdown;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ProcessBean;
-import javax.jws.WebService;
+
+import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
@@ -42,100 +41,120 @@ import java.util.List;
//
// todo: support WebServiceProvider, maybe clients?
public class JAXWSCdiExtension implements Extension {
- private boolean active;
-
- private final List<Bean<?>> serviceBeans = new ArrayList<>();
- private final Collection<Runnable> preShutdownTasks = new ArrayList<>();
-
- public JAXWSCdiExtension() {
- try {
- final ClassLoader loader = Thread.currentThread().getContextClassLoader();
- loader.loadClass("org.apache.cxf.jaxws.JaxWsServerFactoryBean");
- loader.loadClass("org.apache.cxf.service.model.SchemaInfo");
- active = true;
- } catch (final NoClassDefFoundError | ClassNotFoundException e) {
- active = false;
- }
- }
+ private final Impl impl = new Impl();
public <T> void collect(@Observes final ProcessBean<T> processBean) {
- if (active && processBean.getAnnotated().isAnnotationPresent(WebService.class)) {
- serviceBeans.add(processBean.getBean());
- }
+ impl.collect(processBean);
}
public void load(@Observes final AfterDeploymentValidation afterDeploymentValidation, final BeanManager beanManager) {
- if (!active || serviceBeans.isEmpty() ||
- !Meecrowave.Builder.class.cast(beanManager.getReference(beanManager.resolve(beanManager.getBeans(Meecrowave.Builder.class)), Meecrowave.Builder.class, null))
- .isJaxwsSupportIfAvailable()) {
- return;
- }
+ impl.load(afterDeploymentValidation, beanManager);
+ }
- final Bean<?> busBean = beanManager.resolve(beanManager.getBeans("cxf"));
- final Bus bus = Bus.class.cast(beanManager.getReference(busBean, Bus.class, beanManager.createCreationalContext(busBean)));
+ public void release(@Observes final BeforeShutdown beforeShutdown) {
+ impl.release(beforeShutdown);
+ }
- final Bean<?> mapperBean = beanManager.resolve(beanManager.getBeans(JAXWSAddressMapper.class));
- final JAXWSAddressMapper mapper;
- if (mapperBean == null) {
- mapper = type -> {
- WsMapping wsMapping = type.getAnnotation(WsMapping.class);
- return wsMapping != null
- ? wsMapping.value()
- : "/webservices/" + type.getSimpleName();
- };
- } else {
- mapper = JAXWSAddressMapper.class.cast(beanManager.getReference(mapperBean, JAXWSAddressMapper.class, beanManager.createCreationalContext(mapperBean)));
- }
+ private static class Impl implements Extension {
+ private boolean active;
+ private Class<? extends Annotation> marker;
- serviceBeans.forEach(bean -> {
- final Class<?> beanClass = OwbBean.class.isInstance(bean) ? OwbBean.class.cast(bean).getReturnType() : bean.getBeanClass();
+ private final List<Bean<?>> serviceBeans = new ArrayList<>();
+ private final Collection<Runnable> preShutdownTasks = new ArrayList<>();
- final ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ private Impl() {
try {
- final AbstractEndpointFactory aef = AbstractEndpointFactory.class.cast(loader.loadClass("org.apache.cxf.jaxws.JaxWsServerFactoryBean").getConstructor().newInstance());
- aef.setBus(bus);
- aef.setAddress(mapper.map(beanClass));
-
- final Class<? extends AbstractEndpointFactory> factoryClass = aef.getClass();
- factoryClass.getMethod("setStart", boolean.class).invoke(aef, true);
- factoryClass.getMethod("setServiceClass", Class.class).invoke(aef, beanClass);
-
- final CreationalContext<Object> creationalContext = beanManager.createCreationalContext(null);
- if (!beanManager.isNormalScope(bean.getScope())) {
- preShutdownTasks.add(creationalContext::release);
- }
- factoryClass.getMethod("setServiceBean", Object.class).invoke(aef, beanManager.getReference(bean, Object.class, creationalContext));
+ final ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ loader.loadClass("org.apache.cxf.jaxws.JaxWsServerFactoryBean");
+ loader.loadClass("org.apache.cxf.service.model.SchemaInfo");
+ marker = (Class<? extends Annotation>) loader.loadClass("javax.jws.WebService");
+ active = true;
+ } catch (final NoClassDefFoundError | ClassNotFoundException e) {
+ active = false;
+ }
+ }
- final Object server = factoryClass.getMethod("create").invoke(aef);
+ public <T> void collect(@Observes final ProcessBean<T> processBean) {
+ if (active && processBean.getAnnotated().isAnnotationPresent(marker)) {
+ serviceBeans.add(processBean.getBean());
+ }
+ }
- final Class<?> serverClass = server.getClass();
- serverClass.getMethod("start").invoke(server);
- preShutdownTasks.add(() -> {
- try {
- serverClass.getMethod("destroy").invoke(server);
- } catch (final NoClassDefFoundError | NoSuchMethodException | IllegalAccessException e) {
- throw new IllegalStateException(e);
- } catch (final InvocationTargetException e) {
- throw new IllegalStateException(e.getCause());
- }
- });
- } catch (final NoClassDefFoundError | ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException e) {
- throw new IllegalStateException(e);
- } catch (final InvocationTargetException e) {
- throw new IllegalStateException(e.getCause());
+ public void load(@Observes final AfterDeploymentValidation afterDeploymentValidation, final BeanManager beanManager) {
+ if (!active || serviceBeans.isEmpty() ||
+ !Meecrowave.Builder.class.cast(beanManager.getReference(beanManager.resolve(beanManager.getBeans(Meecrowave.Builder.class)), Meecrowave.Builder.class, null))
+ .isJaxwsSupportIfAvailable()) {
+ return;
}
- });
- serviceBeans.clear();
- }
- public void release(@Observes final BeforeShutdown beforeShutdown) {
- preShutdownTasks.stream().map(r -> (Runnable) () -> {
- try {
- r.run();
- } catch (final RuntimeException re) {
- new LogFacade(JAXWSCdiExtension.class.getName()).warn(re.getMessage(), re);
+ final Bean<?> busBean = beanManager.resolve(beanManager.getBeans("cxf"));
+ final org.apache.cxf.Bus bus = org.apache.cxf.Bus.class.cast(beanManager.getReference(
+ busBean, org.apache.cxf.Bus.class, beanManager.createCreationalContext(busBean)));
+
+ final Bean<?> mapperBean = beanManager.resolve(beanManager.getBeans(JAXWSAddressMapper.class));
+ final JAXWSAddressMapper mapper;
+ if (mapperBean == null) {
+ mapper = type -> {
+ WsMapping wsMapping = type.getAnnotation(WsMapping.class);
+ return wsMapping != null
+ ? wsMapping.value()
+ : "/webservices/" + type.getSimpleName();
+ };
+ } else {
+ mapper = JAXWSAddressMapper.class.cast(beanManager.getReference(mapperBean, JAXWSAddressMapper.class, beanManager.createCreationalContext(mapperBean)));
}
- }).forEach(Runnable::run);
- preShutdownTasks.clear();
+
+ serviceBeans.forEach(bean -> {
+ final Class<?> beanClass = OwbBean.class.isInstance(bean) ? OwbBean.class.cast(bean).getReturnType() : bean.getBeanClass();
+
+ final ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ try {
+ final org.apache.cxf.endpoint.AbstractEndpointFactory aef = org.apache.cxf.endpoint.AbstractEndpointFactory.class.cast(
+ loader.loadClass("org.apache.cxf.jaxws.JaxWsServerFactoryBean").getConstructor().newInstance());
+ aef.setBus(bus);
+ aef.setAddress(mapper.map(beanClass));
+
+ final Class<? extends org.apache.cxf.endpoint.AbstractEndpointFactory> factoryClass = aef.getClass();
+ factoryClass.getMethod("setStart", boolean.class).invoke(aef, true);
+ factoryClass.getMethod("setServiceClass", Class.class).invoke(aef, beanClass);
+
+ final CreationalContext<Object> creationalContext = beanManager.createCreationalContext(null);
+ if (!beanManager.isNormalScope(bean.getScope())) {
+ preShutdownTasks.add(creationalContext::release);
+ }
+ factoryClass.getMethod("setServiceBean", Object.class).invoke(aef, beanManager.getReference(bean, Object.class, creationalContext));
+
+ final Object server = factoryClass.getMethod("create").invoke(aef);
+
+ final Class<?> serverClass = server.getClass();
+ serverClass.getMethod("start").invoke(server);
+ preShutdownTasks.add(() -> {
+ try {
+ serverClass.getMethod("destroy").invoke(server);
+ } catch (final NoClassDefFoundError | NoSuchMethodException | IllegalAccessException e) {
+ throw new IllegalStateException(e);
+ } catch (final InvocationTargetException e) {
+ throw new IllegalStateException(e.getCause());
+ }
+ });
+ } catch (final NoClassDefFoundError | ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException e) {
+ throw new IllegalStateException(e);
+ } catch (final InvocationTargetException e) {
+ throw new IllegalStateException(e.getCause());
+ }
+ });
+ serviceBeans.clear();
+ }
+
+ public void release(@Observes final BeforeShutdown beforeShutdown) {
+ preShutdownTasks.stream().map(r -> (Runnable) () -> {
+ try {
+ r.run();
+ } catch (final RuntimeException re) {
+ new LogFacade(org.apache.meecrowave.cxf.JAXWSCdiExtension.class.getName()).warn(re.getMessage(), re);
+ }
+ }).forEach(Runnable::run);
+ preShutdownTasks.clear();
+ }
}
}
Added: openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/logging/jul/AbstractDelegatingLogger.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/logging/jul/AbstractDelegatingLogger.java?rev=1848271&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/logging/jul/AbstractDelegatingLogger.java (added)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/logging/jul/AbstractDelegatingLogger.java Thu Dec 6 08:39:47 2018
@@ -0,0 +1,407 @@
+/*
+ * 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.meecrowave.logging.jul;
+
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.logging.Filter;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+// from cxf
+public abstract class AbstractDelegatingLogger extends Logger {
+
+ protected AbstractDelegatingLogger(String name, String resourceBundleName) {
+ super(name, resourceBundleName);
+ }
+
+ public void log(LogRecord record) {
+ if (isLoggable(record.getLevel())) {
+ doLog(record);
+ }
+ }
+
+ public void log(Level level, String msg) {
+ if (isLoggable(level)) {
+ LogRecord lr = new LogRecord(level, msg);
+ doLog(lr);
+ }
+ }
+
+ public void log(Level level, String msg, Object param1) {
+ if (isLoggable(level)) {
+ LogRecord lr = new LogRecord(level, msg);
+ Object params[] = {param1 };
+ lr.setParameters(params);
+ doLog(lr);
+ }
+ }
+
+ public void log(Level level, String msg, Object params[]) {
+ if (isLoggable(level)) {
+ LogRecord lr = new LogRecord(level, msg);
+ lr.setParameters(params);
+ doLog(lr);
+ }
+ }
+
+ public void log(Level level, String msg, Throwable thrown) {
+ if (isLoggable(level)) {
+ LogRecord lr = new LogRecord(level, msg);
+ lr.setThrown(thrown);
+ doLog(lr);
+ }
+ }
+
+ public void logp(Level level, String sourceClass, String sourceMethod, String msg) {
+ if (isLoggable(level)) {
+ LogRecord lr = new LogRecord(level, msg);
+ lr.setSourceClassName(sourceClass);
+ lr.setSourceMethodName(sourceMethod);
+ doLog(lr);
+ }
+ }
+
+ public void logp(Level level, String sourceClass, String sourceMethod, String msg, Object param1) {
+ if (isLoggable(level)) {
+ LogRecord lr = new LogRecord(level, msg);
+ lr.setSourceClassName(sourceClass);
+ lr.setSourceMethodName(sourceMethod);
+ Object params[] = {param1 };
+ lr.setParameters(params);
+ doLog(lr);
+ }
+ }
+
+ public void logp(Level level, String sourceClass, String sourceMethod, String msg, Object params[]) {
+ if (isLoggable(level)) {
+ LogRecord lr = new LogRecord(level, msg);
+ lr.setSourceClassName(sourceClass);
+ lr.setSourceMethodName(sourceMethod);
+ lr.setParameters(params);
+ doLog(lr);
+ }
+ }
+
+ public void logp(Level level, String sourceClass, String sourceMethod, String msg, Throwable thrown) {
+ if (isLoggable(level)) {
+ LogRecord lr = new LogRecord(level, msg);
+ lr.setSourceClassName(sourceClass);
+ lr.setSourceMethodName(sourceMethod);
+ lr.setThrown(thrown);
+ doLog(lr);
+ }
+ }
+
+ public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg) {
+ if (isLoggable(level)) {
+ LogRecord lr = new LogRecord(level, msg);
+ lr.setSourceClassName(sourceClass);
+ lr.setSourceMethodName(sourceMethod);
+ doLog(lr, bundleName);
+ }
+ }
+
+ public void logrb(Level level, String sourceClass, String sourceMethod,
+ String bundleName, String msg, Object param1) {
+ if (isLoggable(level)) {
+ LogRecord lr = new LogRecord(level, msg);
+ lr.setSourceClassName(sourceClass);
+ lr.setSourceMethodName(sourceMethod);
+ Object params[] = {param1 };
+ lr.setParameters(params);
+ doLog(lr, bundleName);
+ }
+ }
+
+ public void logrb(Level level, String sourceClass, String sourceMethod,
+ String bundleName, String msg, Object params[]) {
+ if (isLoggable(level)) {
+ LogRecord lr = new LogRecord(level, msg);
+ lr.setSourceClassName(sourceClass);
+ lr.setSourceMethodName(sourceMethod);
+ lr.setParameters(params);
+ doLog(lr, bundleName);
+ }
+ }
+
+ public void logrb(Level level, String sourceClass, String sourceMethod,
+ String bundleName, String msg, Throwable thrown) {
+ if (isLoggable(level)) {
+ LogRecord lr = new LogRecord(level, msg);
+ lr.setSourceClassName(sourceClass);
+ lr.setSourceMethodName(sourceMethod);
+ lr.setThrown(thrown);
+ doLog(lr, bundleName);
+ }
+ }
+
+ public void entering(String sourceClass, String sourceMethod) {
+ if (isLoggable(Level.FINER)) {
+ logp(Level.FINER, sourceClass, sourceMethod, "ENTRY");
+ }
+ }
+
+ public void entering(String sourceClass, String sourceMethod, Object param1) {
+ if (isLoggable(Level.FINER)) {
+ Object params[] = {param1 };
+ logp(Level.FINER, sourceClass, sourceMethod, "ENTRY {0}", params);
+ }
+ }
+
+ public void entering(String sourceClass, String sourceMethod, Object params[]) {
+ if (isLoggable(Level.FINER)) {
+ String msg = "ENTRY";
+ if (params == null) {
+ logp(Level.FINER, sourceClass, sourceMethod, msg);
+ return;
+ }
+ StringBuilder builder = new StringBuilder(msg);
+ for (int i = 0; i < params.length; i++) {
+ builder.append(" {");
+ builder.append(Integer.toString(i));
+ builder.append("}");
+ }
+ logp(Level.FINER, sourceClass, sourceMethod, builder.toString(), params);
+ }
+ }
+
+ public void exiting(String sourceClass, String sourceMethod) {
+ if (isLoggable(Level.FINER)) {
+ logp(Level.FINER, sourceClass, sourceMethod, "RETURN");
+ }
+ }
+
+ public void exiting(String sourceClass, String sourceMethod, Object result) {
+ if (isLoggable(Level.FINER)) {
+ Object params[] = {result };
+ logp(Level.FINER, sourceClass, sourceMethod, "RETURN {0}", params);
+ }
+ }
+
+ public void throwing(String sourceClass, String sourceMethod, Throwable thrown) {
+ if (isLoggable(Level.FINER)) {
+ LogRecord lr = new LogRecord(Level.FINER, "THROW");
+ lr.setSourceClassName(sourceClass);
+ lr.setSourceMethodName(sourceMethod);
+ lr.setThrown(thrown);
+ doLog(lr);
+ }
+ }
+
+ public void severe(String msg) {
+ if (isLoggable(Level.SEVERE)) {
+ LogRecord lr = new LogRecord(Level.SEVERE, msg);
+ doLog(lr);
+ }
+ }
+
+ public void warning(String msg) {
+ if (isLoggable(Level.WARNING)) {
+ LogRecord lr = new LogRecord(Level.WARNING, msg);
+ doLog(lr);
+ }
+ }
+
+ public void info(String msg) {
+ if (isLoggable(Level.INFO)) {
+ LogRecord lr = new LogRecord(Level.INFO, msg);
+ doLog(lr);
+ }
+ }
+
+ public void config(String msg) {
+ if (isLoggable(Level.CONFIG)) {
+ LogRecord lr = new LogRecord(Level.CONFIG, msg);
+ doLog(lr);
+ }
+ }
+
+ public void fine(String msg) {
+ if (isLoggable(Level.FINE)) {
+ LogRecord lr = new LogRecord(Level.FINE, msg);
+ doLog(lr);
+ }
+ }
+
+ public void finer(String msg) {
+ if (isLoggable(Level.FINER)) {
+ LogRecord lr = new LogRecord(Level.FINER, msg);
+ doLog(lr);
+ }
+ }
+
+ public void finest(String msg) {
+ if (isLoggable(Level.FINEST)) {
+ LogRecord lr = new LogRecord(Level.FINEST, msg);
+ doLog(lr);
+ }
+ }
+
+ public void setLevel(Level newLevel) throws SecurityException {
+ throw new UnsupportedOperationException();
+ }
+
+ public abstract Level getLevel();
+
+ public boolean isLoggable(Level level) {
+ Level l = getLevel();
+ return level.intValue() >= l.intValue() && l != Level.OFF;
+ }
+
+ protected boolean supportsHandlers() {
+ return false;
+ }
+
+ public synchronized void addHandler(Handler handler) throws SecurityException {
+ if (supportsHandlers()) {
+ super.addHandler(handler);
+ return;
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public synchronized void removeHandler(Handler handler) throws SecurityException {
+ if (supportsHandlers()) {
+ super.removeHandler(handler);
+ return;
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public synchronized Handler[] getHandlers() {
+ if (supportsHandlers()) {
+ return super.getHandlers();
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public synchronized void setUseParentHandlers(boolean useParentHandlers) {
+ if (supportsHandlers()) {
+ super.setUseParentHandlers(useParentHandlers);
+ return;
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public synchronized boolean getUseParentHandlers() {
+ if (supportsHandlers()) {
+ return super.getUseParentHandlers();
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public Logger getParent() {
+ return null;
+ }
+
+ public void setParent(Logger parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ protected void doLog(LogRecord lr) {
+ lr.setLoggerName(getName());
+ String rbname = getResourceBundleName();
+ if (rbname != null) {
+ lr.setResourceBundleName(rbname);
+ lr.setResourceBundle(getResourceBundle());
+ }
+ internalLog(lr);
+ }
+
+ protected void doLog(LogRecord lr, String rbname) {
+ lr.setLoggerName(getName());
+ if (rbname != null) {
+ lr.setResourceBundleName(rbname);
+ lr.setResourceBundle(loadResourceBundle(rbname));
+ }
+ internalLog(lr);
+ }
+
+ protected void internalLog(LogRecord record) {
+ Filter filter = getFilter();
+ if (filter != null && !filter.isLoggable(record)) {
+ return;
+ }
+ String msg = formatMessage(record);
+ internalLogFormatted(msg, record);
+ }
+
+ protected abstract void internalLogFormatted(String msg, LogRecord record);
+
+ protected String formatMessage(LogRecord record) {
+ String format = record.getMessage();
+ ResourceBundle catalog = record.getResourceBundle();
+ if (catalog != null) {
+ try {
+ format = catalog.getString(record.getMessage());
+ } catch (MissingResourceException ex) {
+ format = record.getMessage();
+ }
+ }
+ try {
+ Object parameters[] = record.getParameters();
+ if (parameters == null || parameters.length == 0) {
+ return format;
+ }
+ if (format.indexOf("{0") >= 0 || format.indexOf("{1") >= 0
+ || format.indexOf("{2") >= 0 || format.indexOf("{3") >= 0) {
+ return java.text.MessageFormat.format(format, parameters);
+ }
+ return format;
+ } catch (Exception ex) {
+ return format;
+ }
+ }
+
+ /**
+ * Load the specified resource bundle
+ *
+ * @param resourceBundleName
+ * the name of the resource bundle to load, cannot be null
+ * @return the loaded resource bundle.
+ * @throws java.util.MissingResourceException
+ * If the specified resource bundle can not be loaded.
+ */
+ private static ResourceBundle loadResourceBundle(String resourceBundleName) {
+ // try context class loader to load the resource
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (null != cl) {
+ try {
+ return ResourceBundle.getBundle(resourceBundleName, Locale.getDefault(), cl);
+ } catch (MissingResourceException e) {
+ // Failed to load using context classloader, ignore
+ }
+ }
+ // try system class loader to load the resource
+ cl = ClassLoader.getSystemClassLoader();
+ if (null != cl) {
+ try {
+ return ResourceBundle.getBundle(resourceBundleName, Locale.getDefault(), cl);
+ } catch (MissingResourceException e) {
+ // Failed to load using system classloader, ignore
+ }
+ }
+ return null;
+ }
+
+}
Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/logging/jul/Log4j2Logger.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/logging/jul/Log4j2Logger.java?rev=1848271&r1=1848270&r2=1848271&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/logging/jul/Log4j2Logger.java (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/logging/jul/Log4j2Logger.java Thu Dec 6 08:39:47 2018
@@ -18,7 +18,6 @@
*/
package org.apache.meecrowave.logging.jul;
-import org.apache.cxf.common.logging.AbstractDelegatingLogger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.simple.SimpleLogger;
Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/MeecrowaveExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/MeecrowaveExtension.java?rev=1848271&r1=1848270&r2=1848271&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/MeecrowaveExtension.java (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/MeecrowaveExtension.java Thu Dec 6 08:39:47 2018
@@ -31,6 +31,7 @@ import javax.enterprise.inject.spi.Exten
import javax.enterprise.inject.spi.ProcessAnnotatedType;
import javax.ws.rs.Path;
+import org.apache.meecrowave.cxf.Cxfs;
import org.apache.meecrowave.cxf.JAXRSFieldInjectionInterceptor;
import org.apache.meecrowave.cxf.MeecrowaveBus;
import org.apache.webbeans.container.AnnotatedTypeWrapper;
@@ -39,13 +40,18 @@ import org.apache.webbeans.portable.Anno
public class MeecrowaveExtension implements Extension {
void addBeansFromJava(@Observes final BeforeBeanDiscovery bbd, final BeanManager bm) {
- // stream not really needed but here for the pattern in case we need other beans
- Stream.of(MeecrowaveBus.class).forEach(type -> bbd.addAnnotatedType(bm.createAnnotatedType(type)));
+ if (Cxfs.IS_PRESENT) {
+ // stream not really needed but here for the pattern in case we need other beans
+ Stream.of(MeecrowaveBus.class)
+ .forEach(type -> bbd.addAnnotatedType(bm.createAnnotatedType(type)));
+ }
}
void enableContextFieldInjectionWorks(@Observes final ProcessAnnotatedType<?> pat, final BeanManager bm) {
final AnnotatedType<?> at = pat.getAnnotatedType();
- if (at.isAnnotationPresent(Path.class) && !at.isAnnotationPresent(JAXRSFieldInjectionInterceptor.Binding.class)
+ if (Cxfs.IS_PRESENT
+ && at.isAnnotationPresent(Path.class)
+ && !at.isAnnotationPresent(JAXRSFieldInjectionInterceptor.Binding.class)
&& at.getAnnotations().stream().anyMatch(a -> bm.isNormalScope(a.annotationType()))) {
pat.setAnnotatedType(new JAXRSFIeldInjectionAT(this, at));
}
Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/OWBAutoSetup.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/OWBAutoSetup.java?rev=1848271&r1=1848270&r2=1848271&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/OWBAutoSetup.java (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/OWBAutoSetup.java Thu Dec 6 08:39:47 2018
@@ -19,6 +19,7 @@
package org.apache.meecrowave.openwebbeans;
import org.apache.meecrowave.Meecrowave;
+import org.apache.meecrowave.cxf.Cxfs;
import org.apache.meecrowave.cxf.JAXRSFieldInjectionInterceptor;
import org.apache.webbeans.annotation.DefaultLiteral;
import org.apache.webbeans.config.WebBeansContext;
@@ -103,8 +104,10 @@ public class OWBAutoSetup implements Ser
.types(Meecrowave.class, AutoCloseable.class, Object.class)
.createWith(cc -> meecrowave)));
- interceptorsManager.addInterceptorBindingType(JAXRSFieldInjectionInterceptor.Binding.class);
- beanManager.addAdditionalAnnotatedType(this, beanManager.createAnnotatedType(JAXRSFieldInjectionInterceptor.class));
+ if (Cxfs.IS_PRESENT) {
+ interceptorsManager.addInterceptorBindingType(JAXRSFieldInjectionInterceptor.Binding.class);
+ beanManager.addAdditionalAnnotatedType(this, beanManager.createAnnotatedType(JAXRSFieldInjectionInterceptor.class));
+ }
}
private <T> Bean<?> newBean(final WebBeansContext instance, final Consumer<BeanConfigurator<T>> configurer) {