diff --git a/examples/aem-caravan-jaxrs-sample/build-deploy-author-and-publish.sh b/examples/aem-caravan-jaxrs-sample/build-deploy-author-and-publish.sh new file mode 100644 index 0000000..2bb9f01 --- /dev/null +++ b/examples/aem-caravan-jaxrs-sample/build-deploy-author-and-publish.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# #%L +# wcm.io +# %% +# Copyright (C) 2021 wcm.io +# %% +# Licensed 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. +# #L% + +# Builds the application, deploys it to local author, and then deploys it to local publish as well (without building it again) +# Deployment to author and publish runs in parallel + +# Display a pause message (only when the script was executed via double-click on windows) +pause_message() { + if [ "$DISPLAY_PAUSE_MESSAGE_WRAPPER" = true ]; then + echo "" + read -n1 -r -p "Press any key to continue..." + fi +} + +if [[ $0 == *":\\"* ]]; then + DISPLAY_PAUSE_MESSAGE_WRAPPER=true +fi + +# Build application +./build-deploy.sh build --maven.profiles=fast "$@" +if [ "$?" -ne "0" ]; then + pause_message + exit $? +fi + +# Deploy to author (in parallel) +./build-deploy.sh deploy --maven.profiles=fast --conga.node=aem-author "$@" & + +# Deploy to publish (in parallel) +./build-deploy.sh deploy --maven.profiles=fast,publish --conga.node=aem-publish "$@" & + +wait +pause_message diff --git a/examples/aem-caravan-jaxrs-sample/build-deploy-publish.sh b/examples/aem-caravan-jaxrs-sample/build-deploy-publish.sh index 840b38b..30d36c1 100644 --- a/examples/aem-caravan-jaxrs-sample/build-deploy-publish.sh +++ b/examples/aem-caravan-jaxrs-sample/build-deploy-publish.sh @@ -1,8 +1,8 @@ -#!/bin/sh +#!/bin/bash # #%L # wcm.io # %% -# Copyright (C) 2017 wcm.io +# Copyright (C) 2017 - 2021 wcm.io # %% # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,11 +19,11 @@ # Call with "help" parameter to display syntax information -SLING_URL="http://localhost:4503" +MAVEN_PROFILES="fast,publish" CONGA_NODE="aem-publish" if [[ $0 == *":\\"* ]]; then DISPLAY_PAUSE_MESSAGE=true fi -./build-deploy.sh --sling.url=${SLING_URL} --conga.node=${CONGA_NODE} --display.pause.message=${DISPLAY_PAUSE_MESSAGE} "$@" +./build-deploy.sh --maven.profiles=${MAVEN_PROFILES} --conga.node=${CONGA_NODE} --display.pause.message=${DISPLAY_PAUSE_MESSAGE} "$@" diff --git a/examples/aem-caravan-jaxrs-sample/build-deploy.sh b/examples/aem-caravan-jaxrs-sample/build-deploy.sh index b4c0acf..1eb13ad 100644 --- a/examples/aem-caravan-jaxrs-sample/build-deploy.sh +++ b/examples/aem-caravan-jaxrs-sample/build-deploy.sh @@ -1,8 +1,8 @@ -#!/bin/sh +#!/bin/bash # #%L # wcm.io # %% -# Copyright (C) 2017 wcm.io +# Copyright (C) 2017 - 2022 wcm.io # %% # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,10 +20,11 @@ # Call with "help" parameter to display syntax information # defaults -SLING_URL="http://localhost:4502" -SLING_USER="admin" -SLING_PASSWORD="admin" -CONGA_ENVIRONMENT="development" +MAVEN_PROFILES="fast" +SLING_URL="" +SLING_USER="" +SLING_PASSWORD="" +CONGA_ENVIRONMENT="local" CONGA_NODE="aem-author" JVM_ARGS="" @@ -36,19 +37,18 @@ DEPLOY=false HELP=false DEFAULT_COMMANDS=true -#### - help_message_exit() { echo "" echo " Syntax " echo "" echo " Parameters:" - echo " --sling.url=${SLING_URL}" - echo " --sling.user=${SLING_USER}" - echo " --sling.password=${SLING_PASSWORD}" - echo " --conga.environment=${CONGA_ENVIRONMENT}" - echo " --conga.node=${CONGA_NODE}" - echo " --jvm.args=${JVM_ARGS}" + echo " --maven.profiles=${MAVEN_PROFILES} or -P${MAVEN_PROFILES}" + echo " --sling.url=${SLING_URL} or -Dsling.url=${SLING_URL}" + echo " --sling.user=${SLING_USER} or -Dsling.user=${SLING_USER}" + echo " --sling.password=${SLING_PASSWORD} or -Dsling.password=${SLING_PASSWORD}" + echo " --conga.environment=${CONGA_ENVIRONMENT} or -Dconga.environment=${CONGA_ENVIRONMENT}" + echo " --conga.node=${CONGA_NODE} or -Dconga.node=${CONGA_NODE}" + echo " --jvm.args=${JVM_ARGS} or -Djvm.args=${JVM_ARGS}" echo "" echo " Commands:" echo " build - Clean and install maven project" @@ -64,6 +64,10 @@ parse_parameters() { for i in "$@" do case $i in + --maven\.profiles=*|-P*) + MAVEN_PROFILES="${i#*=}" + shift # past argument=value + ;; --sling\.url=*|-Dsling\.url=*) SLING_URL="${i#*=}" shift # past argument=value @@ -119,74 +123,95 @@ parse_parameters() { } welcome_message() { - echo -e "********************************************************************\e[96m" + echo "********************************************************************" if ([ "$BUILD" = true ] && [ "$DEPLOY" = true ]) || [ "$HELP" = true ]; then - echo " ___ _ _ ___ _ ___ _ ___ ___ ___ _ _____ __" - echo " | _ ) | | |_ _| | | \ _| |_ | \| __| _ \ | / _ \ \ / /" - echo " | _ \ |_| || || |__| |) | |_ _| | |) | _|| _/ |_| (_) \ V /" - echo " |___/\___/|___|____|___/ |_| |___/|___|_| |____\___/ |_|" + echo -e "\e[96m ___ _ _ ___ _ ___ _ ___ ___ ___ _ _____ __\e[0m" + echo -e "\e[96m | _ ) | | |_ _| | | \ _| |_ | \| __| _ \ | / _ \ \ / /\e[0m" + echo -e "\e[96m | _ \ |_| || || |__| |) | |_ _| | |) | _|| _/ |_| (_) \ V /\e[0m" + echo -e "\e[96m |___/\___/|___|____|___/ |_| |___/|___|_| |____\___/ |_|\e[0m" elif [ "$BUILD" = true ]; then - echo " ___ _ _ ___ _ ___ " - echo " | _ ) | | |_ _| | | \\" - echo " | _ \ |_| || || |__| |) |" - echo " |___/\___/|___|____|___/" + echo -e "\e[96m ___ _ _ ___ _ ___ \e[0m" + echo -e "\e[96m | _ ) | | |_ _| | | \\ \e[0m" + echo -e "\e[96m | _ \ |_| || || |__| |) |\e[0m" + echo -e "\e[96m |___/\___/|___|____|___/\e[0m" elif [ "$DEPLOY" = true ]; then - echo " ___ ___ ___ _ _____ __" - echo " | \| __| _ \ | / _ \ \ / /" - echo " | |) | _|| _/ |_| (_) \ V /" - echo " |___/|___|_| |____\___/ |_|" + echo -e "\e[96m ___ ___ ___ _ _____ __\e[0m" + echo -e "\e[96m | \| __| _ \ | / _ \ \ / /\e[0m" + echo -e "\e[96m | |) | _|| _/ |_| (_) \ V /\e[0m" + echo -e "\e[96m |___/|___|_| |____\___/ |_|\e[0m" fi - echo -e "\e[0m" - echo -e " Destination: \e[1m${SLING_URL}\e[0m (\e[1m${CONGA_NODE}\e[0m)" + echo "" + echo -e " Destination: \e[1m${CONGA_NODE}\e[0m (${MAVEN_PROFILES})" echo "" echo "********************************************************************" } completion_message() { + ELAPSED_TIME=$(($SECONDS - $START_TIME)) + TOTAL_TIME="($(($ELAPSED_TIME/60)):$(printf "%02d" $(($ELAPSED_TIME%60))) min)" + echo "" if [ "$BUILD" = true ] && [ "$DEPLOY" = true ]; then - echo -e "*** \e[1mBuild+Deploy complete\e[0m ***" + echo -e "*** \e[1mBuild+Deploy complete\e[0m $TOTAL_TIME ***" elif [ "$BUILD" = true ]; then - echo -e "*** \e[1mBuild complete\e[0m ***" + echo -e "*** \e[1mBuild complete\e[0m $TOTAL_TIME ***" elif [ "$DEPLOY" = true ]; then - echo -e "*** \e[1mDeploy complete\e[0m ***" + echo -e "*** \e[1mDeploy complete\e[0m $TOTAL_TIME ***" fi echo "" pause_message } -#### - execute_build() { echo "" echo -e "*** \e[1mBuild application\e[0m ***" echo "" - mvn ${JVM_ARGS} \ - -Dconga.environments=${CONGA_ENVIRONMENT} \ - -Pfast clean install eclipse:eclipse - + MAVEN_ARGS="" + if [ -n "$JVM_ARGS" ]; then + MAVEN_ARGS+="${JVM_ARGS} " + fi + if [ -n "${MAVEN_PROFILES}" ]; then + MAVEN_ARGS+="--activate-profiles ${MAVEN_PROFILES} " + fi + if [ -n "${CONGA_ENVIRONMENT}" ]; then + MAVEN_ARGS+="-Dconga.environments=${CONGA_ENVIRONMENT} " + fi + + mvn $MAVEN_ARGS clean install eclipse:eclipse + if [ "$?" -ne "0" ]; then exit_with_error "*** BUILD FAILED ***" fi } -#### - execute_deploy() { echo "" echo -e "*** \e[1mDeploy to AEM\e[0m ***" echo "" - mvn -f config-definition \ - ${JVM_ARGS} \ - -Dconga.environments=${CONGA_ENVIRONMENT} \ - -Dconga.nodeDirectory=target/configuration/${CONGA_ENVIRONMENT}/${CONGA_NODE} \ - -Dsling.url=${SLING_URL} \ - -Dsling.user=${SLING_USER} \ - -Dsling.password=${SLING_PASSWORD} \ - conga-aem:package-install + MAVEN_ARGS="" + if [ -n "$JVM_ARGS" ]; then + MAVEN_ARGS+="${JVM_ARGS} " + fi + if [ -n "${MAVEN_PROFILES}" ]; then + MAVEN_ARGS+="--activate-profiles=${MAVEN_PROFILES} " + fi + if [ -n "${CONGA_ENVIRONMENT}" ] && [ -n "${CONGA_NODE}" ]; then + MAVEN_ARGS+="-Dconga.environments=${CONGA_ENVIRONMENT} -Dconga.nodeDirectory=target/configuration/${CONGA_ENVIRONMENT}/${CONGA_NODE} " + fi + if [ -n "${SLING_URL}" ]; then + MAVEN_ARGS+="-Dsling.url=${SLING_URL} " + fi + if [ -n "${SLING_USER}" ]; then + MAVEN_ARGS+="-Dsling.user=${SLING_USER} " + fi + if [ -n "${SLING_PASSWORD}" ]; then + MAVEN_ARGS+="-Dsling.password=${SLING_PASSWORD} " + fi + + mvn $MAVEN_ARGS -f config-definition conga-aem:package-install if [ "$?" -ne "0" ]; then exit_with_error "*** DEPLOY FAILED ***" @@ -194,8 +219,6 @@ execute_deploy() { } -#### - # Display a pause message (only when the script was executed via double-click on windows) pause_message() { if [ "$DISPLAY_PAUSE_MESSAGE" = true ]; then @@ -212,7 +235,8 @@ exit_with_error() { exit 1 } -#### + +START_TIME=$SECONDS parse_parameters "$@" welcome_message diff --git a/examples/aem-caravan-jaxrs-sample/config-definition/pom.xml b/examples/aem-caravan-jaxrs-sample/config-definition/pom.xml index 9b1dc6c..1f1dc69 100644 --- a/examples/aem-caravan-jaxrs-sample/config-definition/pom.xml +++ b/examples/aem-caravan-jaxrs-sample/config-definition/pom.xml @@ -65,9 +65,6 @@ generate - - ${basedir}/src/main/dev-environments - diff --git a/examples/aem-caravan-jaxrs-sample/config-definition/src/main/dev-environments/development.yaml b/examples/aem-caravan-jaxrs-sample/config-definition/src/main/environments/local.yaml similarity index 100% rename from examples/aem-caravan-jaxrs-sample/config-definition/src/main/dev-environments/development.yaml rename to examples/aem-caravan-jaxrs-sample/config-definition/src/main/environments/local.yaml diff --git a/examples/aem-caravan-jaxrs-sample/parent/pom.xml b/examples/aem-caravan-jaxrs-sample/parent/pom.xml index c63a38a..6857682 100644 --- a/examples/aem-caravan-jaxrs-sample/parent/pom.xml +++ b/examples/aem-caravan-jaxrs-sample/parent/pom.xml @@ -114,12 +114,12 @@ junit junit - 4.13.1 + 4.13.2 org.mockito mockito-core - 2.12.0 + 5.11.0 diff --git a/integration-test/sample-service-1/pom.xml b/integration-test/sample-service-1/pom.xml index 8633fcb..21ce367 100644 --- a/integration-test/sample-service-1/pom.xml +++ b/integration-test/sample-service-1/pom.xml @@ -32,7 +32,7 @@ io.wcm.caravan io.wcm.caravan.jaxrs.integration-test.sample-service-1 1-SNAPSHOT - bundle + jar JAX-RS Integration Test Sample Service 1 @@ -51,12 +51,21 @@ - org.apache.felix - maven-bundle-plugin + biz.aQute.bnd + bnd-maven-plugin - - /caravan/jaxrs/test/sampleservice1 - + + Caravan-JaxRs-ApplicationPath: /caravan/jaxrs/test/sampleservice1 + + + + + org.apache.maven.plugins + maven-jar-plugin + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + diff --git a/integration-test/sample-service-1/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice1/JaxRsGlobalService.java b/integration-test/sample-service-1/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice1/JaxRsGlobalService.java index e71f0fa..fbf5ce0 100644 --- a/integration-test/sample-service-1/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice1/JaxRsGlobalService.java +++ b/integration-test/sample-service-1/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice1/JaxRsGlobalService.java @@ -23,11 +23,10 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.Service; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ServiceScope; import io.wcm.caravan.jaxrs.publisher.ApplicationPath; import io.wcm.caravan.jaxrs.publisher.JaxRsComponent; @@ -35,9 +34,10 @@ /** * Sample JAX-RS Service that is registered to all JAX-RS appliations in the OSGi container. */ -@Component -@Service(value = JaxRsComponent.class, serviceFactory = true) -@Property(name = JaxRsComponent.PROPERTY_GLOBAL_COMPONENT, value = "true") +@Component( + service = JaxRsComponent.class, + scope = ServiceScope.BUNDLE, + property = JaxRsComponent.PROPERTY_GLOBAL_COMPONENT + "=true") @Path("/globalServiceId") public class JaxRsGlobalService implements JaxRsComponent { diff --git a/integration-test/sample-service-1/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice1/JaxRsService.java b/integration-test/sample-service-1/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice1/JaxRsService.java index edcd246..38c709a 100644 --- a/integration-test/sample-service-1/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice1/JaxRsService.java +++ b/integration-test/sample-service-1/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice1/JaxRsService.java @@ -23,10 +23,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Service; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; import io.wcm.caravan.jaxrs.publisher.ApplicationPath; import io.wcm.caravan.jaxrs.publisher.JaxRsComponent; @@ -34,8 +33,7 @@ /** * Sample JAX-RS Service */ -@Component(immediate = true) -@Service(JaxRsComponent.class) +@Component(service = JaxRsComponent.class, immediate = true) @Path("/serviceId") public class JaxRsService implements JaxRsComponent { diff --git a/integration-test/sample-service-2/pom.xml b/integration-test/sample-service-2/pom.xml index f4f6b4a..22f1776 100644 --- a/integration-test/sample-service-2/pom.xml +++ b/integration-test/sample-service-2/pom.xml @@ -32,7 +32,7 @@ io.wcm.caravan io.wcm.caravan.jaxrs.integration-test.sample-service-2 1-SNAPSHOT - bundle + jar JAX-RS Integration Test Sample Service 2 @@ -51,12 +51,21 @@ - org.apache.felix - maven-bundle-plugin + biz.aQute.bnd + bnd-maven-plugin - - /caravan/jaxrs/test/sampleservice2 - + + Caravan-JaxRs-ApplicationPath: /caravan/jaxrs/test/sampleservice2 + + + + + org.apache.maven.plugins + maven-jar-plugin + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + diff --git a/integration-test/sample-service-2/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice2/JaxRsClassesProviderService.java b/integration-test/sample-service-2/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice2/JaxRsClassesProviderService.java index 1adb41e..88d5c02 100644 --- a/integration-test/sample-service-2/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice2/JaxRsClassesProviderService.java +++ b/integration-test/sample-service-2/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice2/JaxRsClassesProviderService.java @@ -21,23 +21,19 @@ import java.util.Set; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Service; - -import com.google.common.collect.ImmutableSet; +import org.osgi.service.component.annotations.Component; import io.wcm.caravan.jaxrs.publisher.JaxRsClassesProvider; /** * Sample JAX-RS classes provider. */ -@Component(immediate = true) -@Service(JaxRsClassesProvider.class) +@Component(service = JaxRsClassesProvider.class, immediate = true) public class JaxRsClassesProviderService implements JaxRsClassesProvider { @Override public Set> getClasses() { - return ImmutableSet.of(RequestScopeDateResource.class); + return Set.of(RequestScopeDateResource.class); } } diff --git a/integration-test/sample-service-2/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice2/JaxRsService.java b/integration-test/sample-service-2/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice2/JaxRsService.java index e5acae9..55430a4 100644 --- a/integration-test/sample-service-2/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice2/JaxRsService.java +++ b/integration-test/sample-service-2/src/main/java/io/wcm/caravan/jaxrs/publisher/sampleservice2/JaxRsService.java @@ -23,10 +23,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Service; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; import io.wcm.caravan.jaxrs.publisher.ApplicationPath; import io.wcm.caravan.jaxrs.publisher.JaxRsComponent; @@ -34,8 +33,7 @@ /** * Sample JAX-RS Service */ -@Component(immediate = true) -@Service(JaxRsComponent.class) +@Component(service = JaxRsComponent.class, immediate = true) @Path("/serviceId") public class JaxRsService implements JaxRsComponent { diff --git a/parent/pom.xml b/parent/pom.xml index ab59942..020a148 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -55,11 +55,18 @@ + - org.apache.felix - org.apache.felix.scr.annotations + org.osgi + org.osgi.annotation.bundle + provided + + + org.osgi + org.osgi.annotation.versioning provided + org.osgi osgi.core diff --git a/publisher/pom.xml b/publisher/pom.xml index 728e0a4..471bd92 100644 --- a/publisher/pom.xml +++ b/publisher/pom.xml @@ -32,7 +32,7 @@ io.wcm.caravan io.wcm.caravan.jaxrs.publisher 1.2.1-SNAPSHOT - bundle + jar JAX-RS Publisher Publishes OSGi services as JAX-RS RESTful services. @@ -98,16 +98,21 @@ - org.apache.felix - maven-bundle-plugin - - - baseline - - baseline - - - + biz.aQute.bnd + bnd-maven-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + + biz.aQute.bnd + bnd-baseline-maven-plugin diff --git a/publisher/src/main/java/io/wcm/caravan/jaxrs/publisher/impl/JaxRsBundleTracker.java b/publisher/src/main/java/io/wcm/caravan/jaxrs/publisher/impl/JaxRsBundleTracker.java index 9210ec1..adc0c48 100644 --- a/publisher/src/main/java/io/wcm/caravan/jaxrs/publisher/impl/JaxRsBundleTracker.java +++ b/publisher/src/main/java/io/wcm/caravan/jaxrs/publisher/impl/JaxRsBundleTracker.java @@ -19,16 +19,10 @@ */ package io.wcm.caravan.jaxrs.publisher.impl; -import io.wcm.caravan.jaxrs.publisher.ApplicationPath; - import java.util.Dictionary; import java.util.Hashtable; import org.apache.commons.lang3.StringUtils; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Reference; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleEvent; @@ -36,11 +30,17 @@ import org.osgi.service.component.ComponentContext; import org.osgi.service.component.ComponentFactory; import org.osgi.service.component.ComponentInstance; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; import org.osgi.util.tracker.BundleTracker; import org.osgi.util.tracker.BundleTrackerCustomizer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.wcm.caravan.jaxrs.publisher.ApplicationPath; + /** * Bundle tracker that listens for all bundles added to the OSGi systems, and searches for JAX-RS components. * If any is found and an application path is defined a jersey instance dedicated to this bundle is instantiated. @@ -50,21 +50,20 @@ public class JaxRsBundleTracker implements BundleTrackerCustomizer bundleTracker; @Reference(target = "(" + ComponentConstants.COMPONENT_FACTORY + "=" + ServletContainerBridge.SERVLETCONTAINER_BRIDGE_FACTORY + ")") private ComponentFactory servletContainerBridgeFactory; @Activate void activate(ComponentContext componentContext) { - bundleContext = componentContext.getBundleContext(); + BundleContext bundleContext = componentContext.getBundleContext(); this.bundleTracker = new BundleTracker(bundleContext, Bundle.ACTIVE, this); this.bundleTracker.open(); } @Deactivate - void deactivate(ComponentContext componentContext) { + void deactivate() { this.bundleTracker.close(); } diff --git a/publisher/src/main/java/io/wcm/caravan/jaxrs/publisher/impl/ServletContainerBridge.java b/publisher/src/main/java/io/wcm/caravan/jaxrs/publisher/impl/ServletContainerBridge.java index b04fc1e..c620491 100644 --- a/publisher/src/main/java/io/wcm/caravan/jaxrs/publisher/impl/ServletContainerBridge.java +++ b/publisher/src/main/java/io/wcm/caravan/jaxrs/publisher/impl/ServletContainerBridge.java @@ -28,10 +28,6 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Service; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.servlet.ServletContainer; import org.osgi.framework.Bundle; @@ -39,6 +35,9 @@ import org.osgi.framework.Constants; import org.osgi.framework.ServiceReference; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; import org.osgi.util.tracker.ServiceTracker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,8 +53,7 @@ * It automatically registers JAX-RS components from the current bundle and instances * from global JAX-RS components factories. */ -@Component(factory = ServletContainerBridge.SERVLETCONTAINER_BRIDGE_FACTORY) -@Service(Servlet.class) +@Component(service = Servlet.class, factory = ServletContainerBridge.SERVLETCONTAINER_BRIDGE_FACTORY) public class ServletContainerBridge extends HttpServlet { private static final long serialVersionUID = 1L; @@ -69,10 +67,10 @@ public class ServletContainerBridge extends HttpServlet { private volatile boolean isDirty; private Set localComponents; private Set globalComponents; - private ServiceTracker jaxRsComponentTracker; + private ServiceTracker jaxRsComponentTracker; private Set localClassesProviders; private Set globalClassesProviders; - private ServiceTracker jaxClassesProviderTracker; + private ServiceTracker jaxClassesProviderTracker; static final Logger log = LoggerFactory.getLogger(ServletContainerBridge.class); @@ -97,7 +95,7 @@ void activate(ComponentContext componentContext) { } @Deactivate - void deactivate(ComponentContext componentContext) { + void deactivate() { if (jaxRsComponentTracker != null) { jaxRsComponentTracker.close(); }