You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2018/07/27 09:57:19 UTC
[2/3] aries-jax-rs-whiteboard git commit: [ARIES-1821] Use prototype
scope
[ARIES-1821] Use prototype scope
HTTP Whiteboard spec recommends using prototype scope when registering
servlets and filters to prevent several init/destroy calls to the same
servlet/filter instance.
Also avoid CXFNonSpringServlet to destroy a bus whose lifecycle it does
not own.
Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/96ce3a2e
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/96ce3a2e
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/96ce3a2e
Branch: refs/heads/master
Commit: 96ce3a2ec84ef5054efe3645e71088198c32e543
Parents: d5e624e
Author: Carlos Sierra <cs...@apache.org>
Authored: Fri Jul 27 11:38:21 2018 +0200
Committer: Carlos Sierra <cs...@apache.org>
Committed: Fri Jul 27 11:38:21 2018 +0200
----------------------------------------------------------------------
.../jax/rs/whiteboard/internal/Whiteboard.java | 30 ++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/96ce3a2e/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
index 73c90c9..6f95123 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
@@ -33,6 +33,7 @@ import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.PrototypeServiceFactory;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.wiring.BundleWiring;
@@ -1151,8 +1152,16 @@ public class Whiteboard {
}
private static CXFNonSpringServlet createCXFServlet(Bus bus) {
- CXFNonSpringServlet cxfNonSpringServlet = new CXFNonSpringServlet();
+ CXFNonSpringServlet cxfNonSpringServlet = new CXFNonSpringServlet() {
+
+ @Override
+ public void destroyBus() {
+ }
+
+ };
+
cxfNonSpringServlet.setBus(bus);
+
return cxfNonSpringServlet;
}
@@ -1277,7 +1286,24 @@ public class Whiteboard {
return program.then(
register(
- Servlet.class, () -> createCXFServlet(bus),
+ Servlet.class,
+ new PrototypeServiceFactory<Servlet>() {
+ @Override
+ public Servlet getService(
+ Bundle bundle,
+ ServiceRegistration<Servlet> registration) {
+
+ return createCXFServlet(bus);
+ }
+
+ @Override
+ public void ungetService(
+ Bundle bundle,
+ ServiceRegistration<Servlet> registration,
+ Servlet service) {
+
+ }
+ },
servletPropertiesSup));
}