com.google.inject.grapher.InjectorGrapher Maven / Gradle / Ivy
/**
* Copyright (C) 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.inject.grapher;
import com.google.inject.Binding;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.internal.util.Sets;
import com.google.inject.spi.BindingTargetVisitor;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import java.util.logging.Logger;
/**
* Root class for graphing an {@link Injector}. Bound in {@link GrapherModule}.
*
* Use {@link #of(Injector)} to specify the {@link Injector} to use, and
* {@link graph()} to graph the {@link Injector} using the currently-bound
* {@link Renderer}.
*
* By default, this will graph the entire {@link Injector}. Use
* {@link #rootedAt(Class...)} or {@link #rootedAt(Key...)} to specify an
* initial set of {@link Class}es or {@link Key}s to use, and this will graph
* their transitive bindings and dependencies.
*
* @author [email protected] (Pete Hopkins)
*/
public class InjectorGrapher {
private static final Key loggerKey = Key.get(Logger.class);
private final BindingTargetVisitor