HubSpot/jersey2-guice

Name: jersey2-guice

Owner: HubSpot

Description: Jersey 2.0 w/ Guice

Forked from: Squarespace/jersey2-guice

Created: 2017-09-05 19:16:53.0

Updated: 2017-09-05 19:16:55.0

Pushed: 2017-12-20 18:43:58.0

Homepage:

Size: 321

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Jersey 2.0 w/ Guice

Continuous Integration

Introduction

This library provides support for Jersey 2.0 w/ Guice similar to the way it used to work in Jersey 1.x with the jersey-guice library. It uses Guice's own GuiceFilter (like jersey-guice) and it's somewhat different from the Guice/HK2 Bridge.

Installation

Go to search.maven.org and search for g:"com.squarespace.jersey2-guice" AND a:"jersey2-guice-impl" to find the current release version.

Gradle
ile "com.squarespace.jersey2-guice:jersey2-guice-impl:${current.version}"
Maven
endency>
roupId>com.squarespace.jersey2-guice</groupId>
rtifactId>jersey2-guice-impl</artifactId>
ersion>${current.version}</version>
pendency>
Usage
Getting Started

Jersey/HK2 uses unfortunately SPIs and the Singleton pattern internally. Your code is effectively racing against the Servlet container's code and the first one to initialize HK2's ServiceLocatorGenerator inside its ServiceLocatorFactory wins.

This library uses two approaches to override HK2's own ServiceLocatorGenerator. It first tries to use a SPI and if it can't it'll fall back to reflection to replace a private static field. Regardless of the approach it's still a race against the Servlet container.

ic static void main(String[] args) {

st<Module> modules = new ArrayList<>();

dules.add(new JerseyGuiceModule("__HK2_Generated_0"));
dules.add(new ServletModule());
dules.add(new AbstractModule() {
@Override
protected void configure() {
  // ...
}
;

jector injector = Guice.createInjector(modules);
rseyGuiceUtils.install(injector);

 ... continue ...

Documentation

The User's Guide can be found in the Wiki.

Apache 2.0 License
Copyright 2014-2016 Squarespace, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.