提交 7f96f573 编写于 作者: C Chris Beams

polishing

上级 1284bd58
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation;
import java.lang.annotation.Documented;
......@@ -96,8 +97,3 @@ public @interface Bean {
String[] dependsOn() default {};
}
// TODO: test @Lazy @Bean
// TODO: test @Primary @Bean
// TODO: test init/destroy method scenarios
// TODO: test dependsOn
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation;
import java.lang.annotation.Documented;
......@@ -64,7 +65,3 @@ import org.springframework.stereotype.Component;
public @interface Configuration {
}
// TODO: test @Configuration constructor autowiring
// TODO: test @Lazy @Configuration
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation;
import java.lang.annotation.Documented;
......@@ -42,5 +43,5 @@ public @interface Import {
/**
* The {@link Configuration} class or classes to import.
*/
Class<?>[] value();
Class<?>[] value();
}
......@@ -67,5 +67,5 @@ public @interface Scope {
* only in conjunction with a non-singleton, non-prototype {@link #value()}.
*/
ScopedProxyMode proxyMode() default ScopedProxyMode.NO;
}
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation;
......@@ -25,6 +26,7 @@ package org.springframework.context.annotation;
*
* @author Chris Beams
* @since 3.0
* @see Scope
*/
public class StandardScopes {
......@@ -39,5 +41,3 @@ public class StandardScopes {
public static final String SESSION = "session";
}
// TODO: move StandardScopes to appropriate package
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import org.springframework.beans.factory.config.BeanDefinition;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import net.sf.cglib.asm.Constants;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import org.springframework.asm.AnnotationVisitor;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import java.io.IOException;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static java.lang.String.*;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static java.lang.String.*;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static java.lang.String.*;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static org.springframework.context.annotation.support.AsmUtils.*;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static java.lang.String.*;
......@@ -146,7 +147,7 @@ public class ConfigurationClassPostProcessor extends AbstractConfigurationClassP
ConfigurationEnhancer enhancer = new ConfigurationEnhancer(beanFactory);
for(String beanName : configBeanDefs.getBeanDefinitionNames()) {
for (String beanName : configBeanDefs.getBeanDefinitionNames()) {
BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName);
String configClassName = beanDef.getBeanClassName();
String enhancedClassName = enhancer.enhance(configClassName);
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static java.lang.String.*;
......@@ -144,8 +145,8 @@ class ConfigurationClassVisitor extends ClassAdapter {
* {@link ConfigurationClassMethodVisitor}.
*/
@Override
public MethodVisitor visitMethod(int modifiers, String methodName, String methodDescriptor, String arg3,
String[] arg4) {
public MethodVisitor visitMethod(int modifiers, String methodName, String methodDescriptor,
String arg3, String[] arg4) {
return new ConfigurationClassMethodVisitor(configClass, methodName, methodDescriptor, modifiers, classLoader);
}
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static java.lang.String.*;
......@@ -141,7 +142,6 @@ class ConfigurationEnhancer {
* @return original subclass instance unless superclass is annnotated with @Aspect, in
* which case a subclass of the subclass is returned
*/
// TODO: try to implement with modifications to AbstractAspectJAdvisorFactory#isAspect
private Class<?> nestOneClassDeeperIfAspect(Class<?> superclass, Class<?> origSubclass) {
boolean superclassIsAnAspect = false;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static java.lang.String.*;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static java.lang.String.*;
......@@ -63,10 +64,11 @@ class ConfigurationModelBeanDefinitionReader {
/**
* Reads {@code model}, registering bean definitions with {@link #registry} based on
* its contents.
* Reads {@code configurationModel}, registering bean definitions with {@link #registry}
* based on its contents.
*
* @return number of bean definitions generated
* @return new {@link BeanDefinitionRegistry} containing {@link BeanDefinition}s read
* from the model.
*/
public BeanDefinitionRegistry loadBeanDefinitions(ConfigurationModel configurationModel) {
registry = new SimpleBeanDefinitionRegistry();
......@@ -131,9 +133,6 @@ class ConfigurationModelBeanDefinitionReader {
Bean bean = method.getRequiredAnnotation(Bean.class);
// TODO: prune defaults
//Configuration defaults = configClass.getMetadata();
// consider scoping
Scope scope = method.getAnnotation(Scope.class);
if(scope != null)
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import org.springframework.asm.ClassReader;
......@@ -67,7 +68,7 @@ public class ConfigurationParser {
* that this configuration class was configured via XML)
*/
public void parse(String className, String configurationId) {
String resourcePath = ClassUtils.convertClassNameToResourcePath(className);
ClassReader configClassReader = AsmUtils.newClassReader(Util.getClassAsStream(resourcePath, classLoader));
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static java.lang.String.*;
......@@ -41,6 +42,7 @@ import org.springframework.util.Assert;
* @see ConfigurationClassVisitor
*/
class ImportAnnotationVisitor extends AnnotationAdapter {
private final ArrayList<String> classesToImport = new ArrayList<String>();
private final ConfigurationModel model;
private final ProblemReporter problemReporter;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import java.util.Collections;
......@@ -71,7 +72,6 @@ class ImportStack extends Stack<ConfigurationClass> {
StringBuilder builder = new StringBuilder();
Iterator<ConfigurationClass> iterator = this.iterator();
while (iterator.hasNext()) {
builder.append(iterator.next().getSimpleName());
if (iterator.hasNext())
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import org.springframework.context.annotation.Import;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static org.springframework.util.ClassUtils.*;
......
......@@ -13,10 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import org.springframework.context.annotation.Configuration;
/**
* Note: the visibility of this interface would be reduced to package-private save for an
* Interface used when dynamically creating mutable instances of annotations associated
* with {@link Configuration} class processing. This functionality is necessary given
* that parsing of Configuration classes is done with ASM. Annotation metadata (including
* attributes) is parsed from the classfiles, and instances of those annotations are
* then created using this interface and its associated utilities. The annotation
* instances are attached to the {@link ConfigurationModel} objects at runtime, namely
* {@link BeanMethod}. This approach is better than the alternative of creating fine-grained
* model representations of all annotations and attributes. It is better to simply attach
* annotation instances and read them as needed.
*
* <p>Note: the visibility of this interface would be reduced to package-private save for an
* obscure restriction of JDK dynamic proxies.
* {@link MutableAnnotationUtils#createMutableAnnotation(Class)} creates a proxy based on
* two interfaces: this one, and whatever annotation is currently being parsed. The
......@@ -26,6 +39,9 @@ package org.springframework.context.annotation.support;
* not to use this annotation outside this package.
*
* @author Chris Beams
* @see MutableAnnotationUtils
* @see MutableAnnotationVisitor
* @see MutableAnnotationInvocationHandler
*/
public interface MutableAnnotation {
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static org.springframework.context.annotation.support.MutableAnnotationUtils.*;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static java.lang.String.*;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import java.lang.annotation.Annotation;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static org.springframework.context.annotation.support.MutableAnnotationUtils.*;
......
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation.support;
import static java.lang.String.*;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册