Permalink
Browse files

Do not bind component already binded by the parent

  • Loading branch information...
1 parent c59d49c commit 33a0f5ab3a304fdf1dcbc698aa4dffb580f6d36d @jfarcand committed Jun 14, 2011
@@ -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>() {
@@ -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) {

0 comments on commit 33a0f5a

Please sign in to comment.