diff --git a/bom/camel-karaf-bom/pom.xml b/bom/camel-karaf-bom/pom.xml index 55ffcabf9..a6e98ede4 100644 --- a/bom/camel-karaf-bom/pom.xml +++ b/bom/camel-karaf-bom/pom.xml @@ -76,11 +76,6 @@ camel-kura ${project.version} - - org.apache.camel.karaf - camel-osgi-activator - ${project.version} - org.apache.camel.karaf camel-paxlogging diff --git a/components/camel-osgi-activator/pom.xml b/components/camel-osgi-activator/pom.xml deleted file mode 100644 index 5e6254318..000000000 --- a/components/camel-osgi-activator/pom.xml +++ /dev/null @@ -1,198 +0,0 @@ - - - - 4.0.0 - - - org.apache.camel.karaf - components - 3.15.0-SNAPSHOT - - - camel-osgi-activator - jar - - Camel Karaf :: OSGi Activator (deprecated) - Camel OSGi Activator for running Camel routes from other bundles - - - org.apache.camel.osgi.activator.CamelRoutesActivator - * - 3.1.0 - - preview - - - - - - org.osgi - osgi.cmpn - provided - - - org.osgi - osgi.core - provided - - - org.apache.camel.karaf - camel-core-osgi - ${project.version} - - - org.apache.camel - camel-core-languages - - - - org.apache.camel - camel-timer - test - - - org.apache.camel - camel-log - test - - - - - org.ops4j.pax.exam - pax-exam - test - - - org.ops4j.pax.exam - pax-exam-spi - ${pax-exam-version} - test - - - org.ops4j.pax.exam - pax-exam-junit4 - test - - - org.ops4j.pax.exam - pax-exam-container-karaf - test - - - org.ops4j.pax.url - pax-url-aether - 2.6.2 - test - - - org.ops4j.pax.tinybundles - tinybundles - 2.1.1 - test - - - - - org.apache.karaf - apache-karaf - ${karaf4-version} - zip - test - - - org.apache.karaf.features - framework - - - - - - - org.apache.camel.karaf - apache-camel - ${project.version} - features - xml - test - - - javax.inject - javax.inject - 1 - test - - - - - - org.apache.servicemix.tooling - depends-maven-plugin - - - generate-depends-file - - generate-depends-file - - - - - - maven-assembly-plugin - - - pre-integration-test - - single - - - - src/assembly/test-bundles.xml - - test - false - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - **/*IT.java - - 300 - - - - - - - diff --git a/components/camel-osgi-activator/src/assembly/test-bundles.xml b/components/camel-osgi-activator/src/assembly/test-bundles.xml deleted file mode 100644 index 79dc20c52..000000000 --- a/components/camel-osgi-activator/src/assembly/test-bundles.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - bundles - - dir - - false - - - - ${artifact.artifactId}.jar - - org.apache.camel:camel-api - org.apache.camel:camel-base - org.apache.camel:camel-base-engine - org.apache.camel:camel-core-reifier - org.apache.camel:camel-core-model - org.apache.camel:camel-core-processor - org.apache.camel:camel-core-engine - org.apache.camel:camel-core-languages - org.apache.camel:camel-management-api - org.apache.camel.karaf:camel-core-osgi - org.apache.camel.karaf:camel-osgi-activator - org.apache.camel:camel-support - org.apache.camel:camel-util - org.apache.camel:camel-timer - org.apache.camel:camel-log - - test - - - diff --git a/components/camel-osgi-activator/src/generated/resources/META-INF/services/org/apache/camel/other.properties b/components/camel-osgi-activator/src/generated/resources/META-INF/services/org/apache/camel/other.properties deleted file mode 100644 index 5316a19d1..000000000 --- a/components/camel-osgi-activator/src/generated/resources/META-INF/services/org/apache/camel/other.properties +++ /dev/null @@ -1,7 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -name=osgi-activator -groupId=org.apache.camel.karaf -artifactId=camel-osgi-activator -version=3.15.0-SNAPSHOT -projectName=Camel Karaf :: OSGi Activator (deprecated) -projectDescription=Camel OSGi Activator for running Camel routes from other bundles diff --git a/components/camel-osgi-activator/src/generated/resources/osgi-activator.json b/components/camel-osgi-activator/src/generated/resources/osgi-activator.json deleted file mode 100644 index c4998c7cb..000000000 --- a/components/camel-osgi-activator/src/generated/resources/osgi-activator.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "other": { - "kind": "other", - "name": "osgi-activator", - "title": "Osgi Activator", - "description": "Camel OSGi Activator for running Camel routes from other bundles", - "deprecated": true, - "firstVersion": "3.1.0", - "supportLevel": "Preview", - "groupId": "org.apache.camel.karaf", - "artifactId": "camel-osgi-activator", - "version": "3.15.0-SNAPSHOT" - } -} diff --git a/components/camel-osgi-activator/src/main/docs/osgi-activator.adoc b/components/camel-osgi-activator/src/main/docs/osgi-activator.adoc deleted file mode 100644 index 6546cb125..000000000 --- a/components/camel-osgi-activator/src/main/docs/osgi-activator.adoc +++ /dev/null @@ -1,74 +0,0 @@ -[[OsgiActivator]] -= OSGi Camel Routes Activator (deprecated) -:page-source: components/camel-osgi-activator/src/main/docs/osgi-activator.adoc - -*Since Camel 3.1* - -A small OSGi activator for starting an OSGi Apache Camel Project. - -The bundle starts a shared CamelContext and registers any RouteBuilder instances -(discovered via the OSGi Service Registry), from any other bundles that gets installed. -And when the bundles gets uninstalled then the routes are stopped and removed from the shared CamelContext. - -== Important - -This OSGi activator is a based prototype for quickly starting up an OSGi container with a single shared -CamelContext and then being able to use OSGi dynamism to deploy and undeploy bundlers with Camel routes. - -Beware that this OSGi activator is a basic implementation and has limited support for dealing with errors -when new routes are added which may clash with existing routes (route ids). - -Configuration of the CamelContext is also very limited. - -Therefore only use this for prototyping and experiments. This is NOT recommended for production usage. - -== Install bundle - -Register an Apache Camel RouteBuilder as an OSGi service. - -Using OSGi annotations: - -[source,java] ----- -@Component(service = RouteBuilder.class) -public class MyRouteBuilder extends RouteBuilder { - @Override - public void configure() throws Exception { - from("timer:test?fixedRate=true&period=1000") - .log("Hello"); - } -} ----- - -Or Manually: - -[source,java] ----- -public void start(BundleContext context) throws Exception { - context.registerService(RouteBuilder.class, new MyRouteBuilder(), null); -} ----- - -And it's automatically added or removed to the context from any bundle! - -[source,text] ----- -Route: route1 started and consuming from: timer://test?fixedRate=true&period=1000 ----- - -For routes that need to be started before the CamelContext the "camel.osgi.activator.pre-startup" service property may be added. - -[source,java] ----- -@Component(service = RouteBuilder.class, property = {CamelRoutesActivatorConstants.PRE_START_UP_PROP_NAME + "=true"}) -public class MyStartupRouteBuilder extends RouteBuilder { - @Override - public void configure() throws Exception { - getContext().setStreamCaching(true); - - restConfiguration().component("netty-http").port(8080); - } -} ----- - -If this RouteBuilder is added after other non pre startup RouteBuilders then CamelContext will automatically restart. This allows pre start up RouteBuilder to run their configure methods before other RouteBuilders. diff --git a/components/camel-osgi-activator/src/main/java/org/apache/camel/osgi/activator/CamelRoutesActivator.java b/components/camel-osgi-activator/src/main/java/org/apache/camel/osgi/activator/CamelRoutesActivator.java deleted file mode 100644 index 2b2160a05..000000000 --- a/components/camel-osgi-activator/src/main/java/org/apache/camel/osgi/activator/CamelRoutesActivator.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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.camel.osgi.activator; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.core.osgi.OsgiDefaultCamelContext; -import org.apache.camel.model.ModelCamelContext; -import org.apache.camel.model.RouteDefinition; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; -import org.osgi.util.tracker.ServiceTracker; -import org.osgi.util.tracker.ServiceTrackerCustomizer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CamelRoutesActivator implements BundleActivator, ServiceTrackerCustomizer { - - private static final Logger LOG = LoggerFactory.getLogger(CamelRoutesActivator.class); - private ServiceRegistration camelContextRef; - private ModelCamelContext camelContext; - private BundleContext bundleContext; - private ServiceTracker routeServiceTracker; - - @Override - @SuppressWarnings("unchecked") - public void start(BundleContext context) throws Exception { - this.bundleContext = context; - - this.camelContext = new OsgiDefaultCamelContext(this.bundleContext); - - camelContextRef = this.bundleContext.registerService(CamelContext.class, camelContext, null); - - camelContext.start(); - - this.routeServiceTracker = new ServiceTracker(context, RouteBuilder.class, this); - - this.routeServiceTracker.open(); - - LOG.info("Camel OSGi Activator RouteBuilder ServiceTracker Tracker Open"); - } - - @Override - public RouteBuilder addingService(ServiceReference reference) { - RouteBuilder builder = this.bundleContext.getService(reference); - if (isPreStartRouteBuilder(reference)) { - reloadTrackedServices(reference); - } else { - addRoute(builder); - } - return builder; - } - - @Override - public void stop(BundleContext context) throws Exception { - this.routeServiceTracker.close(); - stopAndClearCamelRoutes(); - this.bundleContext.ungetService(camelContextRef.getReference()); - } - - @Override - public void modifiedService(ServiceReference reference, RouteBuilder service) { - removedService(reference, service); - addingService(reference); - } - - @Override - public void removedService(ServiceReference reference, RouteBuilder service) { - if (isPreStartRouteBuilder(reference)) { - reloadTrackedServices(); - } else { - removeRoute(service); - } - } - - private boolean isPreStartRouteBuilder(ServiceReference reference) { - - boolean result = false; - - Object preStartProperty = reference.getProperty(CamelRoutesActivatorConstants.PRE_START_UP_PROP_NAME); - - if (preStartProperty instanceof Boolean) { - result = (Boolean)preStartProperty; - } else if (preStartProperty instanceof String) { - result = Boolean.parseBoolean((String) preStartProperty); - } - - return result; - } - - private void loadAndRestartCamelContext(List> existingRouteBuildersReferences) { - if (existingRouteBuildersReferences != null) { - List postStartUpRoutes = new ArrayList<>(); - for (ServiceReference currentRouteBuilderReference : existingRouteBuildersReferences) { - RouteBuilder builder = this.bundleContext.getService(currentRouteBuilderReference); - if (isPreStartRouteBuilder(currentRouteBuilderReference)) { - addRoute(builder); - } else { - postStartUpRoutes.add(builder); - } - } - camelContext.start(); - postStartUpRoutes.forEach(this::addRoute); - } - } - - private void reloadTrackedServices(ServiceReference reference) { - LOG.info("Reload Camel Context Routes Triggered"); - try { - synchronized (camelContext) { - stopAndClearCamelRoutes(); - List> routeServiceReferenceArrayList = new ArrayList<>(); - if (reference != null) { - routeServiceReferenceArrayList.add(reference); - } - ServiceReference[] existingTrackedRoutes = this.routeServiceTracker.getServiceReferences(); - if (existingTrackedRoutes != null) { - routeServiceReferenceArrayList.addAll(Arrays.asList(existingTrackedRoutes)); - } - loadAndRestartCamelContext(routeServiceReferenceArrayList); - } - } catch (Exception e) { - LOG.error("Error Reloading Camel Context Routes", e); - } - } - - private void reloadTrackedServices() { - reloadTrackedServices(null); - } - - private void addRoute(RouteBuilder builder) { - try { - // need to synchronize here since adding routes is not synchronized - synchronized (camelContext) { - this.camelContext.addRoutes(builder); - LOG.debug("Camel Routes from RouteBuilder Class {} Added to Camel OSGi Activator Context", builder.getClass().getName()); - } - } catch (Exception e) { - LOG.error("Error Adding Camel RouteBuilder", e); - } - } - - private void stopAndClearCamelRoutes() throws Exception { - camelContext.stop(); - camelContext.removeRouteDefinitions(new ArrayList(this.camelContext.getRouteDefinitions())); - } - - private void removeRoute(RouteBuilder service) { - List routesToBeRemoved = service.getRouteCollection().getRoutes(); - try { - synchronized (camelContext) { - camelContext.removeRouteDefinitions(routesToBeRemoved); - LOG.debug("Camel Routes from RouteBuilder Class {} Removed from Camel OSGi Activator Context", - service.getClass().getName()); - } - } catch (Exception e) { - LOG.error("Error Removing Camel Route Builder", e); - } - } - -} diff --git a/components/camel-osgi-activator/src/main/java/org/apache/camel/osgi/activator/CamelRoutesActivatorConstants.java b/components/camel-osgi-activator/src/main/java/org/apache/camel/osgi/activator/CamelRoutesActivatorConstants.java deleted file mode 100644 index dc015818c..000000000 --- a/components/camel-osgi-activator/src/main/java/org/apache/camel/osgi/activator/CamelRoutesActivatorConstants.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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.camel.osgi.activator; - -public final class CamelRoutesActivatorConstants { - - public static final String PRE_START_UP_PROP_NAME = "camel.osgi.activator.pre-startup"; - - private CamelRoutesActivatorConstants() { - - } -} diff --git a/components/camel-osgi-activator/src/test/java/org/apache/camel/component/osgi/activator/CamelOsgiActivatorIT.java b/components/camel-osgi-activator/src/test/java/org/apache/camel/component/osgi/activator/CamelOsgiActivatorIT.java deleted file mode 100644 index b2cac9b52..000000000 --- a/components/camel-osgi-activator/src/test/java/org/apache/camel/component/osgi/activator/CamelOsgiActivatorIT.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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.camel.component.osgi.activator; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Date; -import java.util.Dictionary; -import java.util.Hashtable; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import javax.inject.Inject; - -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.osgi.activator.CamelRoutesActivatorConstants; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.karaf.container.internal.JavaVersionUtil; -import org.ops4j.pax.exam.options.extra.VMOption; -import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; -import org.ops4j.pax.exam.spi.reactors.PerClass; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.ops4j.pax.exam.CoreOptions.junitBundles; -import static org.ops4j.pax.exam.CoreOptions.options; -import static org.ops4j.pax.exam.CoreOptions.streamBundle; -import static org.ops4j.pax.exam.CoreOptions.when; - -@RunWith(PaxExam.class) -@ExamReactorStrategy(PerClass.class) -public class CamelOsgiActivatorIT { - @Inject - private BundleContext bc; - - @Configuration - public Option[] configuration() throws IOException, URISyntaxException, ClassNotFoundException { - return options( - PaxExamOptions.KARAF.option(), - PaxExamOptions.CAMEL_CORE_OSGI.option(), - when(JavaVersionUtil.getMajorVersion() >= 16) - .useOptions( - new VMOption("--add-opens"), - new VMOption("java.base/java.net=ALL-UNNAMED"), - new VMOption("--add-opens"), - new VMOption("java.base/sun.net.www.protocol.file=ALL-UNNAMED"), - new VMOption("--add-opens"), - new VMOption("java.base/sun.net.www.protocol.ftp=ALL-UNNAMED"), - new VMOption("--add-opens"), - new VMOption("java.base/sun.net.www.protocol.http=ALL-UNNAMED"), - new VMOption("--add-opens"), - new VMOption("java.base/sun.net.www.protocol.https=ALL-UNNAMED"), - new VMOption("--add-opens"), - new VMOption("java.base/sun.net.www.protocol.jar=ALL-UNNAMED"), - new VMOption("--add-opens"), - new VMOption("java.base/sun.net.www.protocol.jmod=ALL-UNNAMED"), - new VMOption("--add-opens"), - new VMOption("java.base/sun.net.www.protocol.mailto=ALL-UNNAMED"), - new VMOption("--add-opens"), - new VMOption("java.base/sun.net.www.protocol.jrt=ALL-UNNAMED"), - new VMOption("--add-opens"), - new VMOption("java.base/jdk.internal.loader=ALL-UNNAMED"), - new VMOption("--add-opens"), - new VMOption("java.base/java.security=ALL-UNNAMED") - ), - streamBundle( - TinyBundles.bundle() - .read( - Files.newInputStream( - Paths.get("target/test-bundles") - .resolve("camel-osgi-activator.jar"))) - .build()), - junitBundles()); - } - - @Test - public void testBundleLoaded() throws Exception { - boolean hasOsgi = false; - boolean hasCamelCoreOsgiActivator = false; - for (Bundle b : bc.getBundles()) { - if ("org.apache.camel.karaf.camel-core-osgi".equals(b.getSymbolicName())) { - hasOsgi = true; - assertEquals("Camel Core OSGi not activated", Bundle.ACTIVE, b.getState()); - } - - if ("org.apache.camel.karaf.camel-osgi-activator".equals(b.getSymbolicName())) { - hasCamelCoreOsgiActivator = true; - assertEquals("Camel OSGi Activator not activated", Bundle.ACTIVE, b.getState()); - } - } - assertTrue("Camel Core OSGi bundle not found", hasOsgi); - assertTrue("Camel OSGi Activator bundle not found", hasCamelCoreOsgiActivator); - } - - @Test - public void testRouteLoadAndRemoved() throws Exception { - CountDownLatch latch = new CountDownLatch(1); - ServiceRegistration testServiceRegistration = bc.registerService(RouteBuilder.class, - new RouteBuilder() { - - @Override - public void configure() throws Exception { - from("timer:test?fixedRate=true&period=300").process(exchange -> { - latch.countDown(); - }); - } - }, null); - - latch.await(10, TimeUnit.SECONDS); - - CamelContext camelContext = bc.getService(bc.getServiceReference(CamelContext.class)); - - assertEquals("There should be one route in the context.", 1, camelContext.getRoutes().size()); - - testServiceRegistration.unregister(); - - assertEquals("There should be no routes in the context.", 0, camelContext.getRoutes().size()); - - } - - @Test - public void testPreStartupLoadAndRemoved() throws Exception { - CountDownLatch preStartLatch = new CountDownLatch(1); - - CountDownLatch postStartLatch = new CountDownLatch(1); - - CamelContext camelContext = bc.getService(bc.getServiceReference(CamelContext.class)); - - Date originalCamelStartTime = camelContext.getStartDate(); - - ServiceRegistration testRegularServiceRegistration = bc.registerService(RouteBuilder.class, - new RouteBuilder() { - - @Override - public void configure() throws Exception { - from("timer:test1?fixedRate=true&period=300") - .description("PostStartRoute") - .process(exchange -> { - postStartLatch.countDown(); - }); - } - }, null); - - postStartLatch.await(10, TimeUnit.SECONDS); - - Date regularRouteAddCamelContextStartTime = camelContext.getStartDate(); - - assertEquals("Camel Context Should NOT be restarted when removing regular RouteBuilder", originalCamelStartTime, regularRouteAddCamelContextStartTime); - - assertEquals("There should be one route in the context.", 1, camelContext.getRoutes().size()); - - assertEquals("The PostStartRoute should be first.", "PostStartRoute", camelContext.getRoutes().get(0).getDescription()); - - - Dictionary preStartUpProperties = new Hashtable<>(); - preStartUpProperties.put(CamelRoutesActivatorConstants.PRE_START_UP_PROP_NAME, "true"); - ServiceRegistration testPreStartupServiceRegistration = bc.registerService(RouteBuilder.class, - new RouteBuilder() { - - @Override - public void configure() throws Exception { - getContext().setStreamCaching(true); - - from("timer:test2?fixedRate=true&period=300") - .description("PreStartRoute") - .process(exchange -> { - preStartLatch.countDown(); - }); - - } - }, preStartUpProperties); - - preStartLatch.await(10, TimeUnit.SECONDS); - - Date preStartCamelContextStartTime = camelContext.getStartDate(); - - assertTrue("Camel Context Should be restarted when adding startup RouteBuilder", preStartCamelContextStartTime.after(originalCamelStartTime)); - - assertEquals("There should be two route in the context.", 2, camelContext.getRoutes().size()); - - assertEquals("The PreStartRoute should be first.", "PreStartRoute", camelContext.getRoutes().get(0).getDescription()); - - testPreStartupServiceRegistration.unregister(); - - Date preStartRemovedCamelContextStartTime = camelContext.getStartDate(); - - assertEquals("There should be one routes in the context.", 1, camelContext.getRoutes().size()); - - assertTrue("Camel Context Should be restarted when removing startup RouteBuilder", preStartRemovedCamelContextStartTime.after(preStartCamelContextStartTime)); - - testRegularServiceRegistration.unregister(); - - Date regularRouteRemovedCamelContextStartTime = camelContext.getStartDate(); - - assertEquals("Camel Context Should NOT be restarted when removing regular RouteBuilder", preStartRemovedCamelContextStartTime, regularRouteRemovedCamelContextStartTime); - - assertEquals("There should be no routes in the context.", 0, camelContext.getRoutes().size()); - - } - -} diff --git a/components/camel-osgi-activator/src/test/java/org/apache/camel/component/osgi/activator/PaxExamOptions.java b/components/camel-osgi-activator/src/test/java/org/apache/camel/component/osgi/activator/PaxExamOptions.java deleted file mode 100644 index c45f75a07..000000000 --- a/components/camel-osgi-activator/src/test/java/org/apache/camel/component/osgi/activator/PaxExamOptions.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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.camel.component.osgi.activator; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Paths; - -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.karaf.container.internal.JavaVersionUtil; -import org.ops4j.pax.exam.karaf.options.LogLevelOption; -import org.ops4j.pax.exam.options.DefaultCompositeOption; -import org.ops4j.pax.exam.options.extra.VMOption; -import org.ops4j.pax.tinybundles.core.TinyBundles; - -import static org.ops4j.pax.exam.CoreOptions.maven; -import static org.ops4j.pax.exam.CoreOptions.streamBundle; -import static org.ops4j.pax.exam.CoreOptions.when; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel; - -public enum PaxExamOptions { - - KARAF( - karafDistributionConfiguration() - .frameworkUrl( - maven() - .groupId("org.apache.karaf") - .artifactId("apache-karaf") - .versionAsInProject() - .type("zip")) - .name("Apache Karaf") - .useDeployFolder(false) - .unpackDirectory(new File("target/paxexam/unpack/")), - keepRuntimeFolder(), - // Don't bother with local console output as it just ends up cluttering the logs - configureConsole().ignoreLocalConsole(), - // Force the log level to INFO so we have more details during the test. It defaults to WARN. - logLevel(LogLevelOption.LogLevel.INFO), - when(JavaVersionUtil.getMajorVersion() >= 9) - .useOptions( - new VMOption("-classpath"), - new VMOption("lib/jdk9plus/*" + File.pathSeparator + "lib/boot/*") - ) - ), - CAMEL_CORE_OSGI( - createStreamBundleOption("camel-core-model.jar"), - createStreamBundleOption("camel-core-reifier.jar"), - createStreamBundleOption("camel-core-processor.jar"), - createStreamBundleOption("camel-core-engine.jar"), - createStreamBundleOption("camel-core-languages.jar"), - createStreamBundleOption("camel-api.jar"), - createStreamBundleOption("camel-base.jar"), - createStreamBundleOption("camel-base-engine.jar"), - createStreamBundleOption("camel-management-api.jar"), - createStreamBundleOption("camel-support.jar"), - createStreamBundleOption("camel-util.jar"), - createStreamBundleOption("camel-timer.jar"), - createStreamBundleOption("camel-log.jar"), - createStreamBundleOption("camel-core-osgi.jar") - ); - - private final Option[] options; - - PaxExamOptions(Option... options) { - this.options = options; - } - - public Option option() { - return new DefaultCompositeOption(options); - } - - public static Option createStreamBundleOption(String fileName) { - InputStream bundleInputStream = null; - try { - bundleInputStream = Files.newInputStream( - Paths.get("target/test-bundles") - .resolve(fileName)); - - } catch (IOException e) { - throw new RuntimeException("Error resolving Bundle", e); - } - - return streamBundle( - TinyBundles.bundle() - .read(bundleInputStream) - .build()); - } -} diff --git a/components/pom.xml b/components/pom.xml index 18e9fb30d..885b31243 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -43,7 +43,6 @@ camel-eventadmin camel-jcache-osgi camel-kura - camel-osgi-activator camel-paxlogging camel-servlet-osgi camel-test-karaf diff --git a/docs/modules/ROOT/pages/components.adoc b/docs/modules/ROOT/pages/components.adoc index 09809acb3..c902355fe 100644 --- a/docs/modules/ROOT/pages/components.adoc +++ b/docs/modules/ROOT/pages/components.adoc @@ -5,7 +5,7 @@ Apache Camel Karaf supports the following Camel artifacts as Karaf features == Camel Components // components: START -Number of Camel components: 204 in 204 JAR artifacts (11 deprecated) +Number of Camel components: 203 in 203 JAR artifacts (10 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -332,9 +332,6 @@ Number of Camel components: 204 in 204 JAR artifacts (11 deprecated) | xref:next@components::kamelet-component.adoc[Kamelet] (camel-kamelet) + `kamelet:templateId/routeId` | 3.8 | To call Kamelets -| xref:next@components::kamelet-reify-component.adoc[Kamelet Reify] (camel-kamelet-reify) + -`kamelet-reify:delegateUri` | 3.6 | *deprecated* To call Kamelets (indirectly) - | xref:next@components::kudu-component.adoc[Kudu] (camel-kudu) + `kudu:host:port/tableName` | 3.0 | Interact with Apache Kudu, a free and open source column-oriented data store of the Apache Hadoop ecosystem. @@ -856,7 +853,7 @@ Number of Camel languages: 20 in 13 JAR artifacts (0 deprecated) == Miscellaneous Extensions // others: START -Number of miscellaneous extensions: 20 in 20 JAR artifacts (5 deprecated) +Number of miscellaneous extensions: 19 in 19 JAR artifacts (4 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -901,9 +898,6 @@ Number of miscellaneous extensions: 20 in 20 JAR artifacts (5 deprecated) | xref:next@components:others:opentracing.adoc[OpenTracing] + (camel-opentracing) | 2.19 | Distributed tracing using OpenTracing -| xref:osgi-activator.adoc[Osgi Activator] + -(camel-osgi-activator) | 3.1 | *deprecated* Camel OSGi Activator for running Camel routes from other bundles - | xref:next@components:others:reactor.adoc[Reactor] + (camel-reactor) | 2.20 | Reactor based back-end for Camel's reactive streams component diff --git a/docs/modules/ROOT/pages/osgi-activator.adoc b/docs/modules/ROOT/pages/osgi-activator.adoc deleted file mode 100644 index 6546cb125..000000000 --- a/docs/modules/ROOT/pages/osgi-activator.adoc +++ /dev/null @@ -1,74 +0,0 @@ -[[OsgiActivator]] -= OSGi Camel Routes Activator (deprecated) -:page-source: components/camel-osgi-activator/src/main/docs/osgi-activator.adoc - -*Since Camel 3.1* - -A small OSGi activator for starting an OSGi Apache Camel Project. - -The bundle starts a shared CamelContext and registers any RouteBuilder instances -(discovered via the OSGi Service Registry), from any other bundles that gets installed. -And when the bundles gets uninstalled then the routes are stopped and removed from the shared CamelContext. - -== Important - -This OSGi activator is a based prototype for quickly starting up an OSGi container with a single shared -CamelContext and then being able to use OSGi dynamism to deploy and undeploy bundlers with Camel routes. - -Beware that this OSGi activator is a basic implementation and has limited support for dealing with errors -when new routes are added which may clash with existing routes (route ids). - -Configuration of the CamelContext is also very limited. - -Therefore only use this for prototyping and experiments. This is NOT recommended for production usage. - -== Install bundle - -Register an Apache Camel RouteBuilder as an OSGi service. - -Using OSGi annotations: - -[source,java] ----- -@Component(service = RouteBuilder.class) -public class MyRouteBuilder extends RouteBuilder { - @Override - public void configure() throws Exception { - from("timer:test?fixedRate=true&period=1000") - .log("Hello"); - } -} ----- - -Or Manually: - -[source,java] ----- -public void start(BundleContext context) throws Exception { - context.registerService(RouteBuilder.class, new MyRouteBuilder(), null); -} ----- - -And it's automatically added or removed to the context from any bundle! - -[source,text] ----- -Route: route1 started and consuming from: timer://test?fixedRate=true&period=1000 ----- - -For routes that need to be started before the CamelContext the "camel.osgi.activator.pre-startup" service property may be added. - -[source,java] ----- -@Component(service = RouteBuilder.class, property = {CamelRoutesActivatorConstants.PRE_START_UP_PROP_NAME + "=true"}) -public class MyStartupRouteBuilder extends RouteBuilder { - @Override - public void configure() throws Exception { - getContext().setStreamCaching(true); - - restConfiguration().component("netty-http").port(8080); - } -} ----- - -If this RouteBuilder is added after other non pre startup RouteBuilders then CamelContext will automatically restart. This allows pre start up RouteBuilder to run their configure methods before other RouteBuilders. diff --git a/pom.xml b/pom.xml index ccf31aecc..c4e95f2af 100644 --- a/pom.xml +++ b/pom.xml @@ -381,11 +381,6 @@ camel-kura ${project.version} - - org.apache.camel.karaf - camel-osgi-activator - ${project.version} - org.apache.camel.karaf camel-paxlogging diff --git a/tooling/camel-catalog-generator-karaf-maven-plugin/src/main/java/org/apache/camel/karaf/maven/PrepareCatalogKarafMojo.java b/tooling/camel-catalog-generator-karaf-maven-plugin/src/main/java/org/apache/camel/karaf/maven/PrepareCatalogKarafMojo.java index 3a0d29b26..2de939825 100644 --- a/tooling/camel-catalog-generator-karaf-maven-plugin/src/main/java/org/apache/camel/karaf/maven/PrepareCatalogKarafMojo.java +++ b/tooling/camel-catalog-generator-karaf-maven-plugin/src/main/java/org/apache/camel/karaf/maven/PrepareCatalogKarafMojo.java @@ -211,7 +211,6 @@ protected void executeFeatures(Set features) throws MojoExecutionExcepti // include others that are in camel-karaf only jsonFiles.add(new File(karafComponentsDir, "camel-blueprint/target/classes/blueprint.json")); jsonFiles.add(new File(karafComponentsDir, "camel-kura/target/classes/kura.json")); - jsonFiles.add(new File(karafComponentsDir, "camel-osgi-activator/target/classes/osgi-activator.json")); if (!jsonFiles.isEmpty()) { Path outDir = othersOutDir.toPath(); copyFiles(outDir, jsonFiles);