diff --git a/org.springframework.config.java/src/main/java/org/springframework/config/java/NoOpInterceptor.java b/org.springframework.config.java/src/main/java/org/springframework/config/java/NoOpInterceptor.java deleted file mode 100644 index c6a579619fe..00000000000 --- a/org.springframework.config.java/src/main/java/org/springframework/config/java/NoOpInterceptor.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2002-2009 the original author or authors. - * - * 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 org.springframework.config.java; - -import java.lang.reflect.Method; - -import net.sf.cglib.proxy.MethodInterceptor; -import net.sf.cglib.proxy.MethodProxy; - - -public class NoOpInterceptor implements MethodInterceptor { - - public static final NoOpInterceptor INSTANCE = new NoOpInterceptor(); - - public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable { - return null; - } - -} diff --git a/org.springframework.config.java/src/main/java/org/springframework/config/java/StandardScopes.java b/org.springframework.config.java/src/main/java/org/springframework/config/java/StandardScopes.java index bc79b411759..5abfce7a564 100644 --- a/org.springframework.config.java/src/main/java/org/springframework/config/java/StandardScopes.java +++ b/org.springframework.config.java/src/main/java/org/springframework/config/java/StandardScopes.java @@ -18,18 +18,17 @@ package org.springframework.config.java; /** * Enumerates the names of the scopes supported out of the box in Spring. - *

- * Not modeled as an actual java enum because annotations that accept a scope attribute must - * allow for user-defined scope names. Given that java enums are not extensible, these must - * remain simple string constants. + * + *

Not modeled as an actual java enum because annotations that accept a scope attribute + * must allow for user-defined scope names. Given that java enums are not extensible, these + * must remain simple string constants. * * @author Chris Beams * @since 3.0 */ public class StandardScopes { - private StandardScopes() { - } + private StandardScopes() { } public static final String SINGLETON = "singleton"; diff --git a/org.springframework.config.java/src/main/java/org/springframework/config/java/internal/enhancement/ConfigurationEnhancer.java b/org.springframework.config.java/src/main/java/org/springframework/config/java/internal/enhancement/ConfigurationEnhancer.java index 7441f566cd7..e74e4d3e2bd 100644 --- a/org.springframework.config.java/src/main/java/org/springframework/config/java/internal/enhancement/ConfigurationEnhancer.java +++ b/org.springframework.config.java/src/main/java/org/springframework/config/java/internal/enhancement/ConfigurationEnhancer.java @@ -29,21 +29,19 @@ import net.sf.cglib.core.DefaultGeneratorStrategy; import net.sf.cglib.proxy.Callback; import net.sf.cglib.proxy.CallbackFilter; import net.sf.cglib.proxy.Enhancer; +import net.sf.cglib.proxy.MethodInterceptor; +import net.sf.cglib.proxy.MethodProxy; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.objectweb.asm.ClassAdapter; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; -import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.config.java.BeanDefinitionRegistrar; import org.springframework.config.java.BeanMethod; import org.springframework.config.java.Configuration; -import org.springframework.config.java.ConfigurationClass; -import org.springframework.config.java.ConfigurationModel; -import org.springframework.config.java.NoOpInterceptor; import org.springframework.config.java.ext.BeanMethodInterceptor; import org.springframework.config.java.ext.BeanRegistrar; @@ -85,15 +83,13 @@ public class ConfigurationEnhancer { */ public ConfigurationEnhancer(DefaultListableBeanFactory beanFactory) { notNull(beanFactory, "beanFactory must be non-null"); - //notNull(model, "model must be non-null"); - - //populateRegistrarsAndCallbacks(beanFactory, model); registrars.add(new BeanRegistrar()); BeanMethodInterceptor beanMethodInterceptor = new BeanMethodInterceptor(); beanMethodInterceptor.setBeanFactory(beanFactory); callbackInstances.add(beanMethodInterceptor); + // add no-op default registrar and method interceptor registrars.add(new BeanDefinitionRegistrar() { public boolean accepts(Method method) { @@ -104,48 +100,15 @@ public class ConfigurationEnhancer { // no-op } }); - callbackInstances.add(NoOpInterceptor.INSTANCE); - - for (Callback callback : callbackInstances) - callbackTypes.add(callback.getClass()); - } + callbackInstances.add(new MethodInterceptor() { - - /** - * Reads the contents of {@code model} in order to populate {@link #registrars}, - * {@link #callbackInstances} and {@link #callbackTypes} appropriately. - * - * @see #callbackFilter - */ - private void populateRegistrarsAndCallbacks(DefaultListableBeanFactory beanFactory, - ConfigurationModel model) { - - for (ConfigurationClass configClass : model.getAllConfigurationClasses()) { - for (BeanMethod method : configClass.getMethods()) { - registrars.add(new BeanRegistrar()); - - Callback callback = new BeanMethodInterceptor(); - - if (callback instanceof BeanFactoryAware) - ((BeanFactoryAware) callback).setBeanFactory(beanFactory); - - callbackInstances.add(callback); - } - } - - // register a 'catch-all' registrar - registrars.add(new BeanDefinitionRegistrar() { - - public boolean accepts(Method method) { - return true; - } - - public void register(BeanMethod method, BeanDefinitionRegistry registry) { - // no-op - } + public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) + throws Throwable { + return null; + } + }); - callbackInstances.add(NoOpInterceptor.INSTANCE); - + for (Callback callback : callbackInstances) callbackTypes.add(callback.getClass()); } diff --git a/org.springframework.config.java/src/test/java/org/springframework/config/java/support/ConfigurationPostProcessorTests.java b/org.springframework.config.java/src/test/java/org/springframework/config/java/support/ConfigurationPostProcessorTests.java index e16f03c04e5..309efdad079 100644 --- a/org.springframework.config.java/src/test/java/org/springframework/config/java/support/ConfigurationPostProcessorTests.java +++ b/org.springframework.config.java/src/test/java/org/springframework/config/java/support/ConfigurationPostProcessorTests.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2009 the original author or authors. + * + * 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 org.springframework.config.java.support; import static org.hamcrest.CoreMatchers.*; @@ -13,8 +28,9 @@ import org.springframework.config.java.Configuration; import org.springframework.config.java.ext.Bean; import org.springframework.util.ClassUtils; + /** - * Unit tests for {@link ConfigurationClassPostProcessor} + * Unit tests for {@link ConfigurationClassPostProcessor}. * * @author Chris Beams */