From dc4987cb96fc723d1b3864871d9cd196da5ea2f1 Mon Sep 17 00:00:00 2001 From: Ivan Akulenka Date: Mon, 18 Mar 2024 19:12:18 +0300 Subject: [PATCH] AEM as a Cloud Service: components and services request in dev.tools are not working (#4) - instead of bundle reference, bundle ID is passed. - constant naming and value correspondent adjustment --------- Co-authored-by: Ivan Akulenka Co-authored-by: Stefan Seifert --- publisher/changes.xml | 6 ++++++ .../caravan/jaxrs/publisher/impl/JaxRsBundleTracker.java | 2 +- .../jaxrs/publisher/impl/ServletContainerBridge.java | 5 +++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/publisher/changes.xml b/publisher/changes.xml index 8fa6807..96ee4c5 100644 --- a/publisher/changes.xml +++ b/publisher/changes.xml @@ -23,6 +23,12 @@ xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd"> + + + Fix issue with AEMaaCS: Use bundle ID instead of bundle instance to pass over bundle reference to ServletContainerBridge. + + + Add new interface "JaxRsClassesProvider" to allow to register additional resources, providers and features that are not OSGi components. 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 158a7aa..9210ec1 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 @@ -80,7 +80,7 @@ public ComponentInstance addingBundle(Bundle bundle, BundleEvent event) { // register JAX-RS application as servlet on HTTP whiteboard Dictionary serviceConfig = new Hashtable<>(); serviceConfig.put("alias", applicationPath); - serviceConfig.put(ServletContainerBridge.PROPERTY_BUNDLE, bundle); + serviceConfig.put(ServletContainerBridge.PROPERTY_BUNDLE_ID, bundle.getBundleId()); return servletContainerBridgeFactory.newInstance(serviceConfig); } return null; 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 7ba4d3a..b04fc1e 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 @@ -60,7 +60,7 @@ public class ServletContainerBridge extends HttpServlet { private static final long serialVersionUID = 1L; static final String SERVLETCONTAINER_BRIDGE_FACTORY = "caravan.jaxrs.servletcontainer.bridge.factory"; - static final String PROPERTY_BUNDLE = "caravan.jaxrs.relatedBundle"; + static final String PROPERTY_BUNDLE_ID = "caravan.jaxrs.relatedBundleId"; private BundleContext bundleContext; private Bundle bundle; @@ -79,7 +79,8 @@ public class ServletContainerBridge extends HttpServlet { @Activate void activate(ComponentContext componentContext) { // bundle which contains the JAX-RS services - bundle = (Bundle)componentContext.getProperties().get(PROPERTY_BUNDLE); + bundle = componentContext.getBundleContext().getBundle( + (Long)componentContext.getProperties().get(PROPERTY_BUNDLE_ID)); bundleContext = bundle.getBundleContext(); // initialize component tracker to detect local and global JAX-RS components for current bundle