Removing oldversion SPI and commands. These are both replaced by Elements.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@609 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/src/com/google/inject/BindingImpl.java b/src/com/google/inject/BindingImpl.java
index 67e42e2..395a2a7 100644
--- a/src/com/google/inject/BindingImpl.java
+++ b/src/com/google/inject/BindingImpl.java
@@ -21,13 +21,11 @@
import com.google.inject.internal.ToStringBuilder;
import com.google.inject.spi.BindingScopingVisitor;
import com.google.inject.spi.ElementVisitor;
-import com.google.inject.spi.oldversion.OldVersionBinding;
-import com.google.inject.spi.oldversion.ProviderBinding;
/**
* @author crazybob@google.com (Bob Lee)
*/
-abstract class BindingImpl<T> implements OldVersionBinding<T> {
+abstract class BindingImpl<T> implements Binding<T> {
final InjectorImpl injector;
final Key<T> key;
@@ -63,13 +61,6 @@
return provider;
}
- @SuppressWarnings("unchecked")
- public ProviderBinding<T> getProviderBinding() {
- // ProviderBinding is the only type of binding that can be generated for
- // a Provider<T>.
- return (ProviderBinding<T>) injector.getBinding(key.providerKey());
- }
-
InternalFactory<? extends T> getInternalFactory() {
return internalFactory;
}
diff --git a/src/com/google/inject/ClassBindingImpl.java b/src/com/google/inject/ClassBindingImpl.java
index 6dfa498..8196235 100644
--- a/src/com/google/inject/ClassBindingImpl.java
+++ b/src/com/google/inject/ClassBindingImpl.java
@@ -22,16 +22,13 @@
import com.google.inject.internal.ToStringBuilder;
import com.google.inject.spi.BindingTargetVisitor;
import com.google.inject.spi.InjectionPoint;
-import com.google.inject.spi.oldversion.BindingVisitor;
-import com.google.inject.spi.oldversion.ClassBinding;
import java.util.Collection;
/**
*
*
*/
-class ClassBindingImpl<T> extends BindingImpl<T>
- implements ClassBinding<T> {
+class ClassBindingImpl<T> extends BindingImpl<T> {
private final InjectorImpl.LateBoundConstructor<T> lateBoundConstructor;
@@ -47,10 +44,6 @@
lateBoundConstructor.bind(injector, getBoundClass(), errors);
}
- public void accept(BindingVisitor<? super T> visitor) {
- visitor.visit(this);
- }
-
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor) {
return visitor.visitConstructor(lateBoundConstructor.getConstructor());
}
@@ -85,7 +78,7 @@
}
@Override public String toString() {
- return new ToStringBuilder(ClassBinding.class)
+ return new ToStringBuilder(Binding.class)
.add("class", getBoundClass())
.add("scope", scope)
.add("source", source)
diff --git a/src/com/google/inject/InjectorImpl.java b/src/com/google/inject/InjectorImpl.java
index 98f8f14..1890b9c 100644
--- a/src/com/google/inject/InjectorImpl.java
+++ b/src/com/google/inject/InjectorImpl.java
@@ -33,10 +33,6 @@
import com.google.inject.internal.ToStringBuilder;
import com.google.inject.spi.BindingTargetVisitor;
import com.google.inject.spi.InjectionPoint;
-import com.google.inject.spi.oldversion.BindingVisitor;
-import com.google.inject.spi.oldversion.ConvertedConstantBinding;
-import com.google.inject.spi.oldversion.OldVersionBinding;
-import com.google.inject.spi.oldversion.ProviderBinding;
import com.google.inject.util.Providers;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
@@ -151,12 +147,12 @@
private <T> BindingImpl<T> getParentBinding(Key<T> key) {
synchronized (parentBindings) {
// null values will mean that the parent doesn't have this binding
- OldVersionBinding<T> binding = (OldVersionBinding<T>) parentBindings.get(key);
+ BindingImpl<T> binding = (BindingImpl<T>) parentBindings.get(key);
if (binding != null) {
return (BindingImpl<T>) binding;
}
try {
- binding = (OldVersionBinding) parentInjector.getBinding(key);
+ binding = (BindingImpl) parentInjector.getBinding(key);
}
catch (ProvisionException e) {
// if this happens, the parent can't create this key, and we ignore it
@@ -237,10 +233,9 @@
return new ProviderBindingImpl<T>(this, key, delegate, loadStrategy);
}
- static class ProviderBindingImpl<T> extends BindingImpl<Provider<T>>
- implements ProviderBinding<T> {
+ static class ProviderBindingImpl<T> extends BindingImpl<Provider<T>> {
- final OldVersionBinding<T> providedBinding;
+ final BindingImpl<T> providedBinding;
ProviderBindingImpl(
InjectorImpl injector,
@@ -254,7 +249,7 @@
createInternalFactory(providedBinding),
Scopes.NO_SCOPE,
loadStrategy);
- this.providedBinding = (OldVersionBinding<T>) providedBinding;
+ this.providedBinding = (BindingImpl<T>) providedBinding;
}
static <T> InternalFactory<Provider<T>> createInternalFactory(Binding<T> providedBinding) {
@@ -267,15 +262,11 @@
};
}
- public void accept(BindingVisitor<? super Provider<T>> bindingVisitor) {
- bindingVisitor.visit(this);
- }
-
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super Provider<T>, V> visitor) {
return visitor.visitProviderBinding(providedBinding.getKey());
}
- public OldVersionBinding<T> getTargetBinding() {
+ public BindingImpl<T> getTargetBinding() {
return providedBinding;
}
}
@@ -341,8 +332,7 @@
}
}
- private static class ConvertedConstantBindingImpl<T> extends BindingImpl<T>
- implements ConvertedConstantBinding<T> {
+ private static class ConvertedConstantBindingImpl<T> extends BindingImpl<T> {
final T value;
final Provider<T> provider;
final Binding<String> originalBinding;
@@ -360,10 +350,6 @@
return provider;
}
- public void accept(BindingVisitor<? super T> bindingVisitor) {
- bindingVisitor.visit(this);
- }
-
public T getValue() {
return value;
}
@@ -372,12 +358,12 @@
return visitor.visitConvertedConstant(value);
}
- public OldVersionBinding<String> getOriginal() {
- return (OldVersionBinding) originalBinding;
+ public BindingImpl<String> getOriginal() {
+ return (BindingImpl<String>) originalBinding;
}
@Override public String toString() {
- return new ToStringBuilder(ConvertedConstantBinding.class)
+ return new ToStringBuilder(Binding.class)
.add("key", key)
.add("value", value)
.add("original", originalBinding)
diff --git a/src/com/google/inject/InstanceBindingImpl.java b/src/com/google/inject/InstanceBindingImpl.java
index 75d8d6a..1c2ae86 100644
--- a/src/com/google/inject/InstanceBindingImpl.java
+++ b/src/com/google/inject/InstanceBindingImpl.java
@@ -21,13 +21,10 @@
import com.google.inject.internal.ToStringBuilder;
import com.google.inject.spi.BindingTargetVisitor;
import com.google.inject.spi.InjectionPoint;
-import com.google.inject.spi.oldversion.BindingVisitor;
-import com.google.inject.spi.oldversion.InstanceBinding;
import com.google.inject.util.Providers;
import java.util.Collection;
-class InstanceBindingImpl<T> extends BindingImpl<T>
- implements InstanceBinding<T> {
+class InstanceBindingImpl<T> extends BindingImpl<T> {
final T instance;
final Provider<T> provider;
@@ -43,10 +40,6 @@
return this.provider;
}
- public void accept(BindingVisitor<? super T> bindingVisitor) {
- bindingVisitor.visit(this);
- }
-
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor) {
return visitor.visitInstance(instance);
}
@@ -67,7 +60,7 @@
}
@Override public String toString() {
- return new ToStringBuilder(InstanceBinding.class)
+ return new ToStringBuilder(Binding.class)
.add("key", key)
.add("instance", instance)
.add("source", source)
diff --git a/src/com/google/inject/InvalidBindingImpl.java b/src/com/google/inject/InvalidBindingImpl.java
index 0c9a4b7..dea02bb 100644
--- a/src/com/google/inject/InvalidBindingImpl.java
+++ b/src/com/google/inject/InvalidBindingImpl.java
@@ -19,7 +19,6 @@
import com.google.inject.internal.Errors;
import com.google.inject.spi.BindingTargetVisitor;
import com.google.inject.spi.InjectionPoint;
-import com.google.inject.spi.oldversion.BindingVisitor;
class InvalidBindingImpl<T> extends BindingImpl<T> {
@@ -31,10 +30,6 @@
}, Scopes.NO_SCOPE, LoadStrategy.LAZY);
}
- public void accept(BindingVisitor<? super T> bindingVisitor) {
- throw new AssertionError();
- }
-
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> vVisitor) {
throw new UnsupportedOperationException();
}
diff --git a/src/com/google/inject/LinkedBindingImpl.java b/src/com/google/inject/LinkedBindingImpl.java
index 4f28410..5737b90 100644
--- a/src/com/google/inject/LinkedBindingImpl.java
+++ b/src/com/google/inject/LinkedBindingImpl.java
@@ -18,16 +18,12 @@
import com.google.inject.internal.ToStringBuilder;
import com.google.inject.spi.BindingTargetVisitor;
-import com.google.inject.spi.oldversion.BindingVisitor;
-import com.google.inject.spi.oldversion.LinkedBinding;
-import com.google.inject.spi.oldversion.OldVersionBinding;
/**
*
*
*/
-class LinkedBindingImpl<T> extends BindingImpl<T>
- implements LinkedBinding<T> {
+class LinkedBindingImpl<T> extends BindingImpl<T> {
final Key<? extends T> targetKey;
@@ -39,20 +35,12 @@
this.targetKey = targetKey;
}
- public void accept(BindingVisitor<? super T> bindingVisitor) {
- bindingVisitor.visit(this);
- }
-
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor) {
return visitor.visitKey(targetKey);
}
- public OldVersionBinding<? extends T> getTargetBinding() {
- return injector.getBinding(targetKey);
- }
-
@Override public String toString() {
- return new ToStringBuilder(LinkedBinding.class)
+ return new ToStringBuilder(Binding.class)
.add("key", key)
.add("target", targetKey)
.add("scope", scope)
diff --git a/src/com/google/inject/LinkedProviderBindingImpl.java b/src/com/google/inject/LinkedProviderBindingImpl.java
index eb836e2..9132e05 100644
--- a/src/com/google/inject/LinkedProviderBindingImpl.java
+++ b/src/com/google/inject/LinkedProviderBindingImpl.java
@@ -18,16 +18,12 @@
import com.google.inject.internal.ToStringBuilder;
import com.google.inject.spi.BindingTargetVisitor;
-import com.google.inject.spi.oldversion.BindingVisitor;
-import com.google.inject.spi.oldversion.LinkedProviderBinding;
-import com.google.inject.spi.oldversion.OldVersionBinding;
/**
*
*
*/
-class LinkedProviderBindingImpl<T> extends BindingImpl<T>
- implements LinkedProviderBinding<T> {
+class LinkedProviderBindingImpl<T> extends BindingImpl<T> {
final Key<? extends Provider<? extends T>> providerKey;
@@ -39,20 +35,12 @@
this.providerKey = providerKey;
}
- public void accept(BindingVisitor<? super T> bindingVisitor) {
- bindingVisitor.visit(this);
- }
-
- public OldVersionBinding<? extends Provider<? extends T>> getTargetProvider() {
- return injector.getBinding(providerKey);
- }
-
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor) {
return visitor.visitProviderKey(providerKey);
}
@Override public String toString() {
- return new ToStringBuilder(LinkedProviderBinding.class)
+ return new ToStringBuilder(Binding.class)
.add("key", key)
.add("provider", providerKey)
.add("scope", scope)
diff --git a/src/com/google/inject/ProviderInstanceBindingImpl.java b/src/com/google/inject/ProviderInstanceBindingImpl.java
index 7cddd12..a0b14ad 100644
--- a/src/com/google/inject/ProviderInstanceBindingImpl.java
+++ b/src/com/google/inject/ProviderInstanceBindingImpl.java
@@ -20,15 +20,12 @@
import com.google.inject.internal.ToStringBuilder;
import com.google.inject.spi.BindingTargetVisitor;
import com.google.inject.spi.InjectionPoint;
-import com.google.inject.spi.oldversion.BindingVisitor;
-import com.google.inject.spi.oldversion.ProviderInstanceBinding;
import java.util.Collection;
/**
*
*/
-class ProviderInstanceBindingImpl<T> extends BindingImpl<T>
- implements ProviderInstanceBinding<T> {
+class ProviderInstanceBindingImpl<T> extends BindingImpl<T> {
final Provider<? extends T> providerInstance;
@@ -41,10 +38,6 @@
this.providerInstance = providerInstance;
}
- public void accept(BindingVisitor<? super T> bindingVisitor) {
- bindingVisitor.visit(this);
- }
-
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor) {
return visitor.visitProvider(providerInstance);
}
@@ -66,7 +59,7 @@
@Override
public String toString() {
- return new ToStringBuilder(ProviderInstanceBinding.class)
+ return new ToStringBuilder(Binding.class)
.add("key", key)
.add("provider", providerInstance)
.add("scope", scope)
diff --git a/src/com/google/inject/commands/AddMessageCommand.java b/src/com/google/inject/commands/AddMessageCommand.java
deleted file mode 100644
index 8437d18..0000000
--- a/src/com/google/inject/commands/AddMessageCommand.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * 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.commands;
-
-import com.google.common.collect.ImmutableList;
-import com.google.inject.spi.InjectionPoint;
-import com.google.inject.spi.Message;
-
-/**
- * Immutable snapshot of a request to add a string message.
- *
- * @deprecated replaced with {@link com.google.inject.spi.Message}
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-@Deprecated
-public final class AddMessageCommand implements Command {
- private final Message message;
-
- AddMessageCommand(Message message) {
- this.message = message;
- }
-
- AddMessageCommand(Object source, String message, Object[] arguments) {
- this.message = new Message(source, String.format(message, arguments));
- }
-
- AddMessageCommand(Object source, Throwable throwable) {
- this.message = new Message(source,
- "An exception was caught and reported. Message: " + throwable.getMessage(),
- ImmutableList.<InjectionPoint>of(), throwable);
- }
-
- public Object getSource() {
- return message.getSource();
- }
-
- public <T> T acceptVisitor(Visitor<T> visitor) {
- return visitor.visitAddMessage(this);
- }
-
- public Message getMessage() {
- return message;
- }
-}
diff --git a/src/com/google/inject/commands/BindCommand.java b/src/com/google/inject/commands/BindCommand.java
deleted file mode 100644
index 2b30f0a..0000000
--- a/src/com/google/inject/commands/BindCommand.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/**
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.inject.Binder;
-import com.google.inject.Key;
-import com.google.inject.Provider;
-import com.google.inject.Scope;
-import com.google.inject.TypeLiteral;
-import com.google.inject.binder.AnnotatedBindingBuilder;
-import com.google.inject.binder.ConstantBindingBuilder;
-import com.google.inject.binder.LinkedBindingBuilder;
-import com.google.inject.binder.ScopedBindingBuilder;
-import java.lang.annotation.Annotation;
-
-/**
- * Immutable snapshot of a request to bind a value.
- *
- * @deprecated replaced with {@link com.google.inject.Binding}
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-@Deprecated
-public final class BindCommand<T> implements Command {
-
- private static final BindTarget<Object> EMPTY_BIND_TARGET = new AbstractTarget<Object>() {
- public ScopedBindingBuilder execute(LinkedBindingBuilder<Object> linkedBindingBuilder) {
- return linkedBindingBuilder;
- }
- public <V> V acceptVisitor(Visitor<Object, V> visitor) {
- return visitor.visitUntargetted();
- }
- };
-
- private static final BindScoping EMPTY_SCOPING = new AbstractScoping() {
- public void execute(ScopedBindingBuilder scopedBindingBuilder) {
- // do nothing
- }
- public <V> V acceptVisitor(Visitor<V> visitor) {
- return visitor.visitNoScoping();
- }
- };
-
- private final Object source;
- private Key<T> key;
-
- @SuppressWarnings("unchecked")
- private BindTarget<T> bindTarget = (BindTarget<T>) EMPTY_BIND_TARGET;
- private BindScoping bindScoping = EMPTY_SCOPING;
-
- BindCommand(Object source, Key<T> key) {
- this.source = checkNotNull(source, "source");
- this.key = checkNotNull(key, "key");
- }
-
- public Object getSource() {
- return source;
- }
-
- public <V> V acceptVisitor(Visitor<V> visitor) {
- return visitor.visitBind(this);
- }
-
- public Key<T> getKey() {
- return key;
- }
-
- public BindTarget<T> getTarget() {
- return bindTarget;
- }
-
- public BindScoping getScoping() {
- return bindScoping;
- }
-
- @Override public String toString() {
- return "bind " + key
- + (bindTarget == EMPTY_BIND_TARGET ? "" : (" to " + bindTarget))
- + (bindScoping == EMPTY_SCOPING ? "" : (" in " + bindScoping));
- }
-
- private static abstract class AbstractTarget<T> implements BindTarget<T> {
- public void execute(ConstantBindingBuilder builder) {
- throw new UnsupportedOperationException();
- }
- public T get() {
- return null;
- }
- public Key<? extends Provider<? extends T>> getProviderKey() {
- return null;
- }
- public Provider<? extends T> getProvider() {
- return null;
- }
- public Key<? extends T> getKey() {
- return null;
- }
- }
-
- private static abstract class AbstractScoping implements BindScoping {
- public boolean isEagerSingleton() {
- return false;
- }
- public Scope getScope() {
- return null;
- }
- public Class<? extends Annotation> getScopeAnnotation() {
- return null;
- }
- }
-
- BindingBuilder bindingBuilder(Binder binder) {
- return new BindingBuilder(binder);
- }
-
- /**
- * Package-private write access to the internal state of this command.
- */
- class BindingBuilder implements AnnotatedBindingBuilder<T> {
- private final Binder binder;
-
- BindingBuilder(Binder binder) {
- this.binder = binder.skipSources(BindingBuilder.class);
- }
-
- public LinkedBindingBuilder<T> annotatedWith(
- Class<? extends Annotation> annotationType) {
- checkNotNull(annotationType, "annotationType");
- checkNotAnnotated();
- key = Key.get(key.getTypeLiteral(), annotationType);
- return this;
- }
-
- public LinkedBindingBuilder<T> annotatedWith(Annotation annotation) {
- checkNotNull(annotation, "annotation");
- checkNotAnnotated();
- key = Key.get(key.getTypeLiteral(), annotation);
- return this;
- }
-
- public ScopedBindingBuilder to(final Class<? extends T> implementation) {
- return to(Key.get(implementation));
- }
-
- public ScopedBindingBuilder to(
- final TypeLiteral<? extends T> implementation) {
- return to(Key.get(implementation));
- }
-
- public ScopedBindingBuilder to(final Key<? extends T> targetKey) {
- checkNotNull(targetKey, "targetKey");
- checkNotTargetted();
- bindTarget = new AbstractTarget<T>() {
- public ScopedBindingBuilder execute(LinkedBindingBuilder<T> linkedBindingBuilder) {
- return linkedBindingBuilder.to(targetKey);
- }
- @Override public Key<? extends T> getKey() {
- return targetKey;
- }
- public <V> V acceptVisitor(Visitor<T, V> visitor) {
- return visitor.visitToKey(targetKey);
- }
- @Override public String toString() {
- return String.valueOf(targetKey);
- }
- };
- return this;
- }
-
- public void toInstance(final T instance) {
- checkNotTargetted();
- bindTarget = new AbstractTarget<T>() {
- public ScopedBindingBuilder execute(LinkedBindingBuilder<T> linkedBindingBuilder) {
- linkedBindingBuilder.toInstance(instance);
- return null;
- }
- @Override public T get() {
- return instance;
- }
- public <V> V acceptVisitor(Visitor<T, V> visitor) {
- return visitor.visitToInstance(instance);
- }
- @Override public String toString() {
- return "instance " + instance;
- }
- };
- }
-
- public ScopedBindingBuilder toProvider(final Provider<? extends T> provider) {
- checkNotNull(provider, "provider");
- checkNotTargetted();
- bindTarget = new AbstractTarget<T>() {
- public ScopedBindingBuilder execute(LinkedBindingBuilder<T> linkedBindingBuilder) {
- return linkedBindingBuilder.toProvider(provider);
- }
- @Override public Provider<? extends T> getProvider() {
- return provider;
- }
- public <V> V acceptVisitor(Visitor<T, V> visitor) {
- return visitor.visitToProvider(provider);
- }
- @Override public String toString() {
- return "provider " + provider;
- }
- };
- return this;
- }
-
- public ScopedBindingBuilder toProvider(
- Class<? extends Provider<? extends T>> providerType) {
- return toProvider(Key.get(providerType));
- }
-
- public ScopedBindingBuilder toProvider(
- final Key<? extends Provider<? extends T>> providerKey) {
- checkNotNull(providerKey, "providerKey");
- checkNotTargetted();
- bindTarget = new AbstractTarget<T>() {
- public ScopedBindingBuilder execute(LinkedBindingBuilder<T> linkedBindingBuilder) {
- return linkedBindingBuilder.toProvider(providerKey);
- }
- @Override public Key<? extends Provider<? extends T>> getProviderKey() {
- return providerKey;
- }
- public <V> V acceptVisitor(Visitor<T, V> visitor) {
- return visitor.visitToProviderKey(providerKey);
- }
- @Override public String toString() {
- return "provider " + providerKey;
- }
- };
- return this;
- }
-
- public void in(final Class<? extends Annotation> scopeAnnotation) {
- checkNotNull(scopeAnnotation, "scopeAnnotation");
- checkNotScoped();
-
- bindScoping = new AbstractScoping() {
- public void execute(ScopedBindingBuilder scopedBindingBuilder) {
- scopedBindingBuilder.in(scopeAnnotation);
- }
- @Override public Class<? extends Annotation> getScopeAnnotation() {
- return scopeAnnotation;
- }
- public <V> V acceptVisitor(Visitor<V> visitor) {
- return visitor.visitScopeAnnotation(scopeAnnotation);
- }
- @Override public String toString() {
- return scopeAnnotation.getName();
- }
- };
- }
-
- public void in(final Scope scope) {
- checkNotNull(scope, "scope");
- checkNotScoped();
- bindScoping = new AbstractScoping() {
-
- public void execute(ScopedBindingBuilder scopedBindingBuilder) {
- scopedBindingBuilder.in(scope);
- }
- @Override public Scope getScope() {
- return scope;
- }
- public <V> V acceptVisitor(Visitor<V> visitor) {
- return visitor.visitScope(scope);
- }
- @Override public String toString() {
- return String.valueOf(scope);
- }
- };
- }
-
- public void asEagerSingleton() {
- checkNotScoped();
- bindScoping = new AbstractScoping() {
- public void execute(ScopedBindingBuilder scopedBindingBuilder) {
- scopedBindingBuilder.asEagerSingleton();
- }
- @Override public boolean isEagerSingleton() {
- return true;
- }
- public <V> V acceptVisitor(Visitor<V> visitor) {
- return visitor.visitEagerSingleton();
- }
- @Override public String toString() {
- return "eager singleton";
- }
- };
- }
-
- static final String IMPLEMENTATION_ALREADY_SET
- = "Implementation is set more than once.";
- static final String SINGLE_INSTANCE_AND_SCOPE = "Setting the scope is not"
- + " permitted when binding to a single instance.";
- static final String SCOPE_ALREADY_SET = "Scope is set more than once.";
- static final String ANNOTATION_ALREADY_SPECIFIED = "More than one annotation"
- + " is specified for this binding.";
-
- private void checkNotTargetted() {
- if (bindTarget != EMPTY_BIND_TARGET) {
- binder.addError(IMPLEMENTATION_ALREADY_SET);
- }
- }
-
- private void checkNotAnnotated() {
- if (BindCommand.this.key.getAnnotationType() != null) {
- binder.addError(ANNOTATION_ALREADY_SPECIFIED);
- }
- }
-
- private void checkNotScoped() {
- // Scoping isn't allowed when we have only one instance.
- if (bindTarget.get() != null) {
- binder.addError(SINGLE_INSTANCE_AND_SCOPE);
- return;
- }
-
- if (bindScoping != EMPTY_SCOPING) {
- binder.addError(SCOPE_ALREADY_SET);
- }
- }
-
- @Override public String toString() {
- String type = key.getAnnotationType() == null
- ? "AnnotatedBindingBuilder<"
- : "LinkedBindingBuilder<";
- return type + key.getTypeLiteral() + ">";
- }
- }
-}
diff --git a/src/com/google/inject/commands/BindConstantCommand.java b/src/com/google/inject/commands/BindConstantCommand.java
deleted file mode 100644
index fed64c4..0000000
--- a/src/com/google/inject/commands/BindConstantCommand.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/**
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.inject.Binder;
-import com.google.inject.Key;
-import com.google.inject.Provider;
-import com.google.inject.binder.AnnotatedConstantBindingBuilder;
-import com.google.inject.binder.ConstantBindingBuilder;
-import com.google.inject.binder.LinkedBindingBuilder;
-import com.google.inject.binder.ScopedBindingBuilder;
-import java.lang.annotation.Annotation;
-
-/**
- * Immutable snapshot of a request to bind a constant.
- *
- * @deprecated replaced with {@link com.google.inject.Binding}
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-@Deprecated
-public final class BindConstantCommand implements Command {
- private final Object source;
- private BindingAnnotation bindingAnnotation;
- private ConstantTarget<?> target;
-
- BindConstantCommand(Object source) {
- this.source = checkNotNull(source, "source");
- }
-
- public Object getSource() {
- return source;
- }
-
- public <T> T acceptVisitor(Visitor<T> visitor) {
- return visitor.visitBindConstant(this);
- }
-
- public BindTarget<?> getTarget() {
- return target;
- }
-
- public <T> Key<T> getKey() {
- return bindingAnnotation.getKey();
- }
-
- /**
- * Target API for bindConstant().
- */
- private static abstract class ConstantTarget<T> implements BindTarget<T> {
-
- /**
- * Returns the type of constant, such as {@code Integer.class} or
- * {@code Enum.class}.
- */
- abstract Class getType();
-
- public boolean hasInstance() {
- return true;
- }
- public ScopedBindingBuilder execute(LinkedBindingBuilder linkedBindingBuilder) {
- throw new UnsupportedOperationException();
- }
- public <V> V acceptVisitor(Visitor<T, V> visitor) {
- return visitor.visitToInstance(get());
- }
- public Provider<? extends T> getProvider() {
- return null;
- }
- public Key<? extends Provider<? extends T>> getProviderKey() {
- return null;
- }
- public Key<? extends T> getKey() {
- return null;
- }
- }
-
- /**
- * Internal annotation API.
- */
- private abstract class BindingAnnotation {
- abstract ConstantBindingBuilder execute(AnnotatedConstantBindingBuilder builder);
- abstract <T> Key<T> getKey();
- }
-
- BindingBuilder bindingBuilder(Binder binder) {
- return new BindingBuilder(binder);
- }
-
- /**
- * Package-private write access to the internal state of this command.
- */
- class BindingBuilder
- implements AnnotatedConstantBindingBuilder, ConstantBindingBuilder {
- private final Binder binder;
-
- BindingBuilder(Binder binder) {
- this.binder = binder.skipSources(BindingBuilder.class);
- }
-
- public ConstantBindingBuilder annotatedWith(final Class<? extends Annotation> annotationType) {
- checkNotNull(annotationType, "annotationType");
- assertNoBindingAnnotation();
-
- bindingAnnotation = new BindingAnnotation() {
- public ConstantBindingBuilder execute(AnnotatedConstantBindingBuilder builder) {
- return builder.annotatedWith(annotationType);
- }
- @SuppressWarnings({"unchecked"})
- public <T> Key<T> getKey() {
- return Key.get((Class<T>) target.getType(), annotationType);
- }
- };
- return this;
- }
-
- public ConstantBindingBuilder annotatedWith(final Annotation annotation) {
- checkNotNull(annotation, "annotation");
- assertNoBindingAnnotation();
-
- bindingAnnotation = new BindingAnnotation() {
- public ConstantBindingBuilder execute(AnnotatedConstantBindingBuilder builder) {
- return builder.annotatedWith(annotation);
- }
- @SuppressWarnings({"unchecked"})
- public <T> Key<T> getKey() {
- return Key.get((Class<T>) target.getType(), annotation);
- }
- };
- return this;
- }
-
- public void to(final String value) {
- checkNotNull(value, "value");
- assertNoTarget();
-
- BindConstantCommand.this.target = new ConstantTarget() {
- public void execute(ConstantBindingBuilder builder) {
- builder.to(value);
- }
- public Object get() {
- return value;
- }
- public Class getType() {
- return String.class;
- }
- @Override public String toString() {
- return value;
- }
- };
- }
-
- public void to(final int value) {
- assertNoTarget();
-
- BindConstantCommand.this.target = new ConstantTarget() {
- public void execute(ConstantBindingBuilder builder) {
- builder.to(value);
- }
- public Object get() {
- return value;
- }
- public Class getType() {
- return Integer.class;
- }
- @Override public String toString() {
- return String.valueOf(value);
- }
- };
- }
-
- public void to(final long value) {
- assertNoTarget();
-
- BindConstantCommand.this.target = new ConstantTarget() {
- public void execute(ConstantBindingBuilder builder) {
- builder.to(value);
- }
- public Object get() {
- return value;
- }
- public Class getType() {
- return Long.class;
- }
- @Override public String toString() {
- return String.valueOf(value);
- }
- };
- }
-
- public void to(final boolean value) {
- assertNoTarget();
-
- BindConstantCommand.this.target = new ConstantTarget() {
- public void execute(ConstantBindingBuilder builder) {
- builder.to(value);
- }
- public Object get() {
- return value;
- }
- public Class getType() {
- return Boolean.class;
- }
- @Override public String toString() {
- return String.valueOf(value);
- }
- };
- }
-
- public void to(final double value) {
- assertNoTarget();
-
- BindConstantCommand.this.target = new ConstantTarget() {
- public void execute(ConstantBindingBuilder builder) {
- builder.to(value);
- }
- public Object get() {
- return value;
- }
- public Class getType() {
- return Double.class;
- }
- @Override public String toString() {
- return String.valueOf(value);
- }
- };
- }
-
- public void to(final float value) {
- assertNoTarget();
-
- BindConstantCommand.this.target = new ConstantTarget() {
- public void execute(ConstantBindingBuilder builder) {
- builder.to(value);
- }
- public Object get() {
- return value;
- }
- public Class getType() {
- return Float.class;
- }
- @Override public String toString() {
- return String.valueOf(value);
- }
- };
- }
-
- public void to(final short value) {
- assertNoTarget();
-
- BindConstantCommand.this.target = new ConstantTarget() {
- public void execute(ConstantBindingBuilder builder) {
- builder.to(value);
- }
- public Object get() {
- return value;
- }
- public Class getType() {
- return Short.class;
- }
- @Override public String toString() {
- return String.valueOf(value);
- }
- };
- }
-
- public void to(final char value) {
- assertNoTarget();
-
- BindConstantCommand.this.target = new ConstantTarget() {
- public void execute(ConstantBindingBuilder builder) {
- builder.to(value);
- }
- public Object get() {
- return value;
- }
- public Class getType() {
- return Character.class;
- }
- @Override public String toString() {
- return String.valueOf(value);
- }
- };
- }
-
- public void to(final Class<?> value) {
- checkNotNull(value, "value");
- assertNoTarget();
-
- BindConstantCommand.this.target = new ConstantTarget() {
- public void execute(ConstantBindingBuilder builder) {
- builder.to(value);
- }
- public Object get() {
- return value;
- }
- public Class getType() {
- return Class.class;
- }
- @Override public String toString() {
- return String.valueOf(value);
- }
- };
- }
-
- public <E extends Enum<E>> void to(final E value) {
- checkNotNull(value, "value");
- assertNoTarget();
-
- BindConstantCommand.this.target = new ConstantTarget() {
- public void execute(ConstantBindingBuilder builder) {
- builder.to(value);
- }
- public Object get() {
- return value;
- }
- public Class getType() {
- return value.getDeclaringClass();
- }
- @Override public String toString() {
- return String.valueOf(value);
- }
- };
- }
-
- static final String CONSTANT_VALUE_ALREADY_SET = "Constant value is set more"
- + " than once.";
- static final String ANNOTATION_ALREADY_SPECIFIED = "More than one annotation"
- + " is specified for this binding.";
-
- private void assertNoBindingAnnotation() {
- if (bindingAnnotation != null) {
- binder.addError(ANNOTATION_ALREADY_SPECIFIED);
- }
- }
-
- private void assertNoTarget() {
- if (target != null) {
- binder.addError(CONSTANT_VALUE_ALREADY_SET);
- }
- }
-
- @Override public String toString() {
- return bindingAnnotation == null
- ? "AnnotatedConstantBindingBuilder"
- : "ConstantBindingBuilder";
- }
- }
-}
diff --git a/src/com/google/inject/commands/BindInterceptorCommand.java b/src/com/google/inject/commands/BindInterceptorCommand.java
deleted file mode 100644
index fdfc550..0000000
--- a/src/com/google/inject/commands/BindInterceptorCommand.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.inject.matcher.Matcher;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import static java.util.Collections.unmodifiableList;
-import java.util.List;
-import org.aopalliance.intercept.MethodInterceptor;
-
-/**
- * Immutable snapshot of a request to bind an interceptor.
- *
- * @deprecated replaced with {@link com.google.inject.spi.InterceptorBinding}
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-@Deprecated
-public final class BindInterceptorCommand implements Command {
- private final Object source;
- private final Matcher<? super Class<?>> classMatcher;
- private final Matcher<? super Method> methodMatcher;
- private final List<MethodInterceptor> interceptors;
-
- BindInterceptorCommand(
- Object source,
- Matcher<? super Class<?>> classMatcher,
- Matcher<? super Method> methodMatcher,
- MethodInterceptor[] interceptors) {
- this.source = checkNotNull(source, "source");
- this.classMatcher = checkNotNull(classMatcher, "classMatcher");
- this.methodMatcher = checkNotNull(methodMatcher, "methodMatcher");
- this.interceptors = unmodifiableList(Arrays.asList(interceptors.clone()));
- }
-
- public Object getSource() {
- return source;
- }
-
- public Matcher<? super Class<?>> getClassMatcher() {
- return classMatcher;
- }
-
- public Matcher<? super Method> getMethodMatcher() {
- return methodMatcher;
- }
-
- public List<MethodInterceptor> getInterceptors() {
- return interceptors;
- }
-
- public <T> T acceptVisitor(Visitor<T> visitor) {
- return visitor.visitBindInterceptor(this);
- }
-}
diff --git a/src/com/google/inject/commands/BindScopeCommand.java b/src/com/google/inject/commands/BindScopeCommand.java
deleted file mode 100644
index 2c17e81..0000000
--- a/src/com/google/inject/commands/BindScopeCommand.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.inject.Scope;
-import java.lang.annotation.Annotation;
-
-/**
- * Immutable snapshot of a request to bind a scope.
- *
- * @deprecated replaced with {@link com.google.inject.spi.ScopeBinding}
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-@Deprecated
-public final class BindScopeCommand implements Command {
- private final Object source;
- private final Class<? extends Annotation> annotationType;
- private final Scope scope;
-
- BindScopeCommand(Object source, Class<? extends Annotation> annotationType, Scope scope) {
- this.source = checkNotNull(source, "source");
- this.annotationType = checkNotNull(annotationType, "annotationType");
- this.scope = checkNotNull(scope, "scope");
- }
-
- public Object getSource() {
- return source;
- }
-
- public Class<? extends Annotation> getAnnotationType() {
- return annotationType;
- }
-
- public Scope getScope() {
- return scope;
- }
-
- public <T> T acceptVisitor(Visitor<T> visitor) {
- return visitor.visitBindScope(this);
- }
-}
diff --git a/src/com/google/inject/commands/BindScoping.java b/src/com/google/inject/commands/BindScoping.java
deleted file mode 100644
index eedaaef..0000000
--- a/src/com/google/inject/commands/BindScoping.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.commands;
-
-import com.google.inject.Scope;
-import com.google.inject.binder.ScopedBindingBuilder;
-import java.lang.annotation.Annotation;
-
-
-/**
- * Immutable snapshot of a binding scope.
- *
- * @deprecated replaced with {@link com.google.inject.spi.BindingScopingVisitor}
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-@Deprecated
-public interface BindScoping {
- void execute(ScopedBindingBuilder scopedBindingBuilder);
- boolean isEagerSingleton();
- Scope getScope();
- Class<? extends Annotation> getScopeAnnotation();
- <V> V acceptVisitor(Visitor<V> visitor);
-
- interface Visitor<V> {
- V visitEagerSingleton();
- V visitScope(Scope scope);
- V visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation);
- V visitNoScoping();
- }
-}
diff --git a/src/com/google/inject/commands/BindTarget.java b/src/com/google/inject/commands/BindTarget.java
deleted file mode 100644
index 70c0262..0000000
--- a/src/com/google/inject/commands/BindTarget.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * 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.commands;
-
-import com.google.inject.Key;
-import com.google.inject.Provider;
-import com.google.inject.binder.ConstantBindingBuilder;
-import com.google.inject.binder.LinkedBindingBuilder;
-import com.google.inject.binder.ScopedBindingBuilder;
-
-
-/**
- * A binding target, which provides instances from a specific key.
- *
- * @deprecated replaced with {@link com.google.inject.spi.BindingTargetVisitor}
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-@Deprecated
-public interface BindTarget<T> {
-
- /**
- * Execute this target against the linked binding builder.
- */
- ScopedBindingBuilder execute(LinkedBindingBuilder<T> linkedBindingBuilder);
-
- /**
- * Execute this target against the constant binding builder.
- */
- void execute(ConstantBindingBuilder builder);
-
- /**
- * Returns the bound instance, if it exists, or {@code null} if no bound value exists.
- */
- T get();
-
- Provider<? extends T> getProvider();
-
- Key<? extends Provider<? extends T>> getProviderKey();
-
- Key<? extends T> getKey();
-
- <V> V acceptVisitor(Visitor<T, V> visitor);
-
- interface Visitor<T, V> {
- V visitToInstance(T instance);
- V visitToProvider(Provider<? extends T> provider);
- V visitToProviderKey(Key<? extends Provider<? extends T>> providerKey);
- V visitToKey(Key<? extends T> key);
- V visitUntargetted();
- }
-}
diff --git a/src/com/google/inject/commands/Command.java b/src/com/google/inject/commands/Command.java
deleted file mode 100644
index 7564af2..0000000
--- a/src/com/google/inject/commands/Command.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.commands;
-
-/**
- * Immutable snapshot of a binding command.
- *
- * @deprecated replaced with {@link com.google.inject.spi.Element}
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-@Deprecated
-public interface Command {
- Object getSource();
- <T> T acceptVisitor(Visitor<T> visitor);
-
- /**
- * Visit commands.
- */
- public interface Visitor<V> {
- V visitAddMessage(AddMessageCommand command);
- V visitBindInterceptor(BindInterceptorCommand command);
- V visitBindScope(BindScopeCommand command);
- V visitRequestInjection(RequestInjectionCommand command);
- V visitRequestStaticInjection(RequestStaticInjectionCommand command);
- V visitBindConstant(BindConstantCommand command);
- V visitConvertToTypes(ConvertToTypesCommand command);
- <T> V visitBind(BindCommand<T> command);
- <T> V visitGetProvider(GetProviderCommand<T> command);
- }
-}
diff --git a/src/com/google/inject/commands/CommandRecorder.java b/src/com/google/inject/commands/CommandRecorder.java
deleted file mode 100644
index 936ec89..0000000
--- a/src/com/google/inject/commands/CommandRecorder.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/**
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkState;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.inject.AbstractModule;
-import com.google.inject.Binder;
-import com.google.inject.Key;
-import com.google.inject.Module;
-import com.google.inject.Provider;
-import com.google.inject.ProviderMethods;
-import com.google.inject.Scope;
-import com.google.inject.Stage;
-import com.google.inject.TypeLiteral;
-import com.google.inject.binder.AnnotatedBindingBuilder;
-import com.google.inject.binder.AnnotatedConstantBindingBuilder;
-import com.google.inject.internal.SourceProvider;
-import com.google.inject.matcher.Matcher;
-import com.google.inject.spi.Message;
-import com.google.inject.spi.TypeConverter;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import org.aopalliance.intercept.MethodInterceptor;
-
-/**
- * Records commands executed by a module so they can be inspected or
- * {@link CommandReplayer replayed}.
- *
- * @deprecated replaced with {@link com.google.inject.spi.Elements#getElements(Module[])}
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-@Deprecated
-public final class CommandRecorder {
- private Stage currentStage = Stage.DEVELOPMENT;
-
- /**
- * Sets the stage reported by the binder.
- */
- public void setCurrentStage(Stage currentStage) {
- this.currentStage = currentStage;
- }
-
- /**
- * Records the commands executed by {@code modules}.
- */
- public List<Command> recordCommands(Module... modules) {
- return recordCommands(Arrays.asList(modules));
- }
-
- /**
- * Records the commands executed by {@code modules}.
- */
- public List<Command> recordCommands(Iterable<? extends Module> modules) {
- RecordingBinder binder = new RecordingBinder();
- for (Module module : modules) {
- binder.install(module);
- }
- return Collections.unmodifiableList(binder.commands);
- }
-
- private class RecordingBinder implements Binder {
- private final Set<Module> modules;
- private final List<Command> commands;
- private final Object source;
- private final SourceProvider sourceProvider;
-
- private RecordingBinder() {
- modules = Sets.newHashSet();
- commands = Lists.newArrayList();
- source = null;
- sourceProvider = new SourceProvider()
- .plusSkippedClasses(CommandRecorder.class, RecordingBinder.class, AbstractModule.class);
- }
-
- /**
- * Creates a recording binder that's backed by the same configuration as
- * {@code backingBinder}.
- */
- private RecordingBinder(RecordingBinder parent, Object source, SourceProvider sourceProvider) {
- checkArgument(source == null ^ sourceProvider == null);
-
- modules = parent.modules;
- commands = parent.commands;
- this.source = source;
- this.sourceProvider = sourceProvider;
- }
-
- public void bindInterceptor(
- Matcher<? super Class<?>> classMatcher,
- Matcher<? super Method> methodMatcher,
- MethodInterceptor... interceptors) {
- commands.add(new BindInterceptorCommand(getSource(), classMatcher, methodMatcher, interceptors));
- }
-
- public void bindScope(Class<? extends Annotation> annotationType, Scope scope) {
- commands.add(new BindScopeCommand(getSource(), annotationType, scope));
- }
-
- public void requestInjection(Object... instances) {
- commands.add(new RequestInjectionCommand(getSource(), instances));
- }
-
- public void requestStaticInjection(Class<?>... types) {
- commands.add(new RequestStaticInjectionCommand(getSource(), types));
- }
-
- public void install(Module module) {
- if (modules.add(module)) {
- try {
- module.configure(this);
- } catch (RuntimeException e) {
- addError(e);
- }
- install(ProviderMethods.from(module));
- }
- }
-
- public Stage currentStage() {
- return currentStage;
- }
-
- public void addError(String message, Object... arguments) {
- commands.add(new AddMessageCommand(getSource(), message, arguments));
- }
-
- public void addError(Throwable t) {
- commands.add(new AddMessageCommand(getSource(), t));
- }
-
- public void addError(Message message) {
- commands.add(new AddMessageCommand(message));
- }
-
- public <T> BindCommand<T>.BindingBuilder bind(Key<T> key) {
- BindCommand<T> bindCommand = new BindCommand<T>(getSource(), key);
- commands.add(bindCommand);
- return bindCommand.bindingBuilder(RecordingBinder.this);
- }
-
- public <T> AnnotatedBindingBuilder<T> bind(TypeLiteral<T> typeLiteral) {
- return bind(Key.get(typeLiteral));
- }
-
- public <T> AnnotatedBindingBuilder<T> bind(Class<T> type) {
- return bind(Key.get(type));
- }
-
- public AnnotatedConstantBindingBuilder bindConstant() {
- BindConstantCommand bindConstantCommand = new BindConstantCommand(getSource());
- commands.add(bindConstantCommand);
- return bindConstantCommand.bindingBuilder(RecordingBinder.this);
- }
-
- public <T> Provider<T> getProvider(final Key<T> key) {
- final GetProviderCommand<T> command = new GetProviderCommand<T>(getSource(), key);
- commands.add(command);
- return new Provider<T>() {
- public T get() {
- Provider<T> delegate = command.getDelegate();
- checkState(delegate != null,
- "This provider cannot be used until the Injector has been created.");
- return delegate.get();
- }
-
- @Override public String toString() {
- return "Provider<" + key.getTypeLiteral() + ">";
- }
- };
- }
-
- public <T> Provider<T> getProvider(Class<T> type) {
- return getProvider(Key.get(type));
- }
-
- public void convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher,
- TypeConverter converter) {
- commands.add(new ConvertToTypesCommand(getSource(), typeMatcher, converter));
- }
-
- public Binder withSource(final Object source) {
- return new RecordingBinder(this, source, null);
- }
-
- public Binder skipSources(Class... classesToSkip) {
- // if a source is specified explicitly, we don't need to skip sources
- if (source != null) {
- return this;
- }
-
- SourceProvider newSourceProvider = sourceProvider.plusSkippedClasses(classesToSkip);
- return new RecordingBinder(this, null, newSourceProvider);
- }
-
- protected Object getSource() {
- return sourceProvider != null
- ? sourceProvider.get()
- : source;
- }
-
- @Override public String toString() {
- return "Binder";
- }
- }
-}
diff --git a/src/com/google/inject/commands/CommandReplayer.java b/src/com/google/inject/commands/CommandReplayer.java
deleted file mode 100644
index b742969..0000000
--- a/src/com/google/inject/commands/CommandReplayer.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/**
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.inject.Binder;
-import com.google.inject.Key;
-import com.google.inject.Module;
-import com.google.inject.Provider;
-import com.google.inject.binder.AnnotatedConstantBindingBuilder;
-import com.google.inject.binder.ConstantBindingBuilder;
-import com.google.inject.binder.LinkedBindingBuilder;
-import com.google.inject.binder.ScopedBindingBuilder;
-import java.util.List;
-import org.aopalliance.intercept.MethodInterceptor;
-
-/**
- * Executes commands against a binder.
- *
- * @deprecated replaced with {@link com.google.inject.spi.ModuleWriter}
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-@Deprecated
-public class CommandReplayer {
-
- /**
- * Returns a module that executes the specified commands
- * using this executing visitor.
- */
- public final Module createModule(final Iterable<? extends Command> commands) {
- return new Module() {
- public void configure(Binder binder) {
- replay(binder, commands);
- }
- };
- }
-
- /**
- * Replays {@code commands} against {@code binder}.
- */
- public final void replay(final Binder binder, Iterable<? extends Command> commands) {
- checkNotNull(binder, "binder");
- checkNotNull(commands, "commands");
-
- Command.Visitor<Void> visitor = new Command.Visitor<Void>() {
- public Void visitAddMessage(AddMessageCommand command) {
- replayAddMessageError(binder, command);
- return null;
- }
-
- public Void visitBindInterceptor(BindInterceptorCommand command) {
- replayBindInterceptor(binder, command);
- return null;
- }
-
- public Void visitBindScope(BindScopeCommand command) {
- replayBindScope(binder, command);
- return null;
- }
-
- public Void visitRequestInjection(RequestInjectionCommand command) {
- replayRequestInjection(binder, command);
- return null;
- }
-
- public Void visitRequestStaticInjection(RequestStaticInjectionCommand command) {
- replayRequestStaticInjection(binder, command);
- return null;
- }
-
- public Void visitBindConstant(BindConstantCommand command) {
- replayBindConstant(binder, command);
- return null;
- }
-
- public Void visitConvertToTypes(ConvertToTypesCommand command) {
- replayConvertToTypes(binder, command);
- return null;
- }
-
- public <T> Void visitBind(BindCommand<T> command) {
- replayBind(binder, command);
- return null;
- }
-
- public <T> Void visitGetProvider(GetProviderCommand<T> command) {
- replayGetProvider(binder, command);
- return null;
- }
- };
-
- for (Command command : commands) {
- command.acceptVisitor(visitor);
- }
- }
-
- public void replayAddMessageError(final Binder binder, final AddMessageCommand command) {
- binder.withSource(command.getSource()).addError(command.getMessage());
- }
-
- public void replayBindInterceptor(final Binder binder, final BindInterceptorCommand command) {
- List<MethodInterceptor> interceptors = command.getInterceptors();
- binder.withSource(command.getSource()).bindInterceptor(
- command.getClassMatcher(), command.getMethodMatcher(),
- interceptors.toArray(new MethodInterceptor[interceptors.size()]));
- }
-
- public void replayBindScope(final Binder binder, final BindScopeCommand command) {
- binder.withSource(command.getSource()).bindScope(
- command.getAnnotationType(), command.getScope());
- }
-
- public void replayRequestInjection(final Binder binder,
- final RequestInjectionCommand command) {
- List<Object> objects = command.getInstances();
- binder.withSource(command.getSource())
- .requestInjection(objects.toArray());
- }
-
- public void replayRequestStaticInjection(final Binder binder,
- final RequestStaticInjectionCommand command) {
- List<Class> types = command.getTypes();
- binder.withSource(command.getSource())
- .requestStaticInjection(types.toArray(new Class[types.size()]));
- }
-
- public void replayBindConstant(final Binder binder, final BindConstantCommand command) {
- AnnotatedConstantBindingBuilder constantBindingBuilder
- = binder.withSource(command.getSource()).bindConstant();
-
- Key<Object> key = command.getKey();
- ConstantBindingBuilder builder = key.getAnnotation() != null
- ? constantBindingBuilder.annotatedWith(key.getAnnotation())
- : constantBindingBuilder.annotatedWith(key.getAnnotationType());
-
- command.getTarget().execute(builder);
- }
-
- public void replayConvertToTypes(final Binder binder, final ConvertToTypesCommand command) {
- binder.withSource(command.getSource())
- .convertToTypes(command.getTypeMatcher(), command.getTypeConverter());
- }
-
- public <T> void replayBind(final Binder binder, final BindCommand<T> command) {
- LinkedBindingBuilder<T> lbb = binder.withSource(command.getSource()).bind(command.getKey());
-
- BindTarget<T> bindTarget = command.getTarget();
- ScopedBindingBuilder sbb = bindTarget != null
- ? bindTarget.execute(lbb)
- : lbb;
-
- BindScoping scoping = command.getScoping();
- if (scoping != null) {
- scoping.execute(sbb);
- }
- }
-
- public <T> void replayGetProvider(final Binder binder, final GetProviderCommand<T> command) {
- Provider<T> provider = binder.withSource(command.getSource()).getProvider(command.getKey());
- command.initDelegate(provider);
- }
-}
diff --git a/src/com/google/inject/commands/ConvertToTypesCommand.java b/src/com/google/inject/commands/ConvertToTypesCommand.java
deleted file mode 100644
index c1276a1..0000000
--- a/src/com/google/inject/commands/ConvertToTypesCommand.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.inject.TypeLiteral;
-import com.google.inject.matcher.Matcher;
-import com.google.inject.spi.TypeConverter;
-
-/**
- * Immutable snapshot of a request to convert binder types.
- *
- * @deprecated replaced with {@link com.google.inject.spi.TypeConverterBinding}
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-@Deprecated
-public final class ConvertToTypesCommand implements Command {
- private final Object source;
- private final Matcher<? super TypeLiteral<?>> typeMatcher;
- private final TypeConverter typeConverter;
-
- ConvertToTypesCommand(Object source, Matcher<? super TypeLiteral<?>> typeMatcher,
- TypeConverter typeConverter) {
- this.source = checkNotNull(source, "source");
- this.typeMatcher = checkNotNull(typeMatcher, "typeMatcher");
- this.typeConverter = checkNotNull(typeConverter, "typeConverter");
- }
-
- public Object getSource() {
- return source;
- }
-
- public Matcher<? super TypeLiteral<?>> getTypeMatcher() {
- return typeMatcher;
- }
-
- public TypeConverter getTypeConverter() {
- return typeConverter;
- }
-
- public <T> T acceptVisitor(Visitor<T> visitor) {
- return visitor.visitConvertToTypes(this);
- }
-}
diff --git a/src/com/google/inject/commands/DefaultCommandVisitor.java b/src/com/google/inject/commands/DefaultCommandVisitor.java
deleted file mode 100644
index 85e8210..0000000
--- a/src/com/google/inject/commands/DefaultCommandVisitor.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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.commands;
-
-/**
- * No-op visitor for subclassing. All interface methods simply delegate to
- * {@link #visitCommand(Command)}, returning its result.
- *
- * @deprecated replaced with {@link com.google.inject.spi.DefaultElementVisitor}
- *
- * @author sberlin@gmail.com (Sam Berlin)
- */
-@Deprecated
-public class DefaultCommandVisitor<V> implements Command.Visitor<V> {
-
- protected DefaultCommandVisitor() {}
-
- /**
- * Visit {@code command} and return a result.
- */
- public V visitCommand(Command command) {
- return null;
- }
-
- public V visitAddMessage(AddMessageCommand command) {
- return visitCommand(command);
- }
-
- public <T> V visitBind(BindCommand<T> command) {
- return visitCommand(command);
- }
-
- public V visitBindConstant(BindConstantCommand command) {
- return visitCommand(command);
- }
-
- public V visitBindInterceptor(BindInterceptorCommand command) {
- return visitCommand(command);
- }
-
- public V visitBindScope(BindScopeCommand command) {
- return visitCommand(command);
- }
-
- public V visitConvertToTypes(ConvertToTypesCommand command) {
- return visitCommand(command);
- }
-
- public <T> V visitGetProvider(GetProviderCommand<T> command) {
- return visitCommand(command);
- }
-
- public V visitRequestInjection(RequestInjectionCommand command) {
- return visitCommand(command);
- }
-
- public V visitRequestStaticInjection(
- RequestStaticInjectionCommand command) {
- return visitCommand(command);
- }
-}
diff --git a/src/com/google/inject/commands/GetProviderCommand.java b/src/com/google/inject/commands/GetProviderCommand.java
deleted file mode 100644
index 7854eed..0000000
--- a/src/com/google/inject/commands/GetProviderCommand.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import com.google.inject.Key;
-import com.google.inject.Provider;
-
-/**
- * Immutable snapshot of a request for a provider.
- *
- * @deprecated replaced with {@link com.google.inject.spi.ProviderLookup}
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-@Deprecated
-public final class GetProviderCommand<T> implements Command {
- private final Object source;
- private final Key<T> key;
- private Provider<T> delegate;
-
- GetProviderCommand(Object source, Key<T> key) {
- this.source = checkNotNull(source, "source");
- this.key = checkNotNull(key, "key");
- }
-
- public Object getSource() {
- return source;
- }
-
- public Key<T> getKey() {
- return key;
- }
-
- public <T> T acceptVisitor(Visitor<T> visitor) {
- return visitor.visitGetProvider(this);
- }
-
- public void initDelegate(Provider<T> delegate) {
- checkState(this.delegate == null, "delegate already initialized");
- checkNotNull(delegate, "delegate");
- this.delegate = delegate;
- }
-
- /**
- * Returns the delegate provider, or {@code null} if it has not yet been initialized. The delegate
- * will be initialized when this command is replayed, or otherwise used to create an injector.
- */
- public Provider<T> getDelegate() {
- return delegate;
- }
-}
diff --git a/src/com/google/inject/commands/RequestInjectionCommand.java b/src/com/google/inject/commands/RequestInjectionCommand.java
deleted file mode 100644
index 60ab2f6..0000000
--- a/src/com/google/inject/commands/RequestInjectionCommand.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * 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.commands;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.common.collect.ImmutableList;
-import java.util.List;
-
-/**
- * Immutable snapshot of a request for injection.
- *
- * @deprecated replaced with {@link com.google.inject.spi.InjectionRequest}
- *
- * @author mikeward@google.com (Mike Ward)
- */
-@Deprecated
-public final class RequestInjectionCommand implements Command {
- private Object source;
- private List<Object> instances;
-
- public RequestInjectionCommand(Object source, Object[] instances) {
- this.source = checkNotNull(source, "source");
- this.instances = ImmutableList.of(instances);
- }
-
- public Object getSource() {
- return source;
- }
-
- public List<Object> getInstances() {
- return instances;
- }
-
- public <T> T acceptVisitor(Visitor<T> visitor) {
- return visitor.visitRequestInjection(this);
- }
-}
diff --git a/src/com/google/inject/commands/RequestStaticInjectionCommand.java b/src/com/google/inject/commands/RequestStaticInjectionCommand.java
deleted file mode 100644
index 0fd15a6..0000000
--- a/src/com/google/inject/commands/RequestStaticInjectionCommand.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * 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.commands;
-
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.common.collect.ImmutableList;
-import java.util.List;
-
-/**
- * Immutable snapshot of a request for static injection.
- *
- * @deprecated replaced with {@link com.google.inject.spi.StaticInjectionRequest}
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-@Deprecated
-public final class RequestStaticInjectionCommand implements Command {
- private final Object source;
- private final List<Class> types;
-
- RequestStaticInjectionCommand(Object source, Class[] types) {
- this.source = checkNotNull(source, "source");
- this.types = ImmutableList.of(types);
- }
-
- public Object getSource() {
- return source;
- }
-
- public List<Class> getTypes() {
- return types;
- }
-
- public <T> T acceptVisitor(Visitor<T> visitor) {
- return visitor.visitRequestStaticInjection(this);
- }
-}
diff --git a/src/com/google/inject/commands/package-info.java b/src/com/google/inject/commands/package-info.java
deleted file mode 100644
index c4fd670..0000000
--- a/src/com/google/inject/commands/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Extension for recording, reviewing and instrumenting the commands executed
- * by a module.
- */
-package com.google.inject.commands;
\ No newline at end of file
diff --git a/src/com/google/inject/spi/oldversion/BindingVisitor.java b/src/com/google/inject/spi/oldversion/BindingVisitor.java
deleted file mode 100644
index 0b4d817..0000000
--- a/src/com/google/inject/spi/oldversion/BindingVisitor.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Copyright (C) 2007 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.spi.oldversion;
-
-/**
- * Visits bindings. Pass an implementation of {@code BindingVisitor} to
- * {@link OldVersionBinding#accept(BindingVisitor)} and the binding
- * will call back to the appropriate visitor method for its type.
- *
- * @deprecated replaced with {@link com.google.inject.spi.ElementVisitor}
- *
- * @author crazybob@google.com (Bob Lee)
- */
-@Deprecated
-public interface BindingVisitor<T> {
-
- /**
- * Visits a linked binding.
- */
- void visit(LinkedBinding<? extends T> binding);
-
- /**
- * Visits a binding to an instance.
- */
- void visit(InstanceBinding<? extends T> binding);
-
- /**
- * Visits a binding to a provider instance.
- */
- void visit(ProviderInstanceBinding<? extends T> binding);
-
- /**
- * Visits a binding which resolves instances from a bound provider.
- */
- void visit(LinkedProviderBinding<? extends T> binding);
-
- /**
- * Visits a synthetic binding to the provider from a binding.
- */
- // To provide any more type safety, the compiler would have to know that
- // T extends Provider<X>.
- void visit(ProviderBinding<?> binding);
-
- /**
- * Visits a class binding.
- */
- void visit(ClassBinding<? extends T> binding);
-
- /**
- * Visits a converted constant binding.
- */
- void visit(ConvertedConstantBinding<? extends T> binding);
-}
diff --git a/src/com/google/inject/spi/oldversion/ClassBinding.java b/src/com/google/inject/spi/oldversion/ClassBinding.java
deleted file mode 100644
index a0d221e..0000000
--- a/src/com/google/inject/spi/oldversion/ClassBinding.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (C) 2007 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.spi.oldversion;
-
-import com.google.inject.spi.HasInjections;
-
-/**
- * A binding to a concrete, injectable class. Instantiates new instances of the
- * class and injects its members.
- *
- * <p>Example: {@code bind(Concrete.class);}
- *
- * @deprecated replaced with {@link
- * com.google.inject.spi.BindingTargetVisitor#visitConstructor(java.lang.reflect.Constructor)}
- *
- * @author crazybob@google.com (Bob Lee)
- */
-@Deprecated
-public interface ClassBinding<T> extends OldVersionBinding<T>, HasInjections {
-
- /**
- * Gets the class associated with this binding.
- */
- Class<T> getBoundClass();
-
- // TODO: Expose information about method and constructor interceptors.
-}
diff --git a/src/com/google/inject/spi/oldversion/ConvertedConstantBinding.java b/src/com/google/inject/spi/oldversion/ConvertedConstantBinding.java
deleted file mode 100644
index 6af2850..0000000
--- a/src/com/google/inject/spi/oldversion/ConvertedConstantBinding.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2007 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.spi.oldversion;
-
-/**
- * A binding which was converted from a string contant.
- *
- * @deprecated replaced with {@link
- * com.google.inject.spi.BindingTargetVisitor#visitConvertedConstant(Object)}
- *
- * @author crazybob@google.com (Bob Lee)
- */
-@Deprecated
-public interface ConvertedConstantBinding<T> extends OldVersionBinding<T> {
-
- /**
- * Gets the binding that we converted to create this binding.
- */
- OldVersionBinding<String> getOriginal();
-
- /**
- * Gets the constant value associated with this binding.
- */
- T getValue();
-}
diff --git a/src/com/google/inject/spi/oldversion/InstanceBinding.java b/src/com/google/inject/spi/oldversion/InstanceBinding.java
deleted file mode 100644
index 701b89d..0000000
--- a/src/com/google/inject/spi/oldversion/InstanceBinding.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (C) 2007 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.spi.oldversion;
-
-import com.google.inject.spi.HasInjections;
-
-/**
- * A binding to a single instance or constant.
- *
- * <p>Examples: <pre>
- * bind(Runnable.class).toInstance(new MyRunnable());
- * bindConstant().annotatedWith(PoolSize.class).to(5);
- * </pre>
- *
- * @deprecated replaced with {@link
- * com.google.inject.spi.BindingTargetVisitor#visitInstance(Object)}
- *
- * @author crazybob@google.com (Bob Lee)
- */
-@Deprecated
-public interface InstanceBinding<T> extends OldVersionBinding<T>, HasInjections {
-
- /**
- * Gets the instance associated with this binding.
- */
- T getInstance();
-}
diff --git a/src/com/google/inject/spi/oldversion/LinkedBinding.java b/src/com/google/inject/spi/oldversion/LinkedBinding.java
deleted file mode 100644
index 32fd6b8..0000000
--- a/src/com/google/inject/spi/oldversion/LinkedBinding.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright (C) 2007 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.spi.oldversion;
-
-/**
- * A binding that links to another binding.
- *
- * <p>Example: {@code bind(Collection.class).to(List.class);}
- *
- * @deprecated replaced with {@link
- * com.google.inject.spi.BindingTargetVisitor#visitKey(com.google.inject.Key)}
- *
- * @author crazybob@google.com (Bob Lee)
- */
-@Deprecated
-public interface LinkedBinding<T> extends OldVersionBinding<T> {
-
- /**
- * Gets the target of this link.
- */
- OldVersionBinding<? extends T> getTargetBinding();
-}
diff --git a/src/com/google/inject/spi/oldversion/LinkedProviderBinding.java b/src/com/google/inject/spi/oldversion/LinkedProviderBinding.java
deleted file mode 100644
index ef77413..0000000
--- a/src/com/google/inject/spi/oldversion/LinkedProviderBinding.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (C) 2007 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.spi.oldversion;
-
-import com.google.inject.Provider;
-
-/**
- * A binding which links to a provider binding which provides instances for
- * this binding.
- *
- * <p>Example: {@code bind(Foo.class).toProvider(FooProvider.class);}
- *
- * @deprecated replaced with {@link
- * com.google.inject.spi.BindingTargetVisitor#visitProviderKey(com.google.inject.Key)}
- *
- * @author crazybob@google.com (Bob Lee)
- */
-@Deprecated
-public interface LinkedProviderBinding<T> extends OldVersionBinding<T> {
-
- /**
- * Gets the binding for the provider of this binding.
- */
- OldVersionBinding<? extends Provider<? extends T>> getTargetProvider();
-}
diff --git a/src/com/google/inject/spi/oldversion/OldVersionBinding.java b/src/com/google/inject/spi/oldversion/OldVersionBinding.java
deleted file mode 100644
index 731f294..0000000
--- a/src/com/google/inject/spi/oldversion/OldVersionBinding.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (C) 2006 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.spi.oldversion;
-
-import com.google.inject.Binding;
-import com.google.inject.Scope;
-
-/**
- * A mapping from a key (type and optional annotation) to a provider of
- * instances of that type. This interface is part of the {@link com.google.inject.Injector}
- * introspection API and is intended primary for use by tools.
- *
- * @deprecated replaced with {@link com.google.inject.Binding}
- *
- * @author crazybob@google.com (Bob Lee)
- */
-@Deprecated
-public interface OldVersionBinding<T> extends Binding<T> {
-
- /**
- * Gets the synthetic binding to this binding's Provider.
- */
- ProviderBinding<T> getProviderBinding();
-
- /**
- * Returns the scope applied by this binding.
- */
- Scope getScope();
-
- /**
- * Accepts a binding visitor. Invokes the visitor method specific to this
- * binding's type.
- *
- * @param visitor to call back on
- */
- void accept(BindingVisitor<? super T> visitor);
-}
diff --git a/src/com/google/inject/spi/oldversion/ProviderBinding.java b/src/com/google/inject/spi/oldversion/ProviderBinding.java
deleted file mode 100644
index b1124e3..0000000
--- a/src/com/google/inject/spi/oldversion/ProviderBinding.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2007 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.spi.oldversion;
-
-import com.google.inject.Provider;
-
-/**
- * A synthetic binding to {@code Provider<T>} which exists for any binding to
- * {@code T}.
- *
- * @deprecated replaced with {@link
- * com.google.inject.spi.BindingTargetVisitor#visitProviderBinding(com.google.inject.Key)}
- *
- * @author crazybob@google.com (Bob Lee)
- */
-@Deprecated
-public interface ProviderBinding<T> extends OldVersionBinding<Provider<T>> {
-
- /**
- * Gets the binding from which the provider comes.
- */
- OldVersionBinding<T> getTargetBinding();
-}
diff --git a/src/com/google/inject/spi/oldversion/ProviderInstanceBinding.java b/src/com/google/inject/spi/oldversion/ProviderInstanceBinding.java
deleted file mode 100644
index 03c4b0e..0000000
--- a/src/com/google/inject/spi/oldversion/ProviderInstanceBinding.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (C) 2007 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.spi.oldversion;
-
-import com.google.inject.Provider;
-import com.google.inject.spi.HasInjections;
-
-/**
- * A binding to a single provider instance.
- *
- * <p>Example: {@code bind(Foo.class).toProvider(new FooProvider());}
- *
- * @deprecated replaced with {@link
- * com.google.inject.spi.BindingTargetVisitor#visitProvider(com.google.inject.Provider)}
- *
- * @author crazybob@google.com (Bob Lee)
- */
-@Deprecated
-public interface ProviderInstanceBinding<T> extends OldVersionBinding<T>, HasInjections {
-
- /**
- * Gets the raw (unscoped) provider instance associated with this binding.
- */
- Provider<? extends T> getProviderInstance();
-}
diff --git a/test/com/google/inject/BindingTest.java b/test/com/google/inject/BindingTest.java
index 124bb6b..dbf63da 100644
--- a/test/com/google/inject/BindingTest.java
+++ b/test/com/google/inject/BindingTest.java
@@ -18,16 +18,6 @@
import static com.google.inject.Asserts.assertContains;
import com.google.inject.name.Names;
-import com.google.inject.spi.InjectionPoint;
-import com.google.inject.spi.oldversion.BindingVisitor;
-import com.google.inject.spi.oldversion.ClassBinding;
-import com.google.inject.spi.oldversion.ConvertedConstantBinding;
-import com.google.inject.spi.oldversion.InstanceBinding;
-import com.google.inject.spi.oldversion.LinkedBinding;
-import com.google.inject.spi.oldversion.LinkedProviderBinding;
-import com.google.inject.spi.oldversion.OldVersionBinding;
-import com.google.inject.spi.oldversion.ProviderBinding;
-import com.google.inject.spi.oldversion.ProviderInstanceBinding;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -38,14 +28,6 @@
*/
public class BindingTest extends TestCase {
- public void testDependencies() {
- Injector injector = Guice.createInjector();
- ClassBinding<Dependent> binding
- = (ClassBinding<Dependent>) injector.getBinding(Dependent.class);
- Collection<InjectionPoint<?>> dependencies = binding.getInjectionPoints();
- assertEquals(4, dependencies.size());
- }
-
static class Dependent {
@Inject A a;
@Inject Dependent(A a, B b) {}
@@ -64,32 +46,8 @@
static class A { @Inject B b; }
static class B { @Inject A a; }
- public void testProviderBinding() {
- Injector injector = Guice.createInjector();
- OldVersionBinding<Bob> bobBinding = (OldVersionBinding) injector.getBinding(Bob.class);
- assertTrue(bobBinding.getProvider().get() instanceof Bob);
- OldVersionBinding<Provider<Bob>> bobProviderBinding = bobBinding.getProviderBinding();
- assertTrue(bobProviderBinding.getProvider().get().get() instanceof Bob);
- OldVersionBinding<Provider<Provider<Bob>>> bobProviderProviderBinding
- = bobProviderBinding.getProviderBinding();
- assertTrue(bobProviderProviderBinding.getProvider().get().get().get()
- instanceof Bob);
- }
-
static class Bob {}
- public void testVisitor() {
- MyVisitor myVisitor = new MyVisitor();
-
- Injector injector = Guice.createInjector(new MyModule());
-
- for (Binding<?> binding : injector.getBindings().values()) {
- ((OldVersionBinding) binding).accept(myVisitor);
- }
-
- myVisitor.verify();
- }
-
static class MyModule extends AbstractModule {
protected void configure() {
@@ -131,77 +89,6 @@
public static class Bar {}
- static class MyVisitor implements BindingVisitor<Object> {
-
- boolean linkedVisited;
-
- public void visit(LinkedBinding<?> linkedBinding) {
- linkedVisited = true;
- assertEquals(Runnable.class,
- linkedBinding.getTargetBinding().getKey().getTypeLiteral().getType());
- assertEquals(Scopes.SINGLETON, linkedBinding.getScope());
- }
-
- boolean sawRunnable;
- boolean constantVisited;
-
- public void visit(InstanceBinding<?> instanceBinding) {
- if (instanceBinding.getInstance() instanceof Runnable) {
- sawRunnable = true;
-
- } else if (instanceBinding.getInstance() instanceof String) {
- constantVisited = true;
- assertEquals("Bob", instanceBinding.getInstance());
- assertEquals(Key.get(String.class, Names.named("name")),
- instanceBinding.getKey());
- }
- assertEquals(Scopes.NO_SCOPE, instanceBinding.getScope());
- }
-
- boolean providerInstanceVisited;
-
- public void visit(ProviderInstanceBinding<?> providerInstanceBinding) {
- if (providerInstanceBinding.getKey().getRawType() == Foo.class) {
- providerInstanceVisited = true;
- assertTrue(providerInstanceBinding.getProvider().get() instanceof Foo);
- assertEquals(Scopes.SINGLETON, providerInstanceBinding.getScope());
- }
- }
-
- boolean providerVisited;
-
- public void visit(LinkedProviderBinding<?> linkedProviderBinding) {
- providerVisited = true;
- assertEquals(FooProvider.class,
- linkedProviderBinding.getTargetProvider().getKey().getRawType());
- }
-
- boolean classVisitied;
-
- public void visit(ClassBinding<?> classBinding) {
- if (classBinding.getKey().getRawType().equals(Bar.class)) {
- classVisitied = true;
- assertEquals(Scopes.SINGLETON, classBinding.getScope());
- }
- }
-
- public void visit(ProviderBinding<?> binding) {
- }
-
- public void visit(
- ConvertedConstantBinding<? extends Object> convertedConstantBinding) {
- }
-
- void verify() {
- assertTrue(linkedVisited);
- assertTrue(sawRunnable);
- assertTrue(providerInstanceVisited);
- assertTrue(providerVisited);
- assertTrue(classVisitied);
- assertTrue(constantVisited);
- }
- }
-
public void testBindToUnboundLinkedBinding() {
try {
Guice.createInjector(new AbstractModule() {
diff --git a/test/com/google/inject/LoggerInjectionTest.java b/test/com/google/inject/LoggerInjectionTest.java
index cd71657..cc8e693 100644
--- a/test/com/google/inject/LoggerInjectionTest.java
+++ b/test/com/google/inject/LoggerInjectionTest.java
@@ -2,7 +2,6 @@
import static com.google.inject.Asserts.assertContains;
import com.google.inject.name.Names;
-import com.google.inject.spi.oldversion.ProviderInstanceBinding;
import java.util.logging.Logger;
import junit.framework.TestCase;
@@ -26,8 +25,6 @@
assertNull(injector.getInstance(Logger.class).getName());
assertNull(injector.getProvider(Logger.class).get().getName());
assertNull(injector.getBinding(Logger.class).getProvider().get().getName());
- assertNull(((ProviderInstanceBinding<Logger>) injector.getBinding(Logger.class))
- .getProviderInstance().get().getName());
assertEquals("Provider<Logger>", injector.getProvider(Logger.class).toString());
}