@SuppressWarnings("unchecked")
    public <T> T getInstance(Key<T> key) {
        // TODO: Combine exception handling with lookupGlobalComponent.
        Object ob = lookupGlobalComponent(key).map(Node::component)
                .orElseThrow(() -> new IllegalStateException(String.format("No global component with key '%s'  ", key)));
        return (T) ob;
    }
@author Tony Vaagenes
@author gjoranv
@author ollivir

Not thread safe.
container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentGraph.java