diff options
author | gjoranv <gv@oath.com> | 2018-02-21 14:01:53 +0100 |
---|---|---|
committer | gjoranv <gv@oath.com> | 2018-02-21 14:01:53 +0100 |
commit | d3864acf70e9eb56c0e4d205a0b98fb82ebc85d1 (patch) | |
tree | 55fa5388f4f3957adf68869ed642dc25729bd74b /container-disc | |
parent | 108ab8eb0781fb59b8cbc13281816d5f7425b064 (diff) |
Remove JacksonJaxrsResolverHook and the BundleActivator.
- Their only purpose was to ensure corresponding versions of
jackson and jersey. We now only use jersey2.
Diffstat (limited to 'container-disc')
3 files changed, 0 insertions, 106 deletions
diff --git a/container-disc/pom.xml b/container-disc/pom.xml index 38b4bfc2ff5..f062efcd4a6 100644 --- a/container-disc/pom.xml +++ b/container-disc/pom.xml @@ -177,7 +177,6 @@ <artifactId>bundle-plugin</artifactId> <extensions>true</extensions> <configuration> - <Bundle-Activator>com.yahoo.container.jdisc.osgi.ContainerBundleActivator</Bundle-Activator> <discApplicationClass>com.yahoo.container.jdisc.ConfiguredApplication</discApplicationClass> <discPreInstallBundle> config-bundle-jar-with-dependencies.jar, diff --git a/container-disc/src/main/java/com/yahoo/container/jdisc/osgi/ContainerBundleActivator.java b/container-disc/src/main/java/com/yahoo/container/jdisc/osgi/ContainerBundleActivator.java deleted file mode 100644 index 1f8163ff0d2..00000000000 --- a/container-disc/src/main/java/com/yahoo/container/jdisc/osgi/ContainerBundleActivator.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.jdisc.osgi; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.framework.hooks.resolver.ResolverHookFactory; - -import java.util.Hashtable; - -/** - * @author tonytv - */ -public class ContainerBundleActivator implements BundleActivator { - - private ServiceRegistration<ResolverHookFactory> resolverHookFactoryServiceRegistration; - - @Override - public void start(BundleContext bundleContext) throws Exception { - resolverHookFactoryServiceRegistration = bundleContext.registerService( - ResolverHookFactory.class, - new JacksonJaxrsResolverHook.Factory(), - new Hashtable<>()); - } - - @Override - public void stop(BundleContext bundleContext) throws Exception { - resolverHookFactoryServiceRegistration.unregister(); - } - -} diff --git a/container-disc/src/main/java/com/yahoo/container/jdisc/osgi/JacksonJaxrsResolverHook.java b/container-disc/src/main/java/com/yahoo/container/jdisc/osgi/JacksonJaxrsResolverHook.java deleted file mode 100644 index 1b4ba3a16c2..00000000000 --- a/container-disc/src/main/java/com/yahoo/container/jdisc/osgi/JacksonJaxrsResolverHook.java +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.jdisc.osgi; - -import com.yahoo.log.LogLevel; -import org.osgi.framework.Bundle; -import org.osgi.framework.hooks.resolver.ResolverHook; -import org.osgi.framework.hooks.resolver.ResolverHookFactory; -import org.osgi.framework.wiring.BundleCapability; -import org.osgi.framework.wiring.BundleRequirement; -import org.osgi.framework.wiring.BundleRevision; - -import java.util.Collection; -import java.util.Iterator; -import java.util.function.Predicate; -import java.util.logging.Logger; - -/** - * Makes jackson1 jaxrs integration use jersey1 and jackson2 jaxrs integration use jersey2 - * @author tonytv - */ -public class JacksonJaxrsResolverHook implements ResolverHook { - private static Logger log = Logger.getLogger(JacksonJaxrsResolverHook.class.getName()); - - public static class Factory implements ResolverHookFactory { - @Override - public ResolverHook begin(Collection<BundleRevision> bundleRevisions) { - return new JacksonJaxrsResolverHook(); - } - } - - @Override - public void filterResolvable(Collection<BundleRevision> bundleRevisions) {} - - @Override - public void filterSingletonCollisions(BundleCapability bundleCapability, Collection<BundleCapability> bundleCapabilities) {} - - @Override - public void filterMatches(BundleRequirement bundleRequirement, Collection<BundleCapability> bundleCapabilities) { - Bundle bundle = bundleRequirement.getRevision().getBundle(); - String symbolicName = bundle.getSymbolicName(); - - log.log(LogLevel.DEBUG, "Filtering matches for " + symbolicName); - - if (symbolicName.startsWith("com.fasterxml.jackson.jaxrs")) - removeBundlesMatching(bundleCapabilities, JacksonJaxrsResolverHook::isJaxRs1Bundle); - else if (symbolicName.equals("jackson-jaxrs") && bundle.getVersion().getMajor() == 1) { - removeBundlesMatching(bundleCapabilities, JacksonJaxrsResolverHook::isJaxRs2Bundle); - } - } - - private static boolean isJaxRs1Bundle(String bundleSymbolicName) { - return bundleSymbolicName.startsWith("com.sun.jersey."); - } - - private static boolean isJaxRs2Bundle(String bundleSymbolicName) { - return bundleSymbolicName.startsWith("org.glassfish.jersey.") || - bundleSymbolicName.equals("javax.ws.rs-api"); - } - - private void removeBundlesMatching(Collection<BundleCapability> bundleCapabilities, Predicate<String> symbolicNamePredicate) { - for (Iterator<BundleCapability> i = bundleCapabilities.iterator(); i.hasNext(); ) { - BundleCapability bundleCapability = i.next(); - String symbolicName = bundleCapability.getRevision().getSymbolicName(); - - if (symbolicNamePredicate.test(symbolicName)) { - log.log(LogLevel.DEBUG, "- Removing bundle " + symbolicName); - i.remove(); - } - } - } - - @Override - public void end() {} -} |