Renamed ContainerCreationException to CreationException (shorter). Renamed Factory to Locator.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@164 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/src/com/google/inject/Binding.java b/src/com/google/inject/Binding.java
index 0326c92..4836b6b 100644
--- a/src/com/google/inject/Binding.java
+++ b/src/com/google/inject/Binding.java
@@ -19,7 +19,7 @@
import com.google.inject.util.ToStringBuilder;
/**
- * A binding from a {@link Key} (type and name) to an implementation.
+ * A binding from a {@link Key} (type and name) to an instance locator.
*
* @author crazybob@google.com (Bob Lee)
*/
@@ -53,16 +53,16 @@
return source;
}
- volatile Factory<T> factory;
+ volatile Locator<T> locator;
/**
- * Gets the factory which returns instances of {@code T}.
+ * Gets the locator which returns instances of {@code T}.
*/
- public Factory<T> getFactory() {
- if (factory == null) {
- factory = container.getFactory(key);
+ public Locator<T> getLocator() {
+ if (locator == null) {
+ locator = container.getLocator(key);
}
- return factory;
+ return locator;
}
InternalFactory<? extends T> getInternalFactory() {
@@ -85,7 +85,7 @@
return new ToStringBuilder(Binding.class)
.add("key", key)
.add("source", source)
- .add("factory", internalFactory)
+ .add("locator", internalFactory)
.toString();
}
}
\ No newline at end of file
diff --git a/src/com/google/inject/Container.java b/src/com/google/inject/Container.java
index e0de052..87c2d85 100644
--- a/src/com/google/inject/Container.java
+++ b/src/com/google/inject/Container.java
@@ -40,9 +40,9 @@
void injectMembers(Object o);
/**
- * Gets the factory bound to the given key.
+ * Gets the locator bound to the given key.
*/
- <T> Factory<T> getFactory(Key<T> key);
+ <T> Locator<T> getLocator(Key<T> key);
/**
* Gets all bindings.
@@ -60,75 +60,71 @@
<T> List<Binding<T>> findBindingsByType(TypeLiteral<T> type);
/**
- * Gets the factory bound to the given type.
+ * Gets the locator bound to the given type.
*/
- <T> Factory<T> getFactory(Class<T> type);
+ <T> Locator<T> getLocator(Class<T> type);
/**
- * Gets the factory bound to the given type.
+ * Gets the locator bound to the given type.
*/
- <T> Factory<T> getFactory(TypeLiteral<T> type);
+ <T> Locator<T> getLocator(TypeLiteral<T> type);
/**
- * Gets an instance from the factory bound to the given type.
+ * Gets an instance from the locator bound to the given type.
*/
<T> T getInstance(TypeLiteral<T> type);
/**
- * Gets an instance from the factory bound to the given type.
+ * Gets an instance from the locator bound to the given type.
*/
<T> T getInstance(Class<T> type);
/**
- * Gets an instance from the factory bound to the given key.
+ * Gets an instance from the locator bound to the given key.
*/
<T> T getInstance(Key<T> key);
/**
- * Gets an instance from the factory bound to the given type and annotation.
+ * Gets an instance from the locator bound to the given type and annotation.
*/
- <T> T getInstance(TypeLiteral<T> type,
- Annotation annotation);
+ <T> T getInstance(TypeLiteral<T> type, Annotation annotation);
/**
- * Gets an instance from the factory bound to the given type and annotation.
+ * Gets an instance from the locator bound to the given type and annotation.
*/
- <T> T getInstance(Class<T> type,
- Annotation annotation);
+ <T> T getInstance(Class<T> type, Annotation annotation);
/**
- * Gets the factory bound to the given type and annotation.
+ * Gets the locator bound to the given type and annotation.
*/
- <T> Factory<T> getFactory(Class<T> type,
- Annotation annotation);
+ <T> Locator<T> getLocator(Class<T> type, Annotation annotation);
/**
- * Gets the factory bound to the given type and annotation.
+ * Gets the locator bound to the given type and annotation.
*/
- <T> Factory<T> getFactory(TypeLiteral<T> type,
- Annotation annotation);
+ <T> Locator<T> getLocator(TypeLiteral<T> type, Annotation annotation);
/**
- * Gets an instance from the factory bound to the given type and annotation.
+ * Gets an instance from the locator bound to the given type and annotation.
*/
<T> T getInstance(TypeLiteral<T> type,
Class<? extends Annotation> annotationType);
/**
- * Gets an instance from the factory bound to the given type and annotation.
+ * Gets an instance from the locator bound to the given type and annotation.
*/
<T> T getInstance(Class<T> type,
Class<? extends Annotation> annotationType);
/**
- * Gets the factory bound to the given type and annotation.
+ * Gets the locator bound to the given type and annotation.
*/
- <T> Factory<T> getFactory(Class<T> type,
+ <T> Locator<T> getLocator(Class<T> type,
Class<? extends Annotation> annotationType);
/**
- * Gets the factory bound to the given type and annotation.
+ * Gets the locator bound to the given type and annotation.
*/
- <T> Factory<T> getFactory(TypeLiteral<T> type,
+ <T> Locator<T> getLocator(TypeLiteral<T> type,
Class<? extends Annotation> annotationType);
}
diff --git a/src/com/google/inject/ContainerBuilder.java b/src/com/google/inject/ContainerBuilder.java
index dd37ae3..21a59b1 100644
--- a/src/com/google/inject/ContainerBuilder.java
+++ b/src/com/google/inject/ContainerBuilder.java
@@ -43,7 +43,7 @@
* <p>Creates several bindings by default:
*
* <ul>
- * <li>A {@code Factory<T>} for each binding of type {@code T}
+ * <li>A {@code Locator<T>} for each binding of type {@code T}
* <li>The {@link Container} iself
* <li>The {@link Logger} for the class being injected
* <li>The {@link Stage} passed to the builder's constructor
@@ -84,7 +84,7 @@
}
public String toString() {
- return "ContainerFactory";
+ return "Locator<Container>";
}
};
@@ -98,7 +98,7 @@
}
public String toString() {
- return "LoggerFactory";
+ return "Locator<Logger>";
}
};
@@ -288,12 +288,12 @@
* Creates a {@link Container} instance. Injects static members for classes
* which were registered using {@link #requestStaticInjection(Class...)}.
*
- * @throws ContainerCreationException if configuration errors are found. The
+ * @throws CreationException if configuration errors are found. The
* expectation is that the application will log this exception and exit.
* @throws IllegalStateException if called more than once
*/
public synchronized Container create()
- throws ContainerCreationException {
+ throws CreationException {
stopwatch.resetAndLog(logger, "Configuration");
// Create the container.
@@ -331,7 +331,7 @@
// Blow up if we encountered errors.
if (!errorMessages.isEmpty()) {
- throw new ContainerCreationException(errorMessages);
+ throw new CreationException(errorMessages);
}
// Switch to runtime error handling.
@@ -451,9 +451,9 @@
Map<Key<?>, Binding<?>> bindings = container.internalBindings();
Binding<?> original = bindings.get(key);
- // Binding to Factory<?> is not allowed.
- if (key.getRawType().equals(Factory.class)) {
- addError(binding.getSource(), ErrorMessages.CANNOT_BIND_TO_FACTORY);
+ // Binding to Locator<?> is not allowed.
+ if (key.getRawType().equals(Locator.class)) {
+ addError(binding.getSource(), ErrorMessages.CANNOT_BIND_TO_LOCATOR);
return;
}
@@ -555,18 +555,9 @@
ensureImplementationIsNotSet();
this.implementation = implementation;
final DefaultFactory<I> defaultFactory
- = new DefaultFactory<I>(key, implementation);
+ = new DefaultFactory<I>(key, implementation, errorHandler);
this.factory = defaultFactory;
- creationListeners.add(new CreationListener() {
- public void notify(final ContainerImpl container) {
- container.withErrorHandler(errorHandler, new Runnable() {
- public void run() {
- defaultFactory.setConstructor(
- container.getConstructor(implementation));
- }
- });
- }
- });
+ creationListeners.add(defaultFactory);
return this;
}
@@ -625,10 +616,10 @@
final Key<? extends Generator<T>> generatorKey) {
ensureImplementationIsNotSet();
- final BoundGenerator<T> delegatingFactory =
+ final BoundGenerator<T> boundGenerator =
new BoundGenerator<T>(generatorKey, errorHandler);
- creationListeners.add(delegatingFactory);
- this.factory = delegatingFactory;
+ creationListeners.add(boundGenerator);
+ this.factory = boundGenerator;
return this;
}
@@ -763,20 +754,28 @@
/**
* Injects new instances of the specified implementation class.
*/
- private static class DefaultFactory<T> implements InternalFactory<T> {
+ private static class DefaultFactory<T> implements InternalFactory<T>,
+ CreationListener {
private final TypeLiteral<T> implementation;
private final Key<? super T> key;
+ private final ErrorHandler errorHandler;
ConstructorInjector<T> constructor;
- DefaultFactory(Key<? super T> key, TypeLiteral<T> implementation) {
+ DefaultFactory(Key<? super T> key, TypeLiteral<T> implementation,
+ ErrorHandler errorHandler) {
this.key = key;
this.implementation = implementation;
+ this.errorHandler = errorHandler;
}
- void setConstructor(ConstructorInjector<T> constructor) {
- this.constructor = constructor;
+ public void notify(final ContainerImpl container) {
+ container.withErrorHandler(errorHandler, new Runnable() {
+ public void run() {
+ constructor = container.getConstructor(implementation);
+ }
+ });
}
public T get(InternalContext context) {
@@ -785,7 +784,7 @@
}
public String toString() {
- return new ToStringBuilder(Factory.class)
+ return new ToStringBuilder(Locator.class)
.add("implementation", implementation)
.toString();
}
diff --git a/src/com/google/inject/ContainerImpl.java b/src/com/google/inject/ContainerImpl.java
index 477beb3..3fffc3e 100644
--- a/src/com/google/inject/ContainerImpl.java
+++ b/src/com/google/inject/ContainerImpl.java
@@ -158,20 +158,20 @@
Class<? super T> rawType = key.getType().getRawType();
// Handle cases where T is a Factory<?>.
- if (rawType.equals(Factory.class)) {
- Type factoryType = key.getType().getType();
- if (!(factoryType instanceof ParameterizedType)) {
+ if (rawType.equals(Locator.class)) {
+ Type locatorType = key.getType().getType();
+ if (!(locatorType instanceof ParameterizedType)) {
return null;
}
Type entryType
- = ((ParameterizedType) factoryType).getActualTypeArguments()[0];
+ = ((ParameterizedType) locatorType).getActualTypeArguments()[0];
try {
- final Factory<?> factory = getFactory(key.ofType(entryType));
+ final Locator<?> locator = getLocator(key.ofType(entryType));
return new InternalFactory<T>() {
@SuppressWarnings("unchecked")
public T get(InternalContext context) {
- return (T) factory;
+ return (T) locator;
}
};
}
@@ -612,65 +612,65 @@
public <T> T getInstance(TypeLiteral<T> type,
Annotation annotation) {
- return getFactory(Key.get(type, annotation)).get();
+ return getLocator(Key.get(type, annotation)).get();
}
public <T> T getInstance(Class<T> type,
Annotation annotation) {
- return getFactory(Key.get(type, annotation)).get();
+ return getLocator(Key.get(type, annotation)).get();
}
- public <T> Factory<T> getFactory(Class<T> type,
+ public <T> Locator<T> getLocator(Class<T> type,
Annotation annotation) {
- return getFactory(Key.get(type, annotation));
+ return getLocator(Key.get(type, annotation));
}
- public <T> Factory<T> getFactory(TypeLiteral<T> type,
+ public <T> Locator<T> getLocator(TypeLiteral<T> type,
Annotation annotation) {
- return getFactory(Key.get(type, annotation));
+ return getLocator(Key.get(type, annotation));
}
public <T> T getInstance(TypeLiteral<T> type,
Class<? extends Annotation> annotationType) {
- return getFactory(Key.get(type, annotationType)).get();
+ return getLocator(Key.get(type, annotationType)).get();
}
public <T> T getInstance(Class<T> type,
Class<? extends Annotation> annotationType) {
- return getFactory(Key.get(type, annotationType)).get();
+ return getLocator(Key.get(type, annotationType)).get();
}
- public <T> Factory<T> getFactory(Class<T> type,
+ public <T> Locator<T> getLocator(Class<T> type,
Class<? extends Annotation> annotationType) {
- return getFactory(Key.get(type, annotationType));
+ return getLocator(Key.get(type, annotationType));
}
- public <T> Factory<T> getFactory(TypeLiteral<T> type,
+ public <T> Locator<T> getLocator(TypeLiteral<T> type,
Class<? extends Annotation> annotationType) {
- return getFactory(Key.get(type, annotationType));
+ return getLocator(Key.get(type, annotationType));
}
public <T> T getInstance(TypeLiteral<T> type) {
- return getFactory(Key.get(type)).get();
+ return getLocator(Key.get(type)).get();
}
public <T> T getInstance(Class<T> type) {
- return getFactory(Key.get(type)).get();
+ return getLocator(Key.get(type)).get();
}
public <T> T getInstance(Key<T> key) {
- return getFactory(key).get();
+ return getLocator(key).get();
}
- public <T> Factory<T> getFactory(Class<T> type) {
- return getFactory(Key.get(type));
+ public <T> Locator<T> getLocator(Class<T> type) {
+ return getLocator(Key.get(type));
}
- public <T> Factory<T> getFactory(TypeLiteral<T> type) {
- return getFactory(Key.get(type));
+ public <T> Locator<T> getLocator(TypeLiteral<T> type) {
+ return getLocator(Key.get(type));
}
- public <T> Factory<T> getFactory(final Key<T> key) {
+ public <T> Locator<T> getLocator(final Key<T> key) {
final InternalFactory<? extends T> factory = getInternalFactory(null, key);
if (factory == null) {
@@ -678,7 +678,7 @@
"Missing binding to " + ErrorMessages.convert(key) + ".");
}
- return new Factory<T>() {
+ return new Locator<T>() {
public T get() {
return callInContext(new ContextualCallable<T>() {
public T call(InternalContext context) {
diff --git a/src/com/google/inject/Context.java b/src/com/google/inject/Context.java
index 52265cf..c4a83e2 100644
--- a/src/com/google/inject/Context.java
+++ b/src/com/google/inject/Context.java
@@ -33,7 +33,7 @@
/**
* Gets the field, method or constructor which is being injected. Returns
* {@code null} if the object isn't being injected into anywhere (i.e. it's
- * preloaded, returned from {@link Factory#get()}, etc.).
+ * preloaded, returned from {@link Locator#get()}, etc.).
*/
Member getMember();
diff --git a/src/com/google/inject/ContainerCreationException.java b/src/com/google/inject/CreationException.java
similarity index 94%
rename from src/com/google/inject/ContainerCreationException.java
rename to src/com/google/inject/CreationException.java
index fd9c42b..c7a443b 100644
--- a/src/com/google/inject/ContainerCreationException.java
+++ b/src/com/google/inject/CreationException.java
@@ -31,14 +31,14 @@
*
* @author crazybob@google.com (Bob Lee)
*/
-public class ContainerCreationException extends Exception {
+public class CreationException extends Exception {
final List<Message> errorMessages;
/**
* Constructs a new exception for the given errors.
*/
- public ContainerCreationException(Collection<Message> errorMessages) {
+ public CreationException(Collection<Message> errorMessages) {
super();
// Sort the messages by source.
diff --git a/src/com/google/inject/ErrorMessages.java b/src/com/google/inject/ErrorMessages.java
index 5905112..7f536f9 100644
--- a/src/com/google/inject/ErrorMessages.java
+++ b/src/com/google/inject/ErrorMessages.java
@@ -50,7 +50,7 @@
}
}
- static final String CANNOT_BIND_TO_FACTORY = "Binding to Factory<?> is not"
+ static final String CANNOT_BIND_TO_LOCATOR = "Binding to Locator<?> is not"
+ " allowed.";
static final String SCOPE_NOT_FOUND = "No scope is bound to %s.";
diff --git a/src/com/google/inject/InternalFactoryToFactoryAdapter.java b/src/com/google/inject/InternalFactoryToLocatorAdapter.java
similarity index 74%
rename from src/com/google/inject/InternalFactoryToFactoryAdapter.java
rename to src/com/google/inject/InternalFactoryToLocatorAdapter.java
index 9abae5f..a4707d6 100644
--- a/src/com/google/inject/InternalFactoryToFactoryAdapter.java
+++ b/src/com/google/inject/InternalFactoryToLocatorAdapter.java
@@ -19,19 +19,19 @@
/**
* @author crazybob@google.com (Bob Lee)
*/
-class InternalFactoryToFactoryAdapter<T> implements InternalFactory<T> {
+class InternalFactoryToLocatorAdapter<T> implements InternalFactory<T> {
- private final Factory<? extends T> factory;
+ private final Locator<? extends T> locator;
- public InternalFactoryToFactoryAdapter(Factory<? extends T> factory) {
- this.factory = factory;
+ public InternalFactoryToLocatorAdapter(Locator<? extends T> locator) {
+ this.locator = locator;
}
public T get(InternalContext context) {
- return factory.get();
+ return locator.get();
}
public String toString() {
- return factory.toString();
+ return locator.toString();
}
}
diff --git a/src/com/google/inject/Factory.java b/src/com/google/inject/Locator.java
similarity index 86%
rename from src/com/google/inject/Factory.java
rename to src/com/google/inject/Locator.java
index 23666d2..2db9605 100644
--- a/src/com/google/inject/Factory.java
+++ b/src/com/google/inject/Locator.java
@@ -17,14 +17,14 @@
package com.google.inject;
/**
- * Gets instances of {@code T}.
+ * Locates bound instances of {@code T}.
*
* @author crazybob@google.com (Bob Lee)
*/
-public interface Factory<T> {
+public interface Locator<T> {
/**
- * Gets an instance of {@code T}.
+ * Locates an instance of {@code T}.
*/
T get();
}
diff --git a/src/com/google/inject/FactoryToInternalFactoryAdapter.java b/src/com/google/inject/LocatorToInternalFactoryAdapter.java
similarity index 90%
rename from src/com/google/inject/FactoryToInternalFactoryAdapter.java
rename to src/com/google/inject/LocatorToInternalFactoryAdapter.java
index 6f4149c..2eb5078 100644
--- a/src/com/google/inject/FactoryToInternalFactoryAdapter.java
+++ b/src/com/google/inject/LocatorToInternalFactoryAdapter.java
@@ -19,13 +19,13 @@
/**
* @author crazybob@google.com (Bob Lee)
*/
-class FactoryToInternalFactoryAdapter<T> implements Factory<T> {
+class LocatorToInternalFactoryAdapter<T> implements Locator<T> {
private final ContainerImpl container;
private final InternalFactory<? extends T> internalFactory;
- public FactoryToInternalFactoryAdapter(ContainerImpl container,
+ public LocatorToInternalFactoryAdapter(ContainerImpl container,
InternalFactory<? extends T> internalFactory) {
this.container = container;
this.internalFactory = internalFactory;
diff --git a/src/com/google/inject/ProxyFactory.java b/src/com/google/inject/ProxyFactory.java
index 7dfea56..7fdb060 100644
--- a/src/com/google/inject/ProxyFactory.java
+++ b/src/com/google/inject/ProxyFactory.java
@@ -62,10 +62,10 @@
* exceptions in {@link RuntimeException} including
* {@link InvocationTargetException}.
*/
- public <T> Factory<T> getFactory(Class<T> type) throws NoSuchMethodException {
+ public <T> Locator<T> getFactory(Class<T> type) throws NoSuchMethodException {
final ConstructionProxy<T> constructionProxy
= createConstructionProxy(type.getDeclaredConstructor());
- return new Factory<T>() {
+ return new Locator<T>() {
public T get() {
try {
return constructionProxy.newInstance();
diff --git a/src/com/google/inject/Scope.java b/src/com/google/inject/Scope.java
index 2dece30..37a7130 100644
--- a/src/com/google/inject/Scope.java
+++ b/src/com/google/inject/Scope.java
@@ -17,11 +17,11 @@
package com.google.inject;
/**
- * A scope which bound objects can reside in.
+ * A scope which bound objects can reside in. Scopes a given {@link Locator}.
*
* <p>Scope implementations should override {@code toString()} in the returned
- * factory and include the creator's {@code toString()} output. Doing so aids
- * debugging. They should also override their own {@code toString()}
+ * locator and include the unscoped locator's {@code toString()} output. Doing
+ * so aids debugging. They should also override their own {@code toString()}
* method.
*
* @author crazybob@google.com (Bob Lee)
@@ -29,14 +29,16 @@
public interface Scope {
/**
- * Scopes a factory. The returned factory returns objects from this scope. If
- * an object does not exist in this scope, the factory can use the given
- * creator to create one.
+ * Scopes a locator. The returned locator returns objects from this scope. If
+ * an object does not exist in this scope, the locator can use the given
+ * unscoped locator to retrieve one.
*
* @param key binding key
- * @param creator creates new instances as needed
- * @return a new factory which only delegates to the given factory when an
- * instance of the requested object doesn't already exist in the scope
+ * @param unscoped locates an instance when one doesn't already exist in this
+ * scope.
+ * @return a new locator which only delegates to the given unscoped locator
+ * when an instance of the requested object doesn't already exist in this
+ * scope
*/
- public <T> Factory<T> scope(Key<T> key, Factory<T> creator);
+ public <T> Locator<T> scope(Key<T> key, Locator<T> unscoped);
}
diff --git a/src/com/google/inject/Scopes.java b/src/com/google/inject/Scopes.java
index ff3d068..755e9d9 100644
--- a/src/com/google/inject/Scopes.java
+++ b/src/com/google/inject/Scopes.java
@@ -32,7 +32,7 @@
* The default scope, one instance per injection.
*/
public static final Scope DEFAULT = new Scope() {
- public <T> Factory<T> scope(Key<T> key, Factory<T> creator) {
+ public <T> Locator<T> scope(Key<T> key, Locator<T> creator) {
return creator;
}
@@ -45,8 +45,8 @@
* One instance per container. Also see {@code @}{@link ContainerScoped}.
*/
public static final Scope CONTAINER = new Scope() {
- public <T> Factory<T> scope(Key<T> key, final Factory<T> creator) {
- return new Factory<T>() {
+ public <T> Locator<T> scope(Key<T> key, final Locator<T> creator) {
+ return new Locator<T>() {
private volatile T instance;
@@ -116,8 +116,8 @@
if (scope == null || scope == DEFAULT) {
return creator;
}
- Factory<T> scoped = scope.scope(key,
- new FactoryToInternalFactoryAdapter<T>(container, creator));
- return new InternalFactoryToFactoryAdapter<T>(scoped);
+ Locator<T> scoped = scope.scope(key,
+ new LocatorToInternalFactoryAdapter<T>(container, creator));
+ return new InternalFactoryToLocatorAdapter<T>(scoped);
}
}
diff --git a/src/com/google/inject/package-info.java b/src/com/google/inject/package-info.java
index 198cfda..8750d8a 100644
--- a/src/com/google/inject/package-info.java
+++ b/src/com/google/inject/package-info.java
@@ -38,12 +38,10 @@
* <dd>The object that Guice passes into your {@link com.google.inject.Module}
* to collect these bindings.
*
- * <dt>{@link com.google.inject.Factory} and
- * {@link com.google.inject.Generator}
+ * <dt>{@link com.google.inject.Generator}
* <dd>The interface you will implement when you need to customize exactly how
- * Guice creates instances for a particular binding. These differ only in
- * whether a {@link com.google.inject.Context} is made available to the
- * factory.
+ * Guice creates instances for a particular binding.
+ *
* <dt>{@link com.google.inject.Container}
* <dd>An object which creates and manages all the instances that make
* up your application. It is created by a
diff --git a/src/com/google/inject/servlet/ServletModule.java b/src/com/google/inject/servlet/ServletModule.java
index 8bf734e..63df37b 100644
--- a/src/com/google/inject/servlet/ServletModule.java
+++ b/src/com/google/inject/servlet/ServletModule.java
@@ -17,7 +17,6 @@
package com.google.inject.servlet;
import com.google.inject.AbstractModule;
-import com.google.inject.Factory;
import com.google.inject.TypeLiteral;
import com.google.inject.Generator;
import com.google.inject.Context;
diff --git a/src/com/google/inject/servlet/ServletScopes.java b/src/com/google/inject/servlet/ServletScopes.java
index 1dfa780..aa07da8 100644
--- a/src/com/google/inject/servlet/ServletScopes.java
+++ b/src/com/google/inject/servlet/ServletScopes.java
@@ -17,7 +17,7 @@
package com.google.inject.servlet;
import com.google.inject.Scope;
-import com.google.inject.Factory;
+import com.google.inject.Locator;
import com.google.inject.Key;
import javax.servlet.http.HttpServletRequest;
@@ -36,9 +36,9 @@
* HTTP servlet request scope.
*/
public static final Scope REQUEST = new Scope() {
- public <T> Factory<T> scope(Key<T> key, final Factory<T> creator) {
+ public <T> Locator<T> scope(Key<T> key, final Locator<T> creator) {
final String name = key.toString();
- return new Factory<T>() {
+ return new Locator<T>() {
public T get() {
HttpServletRequest request = GuiceFilter.getRequest();
synchronized (request) {
@@ -63,9 +63,9 @@
* HTTP session scope.
*/
public static final Scope SESSION = new Scope() {
- public <T> Factory<T> scope(Key<T> key, final Factory<T> creator) {
+ public <T> Locator<T> scope(Key<T> key, final Locator<T> creator) {
final String name = key.toString();
- return new Factory<T>() {
+ return new Locator<T>() {
public T get() {
HttpSession session = GuiceFilter.getRequest().getSession();
synchronized (session) {
diff --git a/src/com/google/inject/tools/jmx/ManagedBinding.java b/src/com/google/inject/tools/jmx/ManagedBinding.java
index f25da83..ffa0896 100644
--- a/src/com/google/inject/tools/jmx/ManagedBinding.java
+++ b/src/com/google/inject/tools/jmx/ManagedBinding.java
@@ -34,7 +34,7 @@
return binding.getKey().toString();
}
- public String getFactory() {
- return binding.getFactory().toString();
+ public String getLocator() {
+ return binding.getLocator().toString();
}
}
diff --git a/src/com/google/inject/tools/jmx/ManagedBindingMBean.java b/src/com/google/inject/tools/jmx/ManagedBindingMBean.java
index 229cd2b..4b187d7 100644
--- a/src/com/google/inject/tools/jmx/ManagedBindingMBean.java
+++ b/src/com/google/inject/tools/jmx/ManagedBindingMBean.java
@@ -29,9 +29,9 @@
String getSource();
/**
- * Gets the factory to which this binding is bound.
+ * Gets the locator to which this binding is bound.
*/
- String getFactory();
+ String getLocator();
/**
* Gets the binding key.
diff --git a/test/com/google/inject/AllTests.java b/test/com/google/inject/AllTests.java
index c97fc7b..be10283 100644
--- a/test/com/google/inject/AllTests.java
+++ b/test/com/google/inject/AllTests.java
@@ -42,14 +42,14 @@
suite.addTestSuite(CircularDependencyTest.class);
suite.addTestSuite(StaticInjectionTest.class);
suite.addTestSuite(NotRequiredTest.class);
- suite.addTestSuite(FactoryTest.class);
+ suite.addTestSuite(GeneratorTest.class);
suite.addTestSuite(SuperclassTest.class);
- suite.addTestSuite(FactoryInjectionTest.class);
+ suite.addTestSuite(LocatorInjectionTest.class);
suite.addTestSuite(PreloadingTest.class);
suite.addTestSuite(ReflectionTest.class);
suite.addTestSuite(ScopesTest.class);
suite.addTestSuite(ImplicitBindingTest.class);
- suite.addTestSuite(GeneratorTest.class);
+ suite.addTestSuite(BoundGeneratorTest.class);
suite.addTestSuite(MatcherTest.class);
suite.addTestSuite(ProxyFactoryTest.class);
diff --git a/test/com/google/inject/GeneratorTest.java b/test/com/google/inject/BoundGeneratorTest.java
similarity index 94%
rename from test/com/google/inject/GeneratorTest.java
rename to test/com/google/inject/BoundGeneratorTest.java
index d0b4b09..8a67e43 100644
--- a/test/com/google/inject/GeneratorTest.java
+++ b/test/com/google/inject/BoundGeneratorTest.java
@@ -21,9 +21,9 @@
/**
* @author crazybob@google.com (Bob Lee)
*/
-public class GeneratorTest extends TestCase {
+public class BoundGeneratorTest extends TestCase {
- public void testFooGenerator() throws ContainerCreationException {
+ public void testFooGenerator() throws CreationException {
ContainerBuilder cb = new ContainerBuilder();
cb.bind(Foo.class).toGenerator(FooGenerator.class);
Container c = cb.create();
@@ -39,7 +39,7 @@
}
public void testContainerScopedFooGenerator()
- throws ContainerCreationException {
+ throws CreationException {
ContainerBuilder cb = new ContainerBuilder();
cb.bind(Foo.class).toGenerator(ContainerScopedFooGenerator.class);
Container c = cb.create();
diff --git a/test/com/google/inject/CircularDependencyTest.java b/test/com/google/inject/CircularDependencyTest.java
index 6ae306b..33952f5 100644
--- a/test/com/google/inject/CircularDependencyTest.java
+++ b/test/com/google/inject/CircularDependencyTest.java
@@ -24,13 +24,13 @@
public class CircularDependencyTest extends TestCase {
public void testCircularlyDependentConstructors()
- throws ContainerCreationException {
+ throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
builder.bind(A.class).to(AImpl.class);
builder.bind(B.class).to(BImpl.class);
Container container = builder.create();
- A a = container.getFactory(AImpl.class).get();
+ A a = container.getLocator(AImpl.class).get();
assertNotNull(a.getB().getA());
}
diff --git a/test/com/google/inject/ConstantConversionTest.java b/test/com/google/inject/ConstantConversionTest.java
index a610e79..7506ed5 100644
--- a/test/com/google/inject/ConstantConversionTest.java
+++ b/test/com/google/inject/ConstantConversionTest.java
@@ -61,12 +61,12 @@
TEE, BAZ, BOB;
}
- public void testOneConstantInjection() throws ContainerCreationException {
+ public void testOneConstantInjection() throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
builder.bindConstant(NumericValue.class).to("5");
builder.bind(Simple.class);
Container container = builder.create();
- Simple simple = container.getFactory(Simple.class).get();
+ Simple simple = container.getLocator(Simple.class).get();
assertEquals(5, simple.i);
}
@@ -74,14 +74,14 @@
@Inject @NumericValue int i;
}
- public void testConstantInjection() throws ContainerCreationException {
+ public void testConstantInjection() throws CreationException {
ContainerBuilder b = new ContainerBuilder();
b.bindConstant(NumericValue.class).to("5");
b.bindConstant(BooleanValue.class).to("true");
b.bindConstant(EnumValue.class).to("TEE");
b.bindConstant(ClassName.class).to(Foo.class.getName());
Container c = b.create();
- Foo foo = c.getFactory(Foo.class).get();
+ Foo foo = c.getLocator(Foo.class).get();
checkNumbers(
foo.integerField,
@@ -108,12 +108,12 @@
}
}
- public void testInvalidInteger() throws ContainerCreationException {
+ public void testInvalidInteger() throws CreationException {
ContainerBuilder b = new ContainerBuilder();
b.bindConstant(NumericValue.class).to("invalid");
Container c = b.create();
try {
- c.getFactory(InvalidInteger.class).get();
+ c.getLocator(InvalidInteger.class).get();
fail();
} catch (ConfigurationException e) { /* expected */ }
}
@@ -122,12 +122,12 @@
@Inject @NumericValue Integer integerField;
}
- public void testInvalidCharacter() throws ContainerCreationException {
+ public void testInvalidCharacter() throws CreationException {
ContainerBuilder b = new ContainerBuilder();
b.bindConstant(NumericValue.class).to("invalid");
Container c = b.create();
try {
- c.getFactory(InvalidCharacter.class).get();
+ c.getLocator(InvalidCharacter.class).get();
fail();
} catch (ConfigurationException e) { /* expected */ }
}
@@ -136,12 +136,12 @@
@Inject @NumericValue char foo;
}
- public void testInvalidEnum() throws ContainerCreationException {
+ public void testInvalidEnum() throws CreationException {
ContainerBuilder b = new ContainerBuilder();
b.bindConstant(NumericValue.class).to("invalid");
Container c = b.create();
try {
- c.getFactory(InvalidEnum.class).get();
+ c.getLocator(InvalidEnum.class).get();
fail();
} catch (ConfigurationException e) { /* expected */ }
}
diff --git a/test/com/google/inject/ContainerTest.java b/test/com/google/inject/ContainerTest.java
index b181be6..24eeb63 100644
--- a/test/com/google/inject/ContainerTest.java
+++ b/test/com/google/inject/ContainerTest.java
@@ -34,7 +34,7 @@
@Retention(RUNTIME)
@Binder @interface I {}
- public void testFactoryMethods() throws ContainerCreationException {
+ public void testLocatorMethods() throws CreationException {
Singleton singleton = new Singleton();
Singleton other = new Singleton();
@@ -46,20 +46,20 @@
Container container = builder.create();
assertSame(singleton,
- container.getFactory(Key.get(Singleton.class)).get());
- assertSame(singleton, container.getFactory(Singleton.class).get());
+ container.getLocator(Key.get(Singleton.class)).get());
+ assertSame(singleton, container.getLocator(Singleton.class).get());
assertSame(singleton,
- container.getFactory(new TypeLiteral<Singleton>() {}).get());
+ container.getLocator(new TypeLiteral<Singleton>() {}).get());
assertSame(singleton, container.getInstance(Key.get(Singleton.class)));
assertSame(singleton, container.getInstance(Singleton.class));
assertSame(singleton,
container.getInstance(new TypeLiteral<Singleton>() {}));
assertSame(other,
- container.getFactory(Key.get(Singleton.class, Other.class)).get());
- assertSame(other, container.getFactory(Singleton.class, Other.class).get());
+ container.getLocator(Key.get(Singleton.class, Other.class)).get());
+ assertSame(other, container.getLocator(Singleton.class, Other.class).get());
assertSame(other,
- container.getFactory(new TypeLiteral<Singleton>() {}, Other.class).get());
+ container.getLocator(new TypeLiteral<Singleton>() {}, Other.class).get());
assertSame(other, container.getInstance(Key.get(Singleton.class, Other.class)));
assertSame(other, container.getInstance(Singleton.class, Other.class));
assertSame(other,
@@ -68,9 +68,9 @@
static class Singleton {}
- public void testInjection() throws ContainerCreationException {
+ public void testInjection() throws CreationException {
Container container = createFooContainer();
- Foo foo = container.getFactory(Foo.class).get();
+ Foo foo = container.getLocator(Foo.class).get();
assertEquals("test", foo.s);
assertEquals("test", foo.bar.getTee().getS());
@@ -82,7 +82,7 @@
assertSame(foo.bar, foo.bar.getTee().getBar());
}
- private Container createFooContainer() throws ContainerCreationException {
+ private Container createFooContainer() throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
builder.install(new AbstractModule() {
@@ -97,20 +97,20 @@
return builder.create();
}
- public void testGetInstance() throws ContainerCreationException {
+ public void testGetInstance() throws CreationException {
Container container = createFooContainer();
- Bar bar = container.getFactory(Key.get(Bar.class)).get();
+ Bar bar = container.getLocator(Key.get(Bar.class)).get();
assertEquals("test", bar.getTee().getS());
assertEquals(5, bar.getI());
}
public void testIntAndIntegerAreInterchangeable()
- throws ContainerCreationException {
+ throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
builder.bindConstant(I.class).to(5);
Container container = builder.create();
- IntegerWrapper iw = container.getFactory(IntegerWrapper.class).get();
+ IntegerWrapper iw = container.getLocator(IntegerWrapper.class).get();
assertEquals(5, (int) iw.i);
}
@@ -186,13 +186,13 @@
}
public void testCircularlyDependentConstructors()
- throws ContainerCreationException {
+ throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
builder.bind(A.class).to(AImpl.class);
builder.bind(B.class).to(BImpl.class);
Container container = builder.create();
- A a = container.getFactory(AImpl.class).get();
+ A a = container.getLocator(AImpl.class).get();
assertNotNull(a.getB().getA());
}
@@ -225,7 +225,7 @@
}
}
- public void testInjectStatics() throws ContainerCreationException {
+ public void testInjectStatics() throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
builder.bindConstant(S.class).to("test");
builder.bindConstant(I.class).to(5);
diff --git a/test/com/google/inject/ErrorHandlingTest.java b/test/com/google/inject/ErrorHandlingTest.java
index fda482f..432e1ed 100644
--- a/test/com/google/inject/ErrorHandlingTest.java
+++ b/test/com/google/inject/ErrorHandlingTest.java
@@ -25,7 +25,7 @@
*/
public class ErrorHandlingTest {
- public static void main(String[] args) throws ContainerCreationException {
+ public static void main(String[] args) throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
builder.install(new MyModule());
builder.create();
diff --git a/test/com/google/inject/FactoryTest.java b/test/com/google/inject/GeneratorTesy.java
similarity index 100%
rename from test/com/google/inject/FactoryTest.java
rename to test/com/google/inject/GeneratorTesy.java
diff --git a/test/com/google/inject/GenericInjectionTest.java b/test/com/google/inject/GenericInjectionTest.java
index 1f8c9bb..08d069b 100644
--- a/test/com/google/inject/GenericInjectionTest.java
+++ b/test/com/google/inject/GenericInjectionTest.java
@@ -26,12 +26,12 @@
*/
public class GenericInjectionTest extends TestCase {
- public void testGenericInjection() throws ContainerCreationException {
+ public void testGenericInjection() throws CreationException {
List<String> names = Arrays.asList("foo", "bar", "bob");
ContainerBuilder builder = new ContainerBuilder();
builder.bind(new TypeLiteral<List<String>>() {}).to(names);
Container container = builder.create();
- Foo foo = container.getFactory(Foo.class).get();
+ Foo foo = container.getLocator(Foo.class).get();
assertEquals(names, foo.names);
}
diff --git a/test/com/google/inject/ImplicitBindingTest.java b/test/com/google/inject/ImplicitBindingTest.java
index 7d4d33b..326a1e0 100644
--- a/test/com/google/inject/ImplicitBindingTest.java
+++ b/test/com/google/inject/ImplicitBindingTest.java
@@ -23,7 +23,7 @@
*/
public class ImplicitBindingTest extends TestCase {
- public void testCircularDependency() throws ContainerCreationException {
+ public void testCircularDependency() throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
Container container = builder.create();
Foo foo = container.getInstance(Foo.class);
diff --git a/test/com/google/inject/IntegrationTest.java b/test/com/google/inject/IntegrationTest.java
index 7201dcb..ed785f3 100644
--- a/test/com/google/inject/IntegrationTest.java
+++ b/test/com/google/inject/IntegrationTest.java
@@ -28,7 +28,7 @@
*/
public class IntegrationTest extends TestCase {
- public void testIntegration() throws ContainerCreationException {
+ public void testIntegration() throws CreationException {
CountingInterceptor counter = new CountingInterceptor();
ContainerBuilder containerBuilder = new ContainerBuilder();
@@ -36,12 +36,12 @@
containerBuilder.intercept(any(), any(), counter);
Container container = containerBuilder.create();
- Foo foo = container.getFactory(Key.get(Foo.class)).get();
+ Foo foo = container.getLocator(Key.get(Foo.class)).get();
foo.foo();
assertTrue(foo.invoked);
assertEquals(1, counter.count);
- foo = container.getFactory(Foo.class).get();
+ foo = container.getLocator(Foo.class).get();
foo.foo();
assertTrue(foo.invoked);
assertEquals(2, counter.count);
diff --git a/test/com/google/inject/FactoryInjectionTest.java b/test/com/google/inject/LocatorInjectionTest.java
similarity index 68%
rename from test/com/google/inject/FactoryInjectionTest.java
rename to test/com/google/inject/LocatorInjectionTest.java
index ab0bebf..5dc99ef 100644
--- a/test/com/google/inject/FactoryInjectionTest.java
+++ b/test/com/google/inject/LocatorInjectionTest.java
@@ -21,9 +21,9 @@
/**
* @author crazybob@google.com (Bob Lee)
*/
-public class FactoryInjectionTest extends TestCase {
+public class LocatorInjectionTest extends TestCase {
- public void testFactoryInjection() throws ContainerCreationException {
+ public void testLocatorInjection() throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
builder.bind(Bar.class);
@@ -31,20 +31,20 @@
Container container = builder.create();
- Foo foo = container.getFactory(Foo.class).get();
+ Foo foo = container.getLocator(Foo.class).get();
- Bar bar = foo.barFactory.get();
+ Bar bar = foo.barLocator.get();
assertNotNull(bar);
- assertNotSame(bar, foo.barFactory.get());
+ assertNotSame(bar, foo.barLocator.get());
- ContainerScoped containerScoped = foo.containerScopedFactory.get();
+ ContainerScoped containerScoped = foo.containerScopedLocator.get();
assertNotNull(containerScoped);
- assertSame(containerScoped, foo.containerScopedFactory.get());
+ assertSame(containerScoped, foo.containerScopedLocator.get());
}
static class Foo {
- @Inject Factory<Bar> barFactory;
- @Inject Factory<ContainerScoped> containerScopedFactory;
+ @Inject Locator<Bar> barLocator;
+ @Inject Locator<ContainerScoped> containerScopedLocator;
}
static class Bar {}
diff --git a/test/com/google/inject/NotRequiredTest.java b/test/com/google/inject/NotRequiredTest.java
index e6dd10d..b287c80 100644
--- a/test/com/google/inject/NotRequiredTest.java
+++ b/test/com/google/inject/NotRequiredTest.java
@@ -23,18 +23,18 @@
*/
public class NotRequiredTest extends TestCase {
- public void testProvided() throws ContainerCreationException {
+ public void testProvided() throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
builder.bind(Bar.class).to(BarImpl.class);
Container c = builder.create();
- Foo foo = c.getFactory(Foo.class).get();
+ Foo foo = c.getLocator(Foo.class).get();
assertNotNull(foo.bar);
assertNotNull(foo.fromMethod);
}
- public void testNotProvided() throws ContainerCreationException {
+ public void testNotProvided() throws CreationException {
Container c = new ContainerBuilder().create();
- Foo foo = c.getFactory(Foo.class).get();
+ Foo foo = c.getLocator(Foo.class).get();
assertNull(foo.bar);
assertNull(foo.fromMethod);
}
diff --git a/test/com/google/inject/PerformanceComparison.java b/test/com/google/inject/PerformanceComparison.java
index 9f91e09..eb3c54a 100644
--- a/test/com/google/inject/PerformanceComparison.java
+++ b/test/com/google/inject/PerformanceComparison.java
@@ -94,7 +94,7 @@
};
static final Callable<Foo> juiceFactory = new Callable<Foo>() {
- final Factory<Foo> fooFactory;
+ final Locator<Foo> fooLocator;
{
ContainerBuilder builder = new ContainerBuilder();
@@ -109,14 +109,14 @@
});
try {
- fooFactory = builder.create().getFactory(Foo.class);
- } catch (ContainerCreationException e) {
+ fooLocator = builder.create().getLocator(Foo.class);
+ } catch (CreationException e) {
throw new RuntimeException(e);
}
}
public Foo call() throws Exception {
- return fooFactory.get();
+ return fooLocator.get();
}
};
diff --git a/test/com/google/inject/PreloadingTest.java b/test/com/google/inject/PreloadingTest.java
index 3b57202..eafce4e 100644
--- a/test/com/google/inject/PreloadingTest.java
+++ b/test/com/google/inject/PreloadingTest.java
@@ -30,14 +30,14 @@
Bar.count = 0;
}
- public void testPreloadSome() throws ContainerCreationException {
+ public void testPreloadSome() throws CreationException {
ContainerBuilder builder = createContainerBuilder(Stage.DEVELOPMENT);
builder.create();
assertEquals(1, Foo.count);
assertEquals(0, Bar.count);
}
- public void testPreloadAll() throws ContainerCreationException {
+ public void testPreloadAll() throws CreationException {
ContainerBuilder builder = createContainerBuilder(Stage.PRODUCTION);
builder.create();
assertEquals(1, Foo.count);
@@ -57,7 +57,7 @@
try {
builder.create();
fail();
- } catch (ContainerCreationException e) { /* expected */ }
+ } catch (CreationException e) { /* expected */ }
}
static class Foo {
diff --git a/test/com/google/inject/ProxyFactoryTest.java b/test/com/google/inject/ProxyFactoryTest.java
index 5c4487b..6d6bc1a 100644
--- a/test/com/google/inject/ProxyFactoryTest.java
+++ b/test/com/google/inject/ProxyFactoryTest.java
@@ -18,7 +18,7 @@
import com.google.inject.ConstructionProxy;
import static com.google.inject.matcher.Matchers.*;
-import com.google.inject.Factory;
+import com.google.inject.Locator;
import junit.framework.TestCase;
@@ -42,7 +42,7 @@
builder.intercept(any(), any(), interceptor);
ProxyFactory factory = builder.create();
- Factory<Simple> creator = factory.getFactory(Simple.class);
+ Locator<Simple> creator = factory.getFactory(Simple.class);
Simple simple = creator.get();
simple.invoke();
diff --git a/test/com/google/inject/ReflectionTest.java b/test/com/google/inject/ReflectionTest.java
index 3e6cc54..a86ad6c 100644
--- a/test/com/google/inject/ReflectionTest.java
+++ b/test/com/google/inject/ReflectionTest.java
@@ -28,37 +28,37 @@
@Retention(RUNTIME)
@Binder @interface I {}
- public void testNormalBinding() throws ContainerCreationException {
+ public void testNormalBinding() throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
Foo foo = new Foo();
builder.bind(Foo.class).to(foo);
Container container = builder.create();
Binding<Foo> fooBinding = container.getBinding(Key.get(Foo.class));
- assertSame(foo, fooBinding.getFactory().get());
+ assertSame(foo, fooBinding.getLocator().get());
assertNotNull(fooBinding.getSource());
assertEquals(Key.get(Foo.class), fooBinding.getKey());
assertFalse(fooBinding.isConstant());
}
- public void testConstantBinding() throws ContainerCreationException {
+ public void testConstantBinding() throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
builder.bindConstant(I.class).to(5);
Container container = builder.create();
Binding<?> i = container.getBinding(Key.get(int.class, I.class));
- assertEquals(5, i.getFactory().get());
+ assertEquals(5, i.getLocator().get());
assertNotNull(i.getSource());
assertEquals(Key.get(int.class, I.class), i.getKey());
assertTrue(i.isConstant());
}
- public void testLinkedBinding() throws ContainerCreationException {
+ public void testLinkedBinding() throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
Bar bar = new Bar();
builder.bind(Bar.class).to(bar);
builder.link(Key.get(Foo.class)).to(Key.get(Bar.class));
Container container = builder.create();
Binding<Foo> fooBinding = container.getBinding(Key.get(Foo.class));
- assertSame(bar, fooBinding.getFactory().get());
+ assertSame(bar, fooBinding.getLocator().get());
assertNotNull(fooBinding.getSource());
assertEquals(Key.get(Foo.class), fooBinding.getKey());
assertFalse(fooBinding.isConstant());
diff --git a/test/com/google/inject/ScopesTest.java b/test/com/google/inject/ScopesTest.java
index 18e16fc..25785bb 100644
--- a/test/com/google/inject/ScopesTest.java
+++ b/test/com/google/inject/ScopesTest.java
@@ -24,7 +24,7 @@
public class ScopesTest extends TestCase {
public void testContainerScopedAnnotation()
- throws ContainerCreationException {
+ throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
Object bindingBuilder
= builder.bind(Singleton.class);
@@ -37,7 +37,7 @@
static class Singleton {}
public void testOverriddingAnnotation()
- throws ContainerCreationException {
+ throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
Object bindingBuilder
= builder.bind(Singleton.class).in(Scopes.DEFAULT);
@@ -52,6 +52,6 @@
try {
builder.create();
fail();
- } catch (ContainerCreationException e) { /* expected */ }
+ } catch (CreationException e) { /* expected */ }
}
}
diff --git a/test/com/google/inject/StaticInjectionTest.java b/test/com/google/inject/StaticInjectionTest.java
index c7fe09b..c0925f1 100644
--- a/test/com/google/inject/StaticInjectionTest.java
+++ b/test/com/google/inject/StaticInjectionTest.java
@@ -31,7 +31,7 @@
@Retention(RUNTIME)
@Binder @interface S {}
- public void testInjectStatics() throws ContainerCreationException {
+ public void testInjectStatics() throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
builder.bindConstant(S.class).to("test");
builder.bindConstant(I.class).to(5);
diff --git a/test/com/google/inject/SuperclassTest.java b/test/com/google/inject/SuperclassTest.java
index 9b9b975..a9aa8d7 100644
--- a/test/com/google/inject/SuperclassTest.java
+++ b/test/com/google/inject/SuperclassTest.java
@@ -23,11 +23,11 @@
*/
public class SuperclassTest extends TestCase {
- public void testSuperclassInjection() throws ContainerCreationException {
+ public void testSuperclassInjection() throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
builder.bind(Foo.class);
Container container = builder.create();
- Factory<Sub> creator = container.getFactory(Sub.class);
+ Locator<Sub> creator = container.getLocator(Sub.class);
Sub sub = creator.get();
sub = creator.get();
sub = creator.get();
diff --git a/test/com/google/inject/servlet/ServletTest.java b/test/com/google/inject/servlet/ServletTest.java
index b72332a..26b8c3d 100644
--- a/test/com/google/inject/servlet/ServletTest.java
+++ b/test/com/google/inject/servlet/ServletTest.java
@@ -18,7 +18,7 @@
import com.google.inject.Container;
import com.google.inject.ContainerBuilder;
-import com.google.inject.ContainerCreationException;
+import com.google.inject.CreationException;
import com.google.inject.Key;
import junit.framework.TestCase;
@@ -45,7 +45,7 @@
public class ServletTest extends TestCase {
public void testNewRequestObject()
- throws ContainerCreationException, IOException, ServletException {
+ throws CreationException, IOException, ServletException {
final Container container = createContainer();
GuiceFilter filter = new GuiceFilter();
@@ -75,7 +75,7 @@
}
public void testExistingRequestObject()
- throws ContainerCreationException, IOException, ServletException {
+ throws CreationException, IOException, ServletException {
final Container container = createContainer();
GuiceFilter filter = new GuiceFilter();
@@ -106,7 +106,7 @@
}
public void testNewSessionObject()
- throws ContainerCreationException, IOException, ServletException {
+ throws CreationException, IOException, ServletException {
final Container container = createContainer();
GuiceFilter filter = new GuiceFilter();
@@ -139,7 +139,7 @@
}
public void testExistingSessionObject()
- throws ContainerCreationException, IOException, ServletException {
+ throws CreationException, IOException, ServletException {
final Container container = createContainer();
GuiceFilter filter = new GuiceFilter();
@@ -173,7 +173,7 @@
assertTrue(invoked[0]);
}
- private Container createContainer() throws ContainerCreationException {
+ private Container createContainer() throws CreationException {
ContainerBuilder builder = new ContainerBuilder();
builder.install(new ServletModule());
builder.bind(InSession.class);