Jersey 2: Replace LocaleProvider

Replace LocaleProvider with LocaleFactory. The semantics are the same except
that Jersey 2 unlike Jersey 1 does not include a native dependency injection
framework; HK2 is the standard dependency injection framework used with Jersey 2.
In this case a class implementing the Factory<Locale> interface is the
replacement of AbstractHttpContextInjectable<Locale> from Jersey 1.

References: https://javaee.github.io/hk2/apidocs/org/glassfish/hk2/api/Factory.html
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/utils/LocaleFactory.java b/core/src/main/java/de/ids_mannheim/korap/web/utils/LocaleFactory.java
new file mode 100644
index 0000000..cb72ba5
--- /dev/null
+++ b/core/src/main/java/de/ids_mannheim/korap/web/utils/LocaleFactory.java
@@ -0,0 +1,25 @@
+package de.ids_mannheim.korap.web.utils;
+
+import org.glassfish.hk2.api.Factory;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.ext.Provider;
+import java.util.List;
+import java.util.Locale;
+
+@Provider
+public class LocaleFactory implements Factory<Locale> {
+    @Context
+    private ContainerRequestContext context;
+
+    @Override
+    public Locale provide() {
+        final List<Locale> locales = context.getAcceptableLanguages();
+        if (locales.isEmpty())
+            return Locale.US;
+        return locales.get(0);
+    }
+
+    @Override
+    public void dispose(Locale instance) {}
+}
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/utils/LocaleProvider.java b/core/src/main/java/de/ids_mannheim/korap/web/utils/LocaleProvider.java
deleted file mode 100644
index cb76260..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/web/utils/LocaleProvider.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package de.ids_mannheim.korap.web.utils;
-
-import com.sun.jersey.api.core.HttpContext;
-import com.sun.jersey.core.spi.component.ComponentContext;
-import com.sun.jersey.core.spi.component.ComponentScope;
-import com.sun.jersey.server.impl.inject.AbstractHttpContextInjectable;
-import com.sun.jersey.spi.inject.Injectable;
-import com.sun.jersey.spi.inject.InjectableProvider;
-
-import javax.ws.rs.core.Context;
-import javax.ws.rs.ext.Provider;
-import java.lang.reflect.Type;
-import java.util.List;
-import java.util.Locale;
-
-/**
- * @author hanl
- * @date 04/02/2014
- */
-@Provider
-public class LocaleProvider extends AbstractHttpContextInjectable<Locale>
-        implements InjectableProvider<Context, Type> {
-
-    @Override
-    public Locale getValue (HttpContext httpContext) {
-        final List<Locale> locales = httpContext.getRequest()
-                .getAcceptableLanguages();
-        if (locales.isEmpty())
-            return Locale.US;
-        return locales.get(0);
-    }
-
-
-    @Override
-    public ComponentScope getScope () {
-        return ComponentScope.PerRequest;
-    }
-
-
-    @Override
-    public Injectable getInjectable (ComponentContext ic, Context context,
-            Type type) {
-        if (type.equals(Locale.class))
-            return this;
-        return null;
-    }
-}