New names for the core elements:
- Binding
- TypeConverterBinding
- ScopeBinding
- InterceptorBinding
- InjectionRequest
- StaticInjectionRequest
- ProviderLookup
- Message
The only names I'm unhappy with are ScopeBinding and TypeConverterBinding, since these have nothing to do with the other Binding type. I was also considering TypeConverterRegistration and ScopeRegistration, but the word registration makes me feel icky.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@578 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/src/com/google/inject/ElementProcessor.java b/src/com/google/inject/ElementProcessor.java
deleted file mode 100644
index b2d55df..0000000
--- a/src/com/google/inject/ElementProcessor.java
+++ /dev/null
@@ -1,95 +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;
-
-import com.google.inject.internal.Errors;
-import com.google.inject.spi.BindInterceptor;
-import com.google.inject.spi.BindScope;
-import com.google.inject.spi.ConvertToTypes;
-import com.google.inject.spi.Element;
-import com.google.inject.spi.GetProvider;
-import com.google.inject.spi.Message;
-import com.google.inject.spi.RequestInjection;
-import com.google.inject.spi.RequestStaticInjection;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Abstract base class for creating an injector from module elements.
- *
- * <p>Extending classes must return {@code true} from any overridden
- * {@code visit*()} methods, in order for the element processor to remove the
- * handled element.
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-abstract class ElementProcessor implements Element.Visitor<Boolean> {
-
- protected Errors errors;
-
- protected ElementProcessor(Errors errors) {
- this.errors = errors;
- }
-
- public void processCommands(List<Element> elements) {
- Errors errorsAnyElement = this.errors;
- try {
- for (Iterator<Element> i = elements.iterator(); i.hasNext(); ) {
- Element element = i.next();
- this.errors = errorsAnyElement.withSource(element.getSource());
- Boolean allDone = element.acceptVisitor(this);
- if (allDone) {
- i.remove();
- }
- }
- } finally {
- this.errors = errorsAnyElement;
- }
- }
-
- public Boolean visitMessage(Message message) {
- return false;
- }
-
- public Boolean visitBindInterceptor(BindInterceptor bindInterceptor) {
- return false;
- }
-
- public Boolean visitBindScope(BindScope bindScope) {
- return false;
- }
-
- public Boolean visitRequestInjection(RequestInjection requestInjection) {
- return false;
- }
-
- public Boolean visitRequestStaticInjection(RequestStaticInjection requestStaticInjection) {
- return false;
- }
-
- public Boolean visitConvertToTypes(ConvertToTypes convertToTypes) {
- return false;
- }
-
- public <T> Boolean visitBinding(Binding<T> binding) {
- return false;
- }
-
- public <T> Boolean visitGetProvider(GetProvider<T> getProvider) {
- return false;
- }
-}
diff --git a/src/com/google/inject/GetProviderProcessor.java b/src/com/google/inject/GetProviderProcessor.java
deleted file mode 100644
index b1bd696..0000000
--- a/src/com/google/inject/GetProviderProcessor.java
+++ /dev/null
@@ -1,49 +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;
-
-import com.google.inject.internal.Errors;
-import com.google.inject.internal.ErrorsException;
-import com.google.inject.spi.GetProvider;
-
-/**
- * Handles {@link Binder#getProvider} commands.
- *
- * @author crazybob@google.com (Bob Lee)
- * @author jessewilson@google.com (Jesse Wilson)
- */
-class GetProviderProcessor extends ElementProcessor {
-
- private final InjectorImpl injector;
-
- GetProviderProcessor(Errors errors, InjectorImpl injector) {
- super(errors);
- this.injector = injector;
- }
-
- @Override public <T> Boolean visitGetProvider(GetProvider<T> command) {
- // ensure the provider can be created
- try {
- Provider<T> provider = injector.getProviderOrThrow(command.getKey(), errors);
- command.initDelegate(provider);
- } catch (ErrorsException e) {
- errors.merge(e.getErrors()); // TODO: source
- }
-
- return true;
- }
-}
diff --git a/src/com/google/inject/spi/GetProvider.java b/src/com/google/inject/spi/GetProvider.java
deleted file mode 100644
index c6852a8..0000000
--- a/src/com/google/inject/spi/GetProvider.java
+++ /dev/null
@@ -1,64 +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.spi;
-
-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.
- *
- * @author jessewilson@google.com (Jesse Wilson)
- */
-public final class GetProvider<T> implements Element {
- private final Object source;
- private final Key<T> key;
- private Provider<T> delegate;
-
- GetProvider(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;
- }
-}