Skip to content

Commit

Permalink
Ref #548: Allow to create a cxfrs endpoint in blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
essobedo committed Dec 5, 2024
1 parent 8b18694 commit 03402c0
Show file tree
Hide file tree
Showing 101 changed files with 6,171 additions and 471 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
Expand All @@ -34,15 +33,6 @@
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;

import org.apache.camel.RuntimeCamelException;
import org.apache.camel.blueprint.CamelRouteConfigurationContextFactoryBean;
import org.apache.camel.builder.LegacyDeadLetterChannelBuilder;
import org.apache.camel.builder.LegacyDefaultErrorHandlerBuilder;
import org.apache.camel.builder.LegacyNoErrorHandlerBuilder;
import org.apache.camel.reifier.errorhandler.ErrorHandlerReifier;
import org.apache.camel.reifier.errorhandler.LegacyDeadLetterChannelReifier;
import org.apache.camel.reifier.errorhandler.LegacyDefaultErrorHandlerReifier;
import org.apache.camel.reifier.errorhandler.LegacyNoErrorHandlerReifier;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
Expand Down Expand Up @@ -71,8 +61,12 @@
import org.apache.camel.blueprint.CamelContextFactoryBean;
import org.apache.camel.blueprint.CamelEndpointFactoryBean;
import org.apache.camel.blueprint.CamelRestContextFactoryBean;
import org.apache.camel.blueprint.CamelRouteConfigurationContextFactoryBean;
import org.apache.camel.blueprint.CamelRouteContextFactoryBean;
import org.apache.camel.blueprint.CamelRouteTemplateContextFactoryBean;
import org.apache.camel.builder.LegacyDeadLetterChannelBuilder;
import org.apache.camel.builder.LegacyDefaultErrorHandlerBuilder;
import org.apache.camel.builder.LegacyNoErrorHandlerBuilder;
import org.apache.camel.core.xml.AbstractCamelFactoryBean;
import org.apache.camel.impl.engine.CamelPostProcessorHelper;
import org.apache.camel.impl.engine.DefaultCamelContextNameStrategy;
Expand All @@ -91,13 +85,15 @@
import org.apache.camel.model.SendDefinition;
import org.apache.camel.model.SortDefinition;
import org.apache.camel.model.ToDefinition;
import org.apache.camel.model.ToDynamicDefinition;
import org.apache.camel.model.UnmarshalDefinition;
import org.apache.camel.model.WireTapDefinition;
import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.model.rest.RestBindingMode;
import org.apache.camel.model.rest.RestDefinition;
import org.apache.camel.model.rest.VerbDefinition;
import org.apache.camel.reifier.errorhandler.ErrorHandlerReifier;
import org.apache.camel.reifier.errorhandler.LegacyDeadLetterChannelReifier;
import org.apache.camel.reifier.errorhandler.LegacyDefaultErrorHandlerReifier;
import org.apache.camel.reifier.errorhandler.LegacyNoErrorHandlerReifier;
import org.apache.camel.spi.CamelContextNameStrategy;
import org.apache.camel.spi.ComponentResolver;
import org.apache.camel.spi.DataFormatResolver;
Expand Down Expand Up @@ -125,7 +121,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


import static org.osgi.service.blueprint.reflect.ComponentMetadata.ACTIVATION_LAZY;
import static org.osgi.service.blueprint.reflect.ServiceReferenceMetadata.AVAILABILITY_MANDATORY;
import static org.osgi.service.blueprint.reflect.ServiceReferenceMetadata.AVAILABILITY_OPTIONAL;
Expand Down Expand Up @@ -209,7 +204,7 @@ public URL getSchemaLocation(String namespace) {
@Override
@SuppressWarnings({"rawtypes"})
public Set<Class> getManagedClasses() {
return new HashSet<>(Arrays.asList(BlueprintCamelContext.class));
return Set.of(BlueprintCamelContext.class);
}

@Override
Expand Down
65 changes: 9 additions & 56 deletions components/camel-cxf/camel-cxf-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,7 @@

<properties>
<camel.osgi.export>
org.apache.camel.component.cxf.osgi;version=${project.version},
org.apache.camel.component.cxf.common;version=${camel-version},
org.apache.camel.component.cxf.common.header;version=${camel-version},
org.apache.camel.component.cxf.common.message;version=${camel-version},
org.apache.camel.component.cxf.converter;version=${camel-version},
org.apache.camel.component.cxf.util;version=${camel-version},
org.apache.camel.component.cxf.bus.blueprint;version=${project.version},
org.apache.camel.component.cxf.bus.osgi;version=${project.version},
org.apache.camel.component.cxf.configuration.blueprint;version=${project.version},
org.apache.camel.component.cxf.helpers;version=${project.version},
org.apache.camel.component.cxf.jaxrs;version="${camel-version}",
org.apache.camel.component.cxf.ext.logging.osgi;version=${project.version},
org.apache.camel.component.cxf.jaxrs.blueprint;version=${project.version},
org.apache.camel.component.cxf.jaxws.blueprint;version=${project.version},
org.apache.camel.component.cxf.frontend.blueprint;version=${project.version},
org.apache.camel.component.cxf.jaxrs.client.blueprint;version=${project.version},
org.apache.camel.component.cxf.transport.http.osgi;version=${project.version},
org.apache.camel.component.cxf.transport.http.blueprint;version=${project.version},
org.apache.camel.component.cxf.servlet.blueprint;version=${project.version},
org.apache.camel.component.cxf.ws.addressing.blueprint;version=${project.version},
org.apache.camel.component.cxf.ws.policy.blueprint;version=${project.version},
org.apache.camel.component.cxf.feature;version=${camel-version},
org.apache.camel.component.cxf.interceptors;version=${camel-version},
org.apache.camel.component.cxf.jaxws;version=${camel-version},
org.apache.camel.component.cxf.transport;version=${camel-version},
org.apache.camel.component.cxf.transport.header;version=${camel-version},
org.apache.camel.component.cxf.transport.message;version=${camel-version},
org.apache.camel.component.cxf.binding.soap.blueprint;version=${project.version},
org.apache.camel.component.cxf*;version=${camel-version},
org.apache.cxf*;version=${cxf-version},
</camel.osgi.export>
<camel.osgi.activator>org.apache.camel.component.cxf.osgi.MainActivator</camel.osgi.activator>
Expand Down Expand Up @@ -104,7 +77,6 @@
org.osgi.util*,
org.osgi.service*,
org.osgi.framework*,
org.apache.aries.blueprint*,
org.xml.sax,
javax.xml*,
javax.management*,
Expand All @@ -120,28 +92,6 @@
<camel.osgi.dynamicimport.pkg>
org.apache.cxf.bus,org.apache.cxf.*,com.ctc.wstx.*
</camel.osgi.dynamicimport.pkg>
<camel.osgi.export.service>
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/blueprint/core",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/beans",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/parameterized-types",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/security",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://schemas.xmlsoap.org/wsdl/",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/blueprint/bindings/soap",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/blueprint/jaxrs",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/blueprint/jaxws",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/blueprint/simple",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/blueprint/jaxrs-client",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/transports/http/configuration",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/ws/addressing",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/policy",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://www.w3.org/ns/ws-policy",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://www.w3.org/2006/07/ws-policy",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://schemas.xmlsoap.org/ws/2004/09/policy",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://www.w3.org/2000/09/xmldsig#",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"
</camel.osgi.export.service>
</properties>

<dependencies>
Expand Down Expand Up @@ -343,11 +293,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.aries.blueprint</groupId>
<artifactId>org.apache.aries.blueprint.core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.core</artifactId>
Expand Down Expand Up @@ -400,6 +345,14 @@
<include>org.apache.camel:camel-cxf-transport</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>schemas/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.camel.component.cxf.bus.blueprint.BlueprintNameSpaceHandlerFactory;
import org.apache.camel.component.cxf.bus.blueprint.NamespaceHandlerRegisterer;
import org.apache.camel.component.cxf.helpers.CXFAPINamespaceHandler;
import org.apache.cxf.bus.extension.Extension;
import org.apache.cxf.bus.extension.ExtensionRegistry;
import org.apache.cxf.common.util.CollectionUtils;
Expand All @@ -40,7 +37,6 @@
* - CXFBundleListener
* - Attaching ManagedWorkqueues to config admin service
* - OsgiBusListener
* - Blueprint namespaces
*/
public class CXFActivator implements BundleActivator {

Expand All @@ -53,6 +49,7 @@ public class CXFActivator implements BundleActivator {


/** {@inheritDoc}*/
@Override
public void start(BundleContext context) throws Exception {
workQueues = new ManagedWorkQueueList();
cxfBundleListener = new CXFExtensionBundleListener(context.getBundle().getBundleId());
Expand All @@ -71,23 +68,6 @@ public void start(BundleContext context) throws Exception {
extensions.add(createOsgiBusListenerExtension(context));
extensions.add(createManagedWorkQueueListExtension(workQueues));
ExtensionRegistry.addExtensions(extensions);

BlueprintNameSpaceHandlerFactory factory = new BlueprintNameSpaceHandlerFactory() {

@Override
public Object createNamespaceHandler() {
return new CXFAPINamespaceHandler();
}
};
NamespaceHandlerRegisterer.register(context, factory,
"http://cxf.apache.org/blueprint/core",
"http://cxf.apache.org/configuration/beans",
"http://cxf.apache.org/configuration/parameterized-types",
"http://cxf.apache.org/configuration/security",
"http://schemas.xmlsoap.org/wsdl/",
"http://www.w3.org/2005/08/addressing",
"http://schemas.xmlsoap.org/ws/2004/08/addressing");

}

private <T> ServiceRegistration<T> registerManagedServiceFactory(BundleContext context,
Expand Down Expand Up @@ -120,6 +100,7 @@ public Extension cloneNoObject() {
}

/** {@inheritDoc}*/
@Override
public void stop(BundleContext context) throws Exception {
context.removeBundleListener(cxfBundleListener);
cxfBundleListener.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public void stop(BundleContext context) throws Exception {
}

private static final class ConfigUpdater implements ManagedService {
private BundleContext bundleContext;
private final BundleContext bundleContext;
private ServiceRegistration<?> serviceReg;
private ServiceRegistration<?> intentReg;
private LoggingFeature logging;
private final LoggingFeature logging;

ConfigUpdater(BundleContext bundleContext) {
this.logging = new LoggingFeature();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,8 @@ public class MainActivator implements BundleActivator {

private final List<BundleActivator> activators = List.of(
new CXFActivator(),
new org.apache.camel.component.cxf.binding.soap.blueprint.Activator(),
new org.apache.camel.component.cxf.ext.logging.osgi.Activator(),
new org.apache.camel.component.cxf.jaxrs.blueprint.Activator(),
new org.apache.camel.component.cxf.jaxws.blueprint.Activator(),
new org.apache.camel.component.cxf.frontend.blueprint.Activator(),
new org.apache.camel.component.cxf.jaxrs.client.blueprint.Activator(),
new HTTPTransportActivator(),
new org.apache.camel.component.cxf.ws.addressing.blueprint.Activator(),
new org.apache.camel.component.cxf.ws.policy.blueprint.Activator());
new HTTPTransportActivator());

@Override
public void start(BundleContext bundleContext) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

package org.apache.camel.component.cxf.transport.http.osgi;

import org.apache.camel.component.cxf.bus.blueprint.BlueprintNameSpaceHandlerFactory;
import org.apache.camel.component.cxf.bus.blueprint.NamespaceHandlerRegisterer;
import org.apache.camel.component.cxf.transport.http.blueprint.HttpBPHandler;
import org.apache.cxf.common.util.CollectionUtils;
import org.apache.cxf.common.util.PropertyUtils;
import org.apache.cxf.transport.http.DestinationRegistry;
Expand All @@ -38,6 +35,7 @@ public class HTTPTransportActivator implements BundleActivator {
private static final String DISABLE_DEFAULT_HTTP_TRANSPORT = "org.apache.cxf.osgi.http.transport.disable";
private ServiceTracker<HttpService, ?> httpServiceTracker;

@Override
public void start(final BundleContext context) throws Exception {

ConfigAdminHttpConduitConfigurer conduitConfigurer = new ConfigAdminHttpConduitConfigurer();
Expand All @@ -56,22 +54,13 @@ public void start(final BundleContext context) throws Exception {
DestinationRegistry destinationRegistry = new DestinationRegistryImpl();
HTTPTransportFactory transportFactory = new HTTPTransportFactory(destinationRegistry);

// HttpService is no longer available in OSGI 8
// HttpServiceTrackerCust customizer = new HttpServiceTrackerCust(destinationRegistry, context);
// httpServiceTracker = new ServiceTracker<>(context, HttpService.class, customizer);
// httpServiceTracker.open();

context.registerService(DestinationRegistry.class.getName(), destinationRegistry, null);
context.registerService(HTTPTransportFactory.class.getName(), transportFactory, null);

BlueprintNameSpaceHandlerFactory factory = new BlueprintNameSpaceHandlerFactory() {

@Override
public Object createNamespaceHandler() {
return new HttpBPHandler();
}
};
NamespaceHandlerRegisterer.register(context, factory,
"http://cxf.apache.org/transports/http/configuration");
}

private <T> ServiceRegistration<T> registerService(BundleContext context, Class<T> serviceInterface,
Expand All @@ -80,6 +69,7 @@ private <T> ServiceRegistration<T> registerService(BundleContext context, Class<
CollectionUtils.singletonDictionary(Constants.SERVICE_PID, servicePid));
}

@Override
public void stop(BundleContext context) throws Exception {
if (httpServiceTracker != null) {
httpServiceTracker.close();
Expand Down
Loading

0 comments on commit 03402c0

Please sign in to comment.