Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Upgrade dependencies versions #44

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'net.researchgate.release' version '2.3.4'
id 'net.researchgate.release' version '2.6.0'
}

task wrapper(type: Wrapper) {
gradleVersion = '2.11'
gradleVersion = '5.1.1'
}

allprojects {
Expand All @@ -16,8 +16,8 @@ allprojects {
// UTF-8 should be standard by now. So use it!
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8

group = 'com.squarespace.jersey2-guice'

Expand All @@ -38,9 +38,9 @@ allprojects {
subprojects {

project.ext {
guiceVersion = '4.0'
jerseyVersion = '2.22.2'
hk2Version = '2.4.0-b34'
guiceVersion = '4.2.2'
jerseyVersion = '2.28'
hk2Version = '2.5.0'
}

// Telling Eclipse about the provided scope
Expand Down Expand Up @@ -103,12 +103,12 @@ subprojects {
}

javadoc {
classpath += [configurations.provided]
options.links('http://docs.oracle.com/javase/7/docs/api/',
classpath.add(configurations.provided)

options.links('http://docs.oracle.com/javase/8/docs/api/',
'http://docs.oracle.com/javaee/7/api/',
'http://google-guice.googlecode.com/git/javadoc/',
'https://hk2.java.net/2.4.0-b32/apidocs/')
'https://javaee.github.io/hk2/')
}

signing {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Wed, 29 Apr 2015 13:52:27 -0400
version=1.0.7
version=1.1.0
12 changes: 9 additions & 3 deletions jersey2-guice-impl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
dependencies {
compile project(':jersey2-guice-spi')

compile 'org.slf4j:slf4j-api:1.7.16'
compile 'org.slf4j:slf4j-api:1.7.25'

compile 'com.google.code.findbugs:jsr305:3.0.1'
compile "com.google.inject.extensions:guice-servlet:${project.guiceVersion}"
Expand All @@ -17,9 +17,15 @@ dependencies {
// Use Guice's javax.inject module
exclude group: 'org.glassfish.hk2.external', module: 'javax.inject'
}

testCompile ("org.glassfish.jersey.inject:jersey-hk2:${project.jerseyVersion}") {
// Use Guice's javax.inject module
exclude group: 'org.glassfish.hk2.external', module: 'javax.inject'
}

provided 'javax.servlet:javax.servlet-api:3.1.0'

testCompile 'org.eclipse.jetty:jetty-servlet:9.2.9.v20150224'
testCompile 'org.eclipse.jetty:jetty-servlet:9.4.14.v20181114'
testCompile 'org.testng:testng:6.9.10'
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public Class<?> getImplementationClass() {
return clazz;
}

@Override
public Type getImplementationType() {
return this.clazz;
}

@Override
public T create(ServiceHandle<?> root) {
return binding.getProvider().get();
Expand Down Expand Up @@ -108,4 +113,4 @@ public boolean containsAll(Collection<?> foreignEntries) {
return true;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,11 @@

package com.squarespace.jersey2.guice;

import static com.squarespace.jersey2.guice.BindingUtils.newGuiceInjectionResolverDescriptor;
import static com.squarespace.jersey2.guice.BindingUtils.newThreeThirtyInjectionResolverDescriptor;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;

import javax.inject.Singleton;

import com.google.inject.Binding;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.spi.ElementSource;
import org.glassfish.hk2.api.ActiveDescriptor;
import org.glassfish.hk2.api.DynamicConfiguration;
import org.glassfish.hk2.api.DynamicConfigurationService;
Expand All @@ -54,11 +42,21 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Binding;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.spi.ElementSource;
import javax.inject.Singleton;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;

import static com.squarespace.jersey2.guice.BindingUtils.newGuiceInjectionResolverDescriptor;
import static com.squarespace.jersey2.guice.BindingUtils.newThreeThirtyInjectionResolverDescriptor;

/**
* An utility class to bootstrap HK2's {@link ServiceLocator}s and {@link Guice}'s {@link Injector}s.
Expand Down Expand Up @@ -163,23 +161,18 @@ private static synchronized boolean isProviderPresent() {
}

private static ServiceLocatorGenerator lookupSPI() {
return AccessController.doPrivileged(new PrivilegedAction<ServiceLocatorGenerator>() {
@Override
public ServiceLocatorGenerator run() {
try {
ClassLoader classLoader = JerseyGuiceUtils.class.getClassLoader();
ServiceLoader<ServiceLocatorGenerator> providers
= ServiceLoader.load(ServiceLocatorGenerator.class, classLoader);

for (ServiceLocatorGenerator generator : providers) {
return generator;
}
} catch (Throwable th) {
LOG.warn("Exception", th);
}

return null;
return AccessController.doPrivileged((PrivilegedAction<ServiceLocatorGenerator>) () -> {
try {
ClassLoader classLoader = JerseyGuiceUtils.class.getClassLoader();
ServiceLoader<ServiceLocatorGenerator> providers
= ServiceLoader.load(ServiceLocatorGenerator.class, classLoader);

return providers.iterator().next();
} catch (Throwable th) {
LOG.warn("Exception", th);
}

return null;
});
}

Expand Down Expand Up @@ -282,7 +275,7 @@ public static ServiceLocator newServiceLocator(String name, ServiceLocator paren
public static ServiceLocator link(ServiceLocator locator, Injector injector) {

Map<Key<?>, Binding<?>> bindings = gatherBindings(injector);
Set<Binder> binders = toBinders(bindings);
Set<GuiceBinder> binders = toBinders(bindings);

return link(locator, injector, binders);
}
Expand All @@ -292,7 +285,7 @@ public static ServiceLocator link(ServiceLocator locator, Injector injector) {
*/
private static Map<Key<?>, Binding<?>> gatherBindings(Injector injector) {

Map<Key<?>, Binding<?>> dst = new HashMap<Key<?>, Binding<?>>();
Map<Key<?>, Binding<?>> dst = new HashMap<>();

Injector current = injector;
while (current != null) {
Expand All @@ -305,10 +298,9 @@ private static Map<Key<?>, Binding<?>> gatherBindings(Injector injector) {

/**
* @see #link(ServiceLocator, Injector)
* @see #newChildInjector(Injector, ServiceLocator)
*/
private static ServiceLocator link(ServiceLocator locator,
Injector injector, Iterable<? extends Binder> binders) {
Injector injector, Iterable<? extends GuiceBinder> binders) {

DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
DynamicConfiguration dc = dcs.createDynamicConfiguration();
Expand All @@ -320,19 +312,28 @@ private static ServiceLocator link(ServiceLocator locator,

bind(locator, dc, new MessagingBinders.HeaderDelegateProviders());

for (Binder binder : binders) {
bind(locator, dc, binder);
for (GuiceBinder binder : binders) {
bind(locator, dc, binder);
}

dc.commit();
return locator;
}


/**
* @see ServiceLocator#inject(Object)
* @see Binder#bind(DynamicConfiguration)
*/
private static void bind(ServiceLocator locator, DynamicConfiguration dc, org.glassfish.hk2.utilities.binding.AbstractBinder binder) {
locator.inject(binder);
binder.bind(dc);
}

/**
* @see ServiceLocator#inject(Object)
* @see Binder#bind(DynamicConfiguration)
*/
private static void bind(ServiceLocator locator, DynamicConfiguration dc, Binder binder) {
private static void bind(ServiceLocator locator, DynamicConfiguration dc, org.glassfish.jersey.internal.inject.AbstractBinder binder) {
locator.inject(binder);
binder.bind(dc);
}
Expand All @@ -341,8 +342,8 @@ private static void bind(ServiceLocator locator, DynamicConfiguration dc, Binder
* Turns the given Guice {@link Binding}s into HK2 {@link Binder}s.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Set<Binder> toBinders(Map<Key<?>, Binding<?>> bindings) {
Set<Binder> binders = new HashSet<>();
private static Set<GuiceBinder> toBinders(Map<Key<?>, Binding<?>> bindings) {
Set<GuiceBinder> binders = new HashSet<>();

for (Map.Entry<Key<?>, Binding<?>> entry : bindings.entrySet()) {
Key<?> key = entry.getKey();
Expand Down
8 changes: 7 additions & 1 deletion jersey2-guice-spi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ dependencies {
compile ("org.glassfish.hk2:hk2-api:${project.hk2Version}") {
transitive = false
}
}
compile ("org.glassfish.hk2:hk2-utils:${project.hk2Version}") {
transitive = false
}
compile ("org.glassfish.hk2:hk2-locator:${project.hk2Version}") {
transitive = false
}
}