提交 5de6e2c3 编写于 作者: C Chris Beams

+ Eliminated support for @Extension methods for now

+ Consolidated all remaining supporting classes into .support package, eliminating .internal.*
+ 7 public types remain
上级 faffd986
/*
* Copyright 2002-2008 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.plugin;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.core.Ordered;
/**
* TODO: JAVADOC
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
@Inherited
public @interface Extension {
/**
* The class that handles this plugin.
*/
// TODO: SJC-242 rename to handlerType / handlerClass
Class<? extends ExtensionAnnotationBeanDefinitionRegistrar<?>> handler();
/**
* The order in which this plugin will be processed relative to others. Per the
* semantics of {@link Ordered}, lower integer values will be treated as higher
* priority.
*
* @see Ordered
*/
int order() default 0;
}
/*
* Copyright 2002-2008 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.plugin;
import java.lang.annotation.Annotation;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
/**
* Registers bean definitions based on {@link Extension} metadata
*/
public interface ExtensionAnnotationBeanDefinitionRegistrar<A extends Annotation> {
/**
*
*/
void handle(A annotation, BeanDefinitionRegistry registry);
}
......@@ -22,8 +22,6 @@ import org.springframework.beans.factory.parsing.ProblemReporter;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.config.java.Bean;
import org.springframework.config.java.Configuration;
import org.springframework.config.java.ConfigurationModel;
import org.springframework.config.java.internal.parsing.ConfigurationParser;
/**
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.enhancement;
package org.springframework.config.java.support;
import java.lang.reflect.Method;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.enhancement;
package org.springframework.config.java.support;
import net.sf.cglib.asm.Constants;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.parsing;
package org.springframework.config.java.support;
import org.objectweb.asm.AnnotationVisitor;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.parsing;
package org.springframework.config.java.support;
import java.io.IOException;
import java.io.InputStream;
......@@ -22,7 +22,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.commons.EmptyVisitor;
import org.springframework.config.java.Util;
/**
......
package org.springframework.config.java;
package org.springframework.config.java.support;
import java.lang.reflect.Method;
......@@ -19,7 +19,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
// TODO: SJC-242 document FactoryMethodHandler
// TODO: SJC-242 odd that the api here uses both ModelMethod and java.lang.reflect.Member
// TODO: SJC-242 document that there must be a no-arg ctor
public interface BeanDefinitionRegistrar {
interface BeanDefinitionRegistrar {
/**
* Determines whether this registrar is capable of handling <var>method</var>.
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java;
package org.springframework.config.java.support;
import static java.lang.String.*;
import static org.springframework.config.java.StandardScopes.*;
......@@ -26,13 +26,14 @@ import java.util.List;
import org.springframework.beans.factory.parsing.Location;
import org.springframework.beans.factory.parsing.Problem;
import org.springframework.beans.factory.parsing.ProblemReporter;
import org.springframework.config.java.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.core.io.FileSystemResource;
import org.springframework.util.Assert;
public final class BeanMethod {
final class BeanMethod {
private final String name;
private final int modifiers;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.enhancement;
package org.springframework.config.java.support;
import static java.lang.String.*;
......@@ -23,7 +23,6 @@ import net.sf.cglib.proxy.MethodProxy;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.config.java.Bean;
import org.springframework.config.java.BeanRegistrar;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.core.annotation.AnnotationUtils;
......
package org.springframework.config.java;
package org.springframework.config.java.support;
import static java.lang.String.*;
import static org.springframework.util.StringUtils.*;
......@@ -17,6 +17,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.config.java.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.core.annotation.AnnotationUtils;
......@@ -25,7 +26,7 @@ import org.springframework.util.Assert;
// TODO: SJC-242 document BeanHandler
// TODO: SJC-242 make package-private
public class BeanRegistrar implements BeanDefinitionRegistrar {
class BeanRegistrar implements BeanDefinitionRegistrar {
private static final Log logger = LogFactory.getLog(BeanRegistrar.class);
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java;
package org.springframework.config.java.support;
import static java.lang.String.*;
......@@ -26,6 +26,7 @@ import java.util.Set;
import org.springframework.beans.factory.parsing.Location;
import org.springframework.beans.factory.parsing.Problem;
import org.springframework.beans.factory.parsing.ProblemReporter;
import org.springframework.config.java.Configuration;
import org.springframework.core.io.FileSystemResource;
import org.springframework.util.Assert;
......@@ -48,9 +49,7 @@ import sun.security.x509.Extension;
*
* @author Chris Beams
*/
// TODO: SJC-242 update documentation in light of generalization changes
// consider removing all refs to Bean, ExternalBean, etc.
public final class ConfigurationClass extends ModelClass {
final class ConfigurationClass extends ModelClass {
private String beanName;
......
......@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.parsing;
package org.springframework.config.java.support;
import static org.springframework.config.java.Util.*;
import static org.springframework.config.java.internal.parsing.AsmUtils.*;
import static org.springframework.config.java.internal.parsing.MutableAnnotationUtils.*;
import static org.springframework.config.java.support.AsmUtils.*;
import static org.springframework.config.java.support.MutableAnnotationUtils.*;
import static org.springframework.config.java.support.Util.*;
import static org.springframework.util.ClassUtils.*;
import java.lang.annotation.Annotation;
......@@ -29,10 +29,7 @@ import org.objectweb.asm.Label;
import org.objectweb.asm.MethodAdapter;
import org.objectweb.asm.Opcodes;
import org.springframework.config.java.Bean;
import org.springframework.config.java.BeanMethod;
import org.springframework.config.java.Configuration;
import org.springframework.config.java.ConfigurationClass;
import org.springframework.config.java.ModelClass;
/**
......
......@@ -29,9 +29,6 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.config.java.Bean;
import org.springframework.config.java.Configuration;
import org.springframework.config.java.ConfigurationModel;
import org.springframework.config.java.internal.enhancement.ConfigurationEnhancer;
import org.springframework.config.java.internal.parsing.ConfigurationParser;
import org.springframework.core.Ordered;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.classreading.MetadataReader;
......
......@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.parsing;
package org.springframework.config.java.support;
import static org.springframework.config.java.Util.*;
import static org.springframework.config.java.internal.parsing.MutableAnnotationUtils.*;
import static org.springframework.config.java.support.MutableAnnotationUtils.*;
import static org.springframework.config.java.support.Util.*;
import static org.springframework.util.ClassUtils.*;
import java.lang.annotation.Annotation;
......@@ -30,10 +30,6 @@ import org.objectweb.asm.ClassReader;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.springframework.config.java.Configuration;
import org.springframework.config.java.ConfigurationClass;
import org.springframework.config.java.ConfigurationModel;
import org.springframework.config.java.plugin.Extension;
import org.springframework.util.ClassUtils;
/**
......@@ -130,8 +126,8 @@ class ConfigurationClassVisitor extends ClassAdapter {
// return new ImportAnnotationVisitor(model);
// }
// -------------------------------------
// Detect @Plugin annotations
/* -------------------------------------
// Detect @Extension annotations
// -------------------------------------
PluginAnnotationDetectingClassVisitor classVisitor = new PluginAnnotationDetectingClassVisitor(classLoader);
......@@ -142,6 +138,7 @@ class ConfigurationClassVisitor extends ClassAdapter {
if (!classVisitor.hasPluginAnnotation())
return super.visitAnnotation(annoTypeDesc, visible);
*/
Class<? extends Annotation> annoType = loadToolingSafeClass(annoTypeName, classLoader);
......@@ -153,6 +150,7 @@ class ConfigurationClassVisitor extends ClassAdapter {
return new MutableAnnotationVisitor(pluginAnno, classLoader);
}
/* Support for @Extension annotation processing
private static class PluginAnnotationDetectingClassVisitor extends ClassAdapter {
private boolean hasPluginAnnotation = false;
private final Extension pluginAnnotation = createMutableAnnotation(Extension.class);
......@@ -180,6 +178,7 @@ class ConfigurationClassVisitor extends ClassAdapter {
return pluginAnnotation;
}
}
*/
/**
* Delegates all {@link Configuration @Configuration} class method parsing to
......
......@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.enhancement;
package org.springframework.config.java.support;
import static java.lang.String.*;
import static org.springframework.config.java.Util.*;
import static org.springframework.config.java.support.Util.*;
import static org.springframework.util.Assert.*;
import java.lang.annotation.Annotation;
......@@ -39,9 +39,6 @@ import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
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.BeanRegistrar;
import org.springframework.config.java.Configuration;
......@@ -53,7 +50,7 @@ import org.springframework.config.java.Configuration;
*
* @author Chris Beams
*/
public class ConfigurationEnhancer {
class ConfigurationEnhancer {
private static final Log log = LogFactory.getLog(ConfigurationEnhancer.class);
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java;
package org.springframework.config.java.support;
import static java.lang.String.*;
......@@ -22,6 +22,7 @@ import java.util.ArrayList;
import org.springframework.beans.factory.parsing.Location;
import org.springframework.beans.factory.parsing.Problem;
import org.springframework.beans.factory.parsing.ProblemReporter;
import org.springframework.config.java.Configuration;
import org.springframework.core.io.FileSystemResource;
......@@ -30,7 +31,7 @@ import org.springframework.core.io.FileSystemResource;
* An abstract representation of a set of user-provided "Configuration classes", usually but
* not necessarily annotated with {@link Configuration @Configuration}. The model is
* populated with a
* {@link org.springframework.config.java.internal.parsing.ConfigurationParser}
* {@link org.springframework.config.java.support.ConfigurationParser}
* implementation which may be reflection-based or ASM-based. Once a model has been
* populated, it can then be rendered out to a set of BeanDefinitions. The model provides an
* important layer of indirection between the complexity of parsing a set of classes and the
......@@ -41,9 +42,9 @@ import org.springframework.core.io.FileSystemResource;
* </p>
*
* @author Chris Beams
* @see org.springframework.config.java.internal.parsing.ConfigurationParser
* @see org.springframework.config.java.support.ConfigurationParser
*/
public final class ConfigurationModel {
final class ConfigurationModel {
/* list is used because order and collection equality matters. */
private final ArrayList<ConfigurationClass> configurationClasses = new ArrayList<ConfigurationClass>();
......
......@@ -25,12 +25,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry;
import org.springframework.config.java.Bean;
import org.springframework.config.java.BeanMethod;
import org.springframework.config.java.BeanRegistrar;
import org.springframework.config.java.Configuration;
import org.springframework.config.java.ConfigurationClass;
import org.springframework.config.java.ConfigurationModel;
import org.springframework.config.java.plugin.Extension;
import org.springframework.core.io.Resource;
......
......@@ -13,14 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.parsing;
package org.springframework.config.java.support;
import org.objectweb.asm.ClassReader;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.config.java.Configuration;
import org.springframework.config.java.ConfigurationClass;
import org.springframework.config.java.ConfigurationModel;
import org.springframework.config.java.Util;
import org.springframework.util.ClassUtils;
......@@ -33,7 +30,7 @@ import org.springframework.util.ClassUtils;
* from the concern of registering {@link BeanDefinition} objects based on the content of
* that model.
*
* @see org.springframework.config.java.ConfigurationModel
* @see org.springframework.config.java.support.ConfigurationModel
* @see org.springframework.config.java.support.ConfigurationModelBeanDefinitionReader
*
* @author Chris Beams
......
......@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java;
package org.springframework.config.java.support;
import org.springframework.beans.BeanMetadataElement;
import org.springframework.config.java.Configuration;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
......@@ -27,7 +28,7 @@ import org.springframework.util.ClassUtils;
* @author Chris Beams
*/
// TODO: Consider eliminating in favor of just ConfigurationClass
public class ModelClass implements BeanMetadataElement {
class ModelClass implements BeanMetadataElement {
private String name;
private boolean isInterface;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.parsing;
package org.springframework.config.java.support;
/**
* Note: the visibility of this interface would be reduced to package-private save for an
......@@ -22,9 +22,8 @@ package org.springframework.config.java.internal.parsing;
* two interfaces: this one, and whatever annotation is currently being parsed. The
* restriction is that both interfaces may not be package-private if they are in separate
* packages. In order to avoid unnecessarily restricting the visibility options for
* user-defined annotations, this interface becomes public. Because it is in the internal.*
* package, it won't pollute the public API, but developers should take caution not to use
* this annotation outside the internal.parsing package.
* user-defined annotations, this interface becomes public. Developers should take caution
* not to use this annotation outside this package.
*
* @author Chris Beams
*/
......
......@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.parsing;
package org.springframework.config.java.support;
import static org.springframework.config.java.Util.*;
import static org.springframework.config.java.internal.parsing.MutableAnnotationUtils.*;
import static org.springframework.config.java.support.MutableAnnotationUtils.*;
import static org.springframework.config.java.support.Util.*;
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.parsing;
package org.springframework.config.java.support;
import static java.lang.String.*;
import static org.springframework.core.annotation.AnnotationUtils.*;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.parsing;
package org.springframework.config.java.support;
import java.lang.annotation.Annotation;
import java.lang.reflect.Proxy;
......
......@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.parsing;
package org.springframework.config.java.support;
import static org.springframework.config.java.Util.*;
import static org.springframework.config.java.internal.parsing.MutableAnnotationUtils.*;
import static org.springframework.config.java.support.MutableAnnotationUtils.*;
import static org.springframework.config.java.support.Util.*;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
......
package org.springframework.config.java;
package org.springframework.config.java.support;
import static java.lang.String.*;
import static org.springframework.util.ClassUtils.*;
......@@ -24,7 +24,7 @@ import sun.security.x509.Extension;
// TODO: SJC-242 general - check tabs & spaces
// TODO: SJC-242 general - check apache header
// TODO: SJC-242 rename, repackage, document
public class Util {
class Util {
private static final Log log = LogFactory.getLog(Util.class);
......
......@@ -26,7 +26,6 @@ import org.springframework.aop.scope.ScopedObject;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.config.java.Bean;
import org.springframework.config.java.BeanRegistrar;
import org.springframework.config.java.Configuration;
import org.springframework.config.java.StandardScopes;
import org.springframework.config.java.support.ConfigurationClassPostProcessor;
......@@ -145,7 +144,7 @@ public class ScopingTests {
String beanName = "scopedProxyInterface";
String scopedBeanName = BeanRegistrar.resolveHiddenScopedProxyBeanName(beanName);
String scopedBeanName = "scopedTarget." + beanName;
// get hidden bean
assertEquals(flag, spouse.getName());
......@@ -179,7 +178,7 @@ public class ScopingTests {
String beanName = "scopedProxyClass";
String scopedBeanName = BeanRegistrar.resolveHiddenScopedProxyBeanName(beanName);
String scopedBeanName = "scopedTarget." + beanName;
// get hidden bean
assertEquals(flag, spouse.getName());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册