Skip to content

Commit

Permalink
Do not bind component already binded by the parent
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed Jun 14, 2011
1 parent c59d49c commit 33a0f5a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Expand Up @@ -99,10 +99,14 @@ protected final void configureServlets() {
}

NegotiationTokenGenerator token = injector.getInstance( NegotiationTokenGenerator.class );
bind(NegotiationTokenGenerator.class).toInstance( token );
if (parent == null || parent.getBinding(NegotiationTokenGenerator.class ) == null) {
bind(NegotiationTokenGenerator.class).toInstance( token );
}

ServiceHandlerMapper mapper = injector.getInstance( ServiceHandlerMapper.class );
bind( ServiceHandlerMapper.class ).toInstance( mapper );
ServiceHandlerMapper mapper = injector().getInstance( ServiceHandlerMapper.class );
if (parent == null || parent.getBinding(ServiceHandlerMapper.class ) == null) {
bind( ServiceHandlerMapper.class ).toInstance( mapper );
}

sdSet.addAll( defineServices( injector ) );
ServiceDefinitionGenerator generator = new JAXRSServiceDefinitionGenerator( new ResourceModuleConfig<Module>() {
Expand Down
Expand Up @@ -111,10 +111,14 @@ public void install(Module module) {
});

NegotiationTokenGenerator token = injector.getInstance( NegotiationTokenGenerator.class );
bind(NegotiationTokenGenerator.class).toInstance( token );
if (parent == null || parent.getBinding(NegotiationTokenGenerator.class ) == null) {
bind(NegotiationTokenGenerator.class).toInstance( token );
}

ServiceHandlerMapper mapper = injector().getInstance( ServiceHandlerMapper.class );
bind( ServiceHandlerMapper.class ).toInstance( mapper );
if (parent == null || parent.getBinding(ServiceHandlerMapper.class ) == null) {
bind( ServiceHandlerMapper.class ).toInstance( mapper );
}

if (sdSet != null && sdSet.size() > 0) {
for (ServiceDefinition sd : sdSet) {
Expand Down

0 comments on commit 33a0f5a

Please sign in to comment.