Now added support for ProvidedInterfaces in Container.
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Wed, 14 May 2008 12:10:05 +0000 (12:10 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Wed, 14 May 2008 12:10:05 +0000 (12:10 +0000)
As a result. UserAdministrationComponent can be simplified and in general writing composite components becomes easier.

security/src/main/java/org/wamblee/usermgt/UserAdministrationComponent.java

index d1f6a87ab206099fc86d6180e9eeb20600fdee9d..e073442a7c2626d3800d54fccd4d8cbd43ba7416 100644 (file)
@@ -73,34 +73,4 @@ public class UserAdministrationComponent extends DefaultContainer {
         }
         addProvidedInterface(USER_MGT);
     }
-
-    @Override
-    protected Scope doStart(Scope aExternalScope) {
-
-        Scope scope = super.doStart(aExternalScope);
-        if (_exposeInternals) {
-            addInterface(TRANSACTION_MGR, getInterfaceImplementation(
-                    TRANSACTION_MGR, _hibernate, scope), aExternalScope);
-            addInterface(USER_CACHE, getInterfaceImplementation(USER_CACHE,
-                    _repository, scope), aExternalScope);
-            addInterface(HIBERNATE_TEMPLATE, getInterfaceImplementation(
-                    HIBERNATE_TEMPLATE, _hibernate, scope), aExternalScope);
-        }
-        addInterface(USER_MGT, getInterfaceImplementation(USER_MGT, _usermgt,
-                scope), aExternalScope);
-
-        return scope;
-    }
-
-    private Object getInterfaceImplementation(ProvidedInterface aInterface,
-            Component aSource, Scope aScope) {
-        for (ProvidedInterface provided : aSource.getProvidedInterfaces()) {
-            if (provided.equals(aInterface)) {
-                return aScope
-                        .getInterfaceImplementation(provided, Object.class);
-            }
-        }
-        throw new IllegalArgumentException("Provided interface '" + aInterface
-                + "' not found in component '" + aSource + "'");
-    }
 }