Permalink
Browse files

Make sure both ServiceDefinition and ServiceHandlerMapper are binded

  • Loading branch information...
1 parent 33a0f5a commit a1f846f340e37fbbc3b0464e9d181da94318e0b2 @jfarcand jfarcand committed Jun 14, 2011
@@ -90,21 +90,23 @@ public RestSimpleJaxrsModule( Injector parent, Map<String, String> jaxrsProperti
*/
@Override
protected final void configureServlets() {
+ boolean bindServiceDefinition = true;
if (parent == null) {
injector = Guice.createInjector();
} else if (parent.getBinding( ServiceDefinition.class ) == null) {
injector = parent.createChildInjector();
+ bindServiceDefinition = false;
} else {
injector = parent;
}
NegotiationTokenGenerator token = injector.getInstance( NegotiationTokenGenerator.class );
- if (parent == null || parent.getBinding(NegotiationTokenGenerator.class ) == null) {
+ if (parent == null || bindServiceDefinition || parent.getBinding(NegotiationTokenGenerator.class ) == null) {
bind(NegotiationTokenGenerator.class).toInstance( token );
}
ServiceHandlerMapper mapper = injector().getInstance( ServiceHandlerMapper.class );
- if (parent == null || parent.getBinding(ServiceHandlerMapper.class ) == null) {
+ if (parent == null || bindServiceDefinition || parent.getBinding(ServiceHandlerMapper.class ) == null) {
bind( ServiceHandlerMapper.class ).toInstance( mapper );
}
@@ -78,10 +78,12 @@ public RestSimpleSitebricksModule( ServiceHandlerMapper mapper ) {
@Override
protected final void configureServlets() {
+ boolean bindServiceDefinition = true;
if (parent == null) {
injector = Guice.createInjector();
} else if (parent.getBinding( ServiceDefinition.class ) == null) {
injector = parent.createChildInjector();
+ bindServiceDefinition = false;
} else {
injector = parent;
}
@@ -111,12 +113,12 @@ public void install(Module module) {
});
NegotiationTokenGenerator token = injector.getInstance( NegotiationTokenGenerator.class );
- if (parent == null || parent.getBinding(NegotiationTokenGenerator.class ) == null) {
+ if (parent == null || bindServiceDefinition || parent.getBinding(NegotiationTokenGenerator.class ) == null) {
bind(NegotiationTokenGenerator.class).toInstance( token );
}
ServiceHandlerMapper mapper = injector().getInstance( ServiceHandlerMapper.class );
- if (parent == null || parent.getBinding(ServiceHandlerMapper.class ) == null) {
+ if (parent == null || bindServiceDefinition || parent.getBinding(ServiceHandlerMapper.class ) == null) {
bind( ServiceHandlerMapper.class ).toInstance( mapper );
}

0 comments on commit a1f846f

Please sign in to comment.