Whitespace and license polish
This commit is contained in:
parent
a2c87ae67a
commit
dc191bec2d
|
|
@ -113,12 +113,12 @@ public abstract class AbstractConfigurationClassProcessor {
|
||||||
// populate a new ConfigurationModel by parsing each @Configuration classes
|
// populate a new ConfigurationModel by parsing each @Configuration classes
|
||||||
ConfigurationParser parser = createConfigurationParser();
|
ConfigurationParser parser = createConfigurationParser();
|
||||||
|
|
||||||
for(String beanName : configBeanDefs.getBeanDefinitionNames()) {
|
for(String beanName : configBeanDefs.getBeanDefinitionNames()) {
|
||||||
BeanDefinition beanDef = configBeanDefs.getBeanDefinition(beanName);
|
BeanDefinition beanDef = configBeanDefs.getBeanDefinition(beanName);
|
||||||
String className = beanDef.getBeanClassName();
|
String className = beanDef.getBeanClassName();
|
||||||
|
|
||||||
parser.parse(className, beanName);
|
parser.parse(className, beanName);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationModel configModel = parser.getConfigurationModel();
|
ConfigurationModel configModel = parser.getConfigurationModel();
|
||||||
|
|
||||||
|
|
@ -126,7 +126,7 @@ public abstract class AbstractConfigurationClassProcessor {
|
||||||
validateModel(configModel);
|
validateModel(configModel);
|
||||||
|
|
||||||
// read the model and create bean definitions based on its content
|
// read the model and create bean definitions based on its content
|
||||||
return new ConfigurationModelBeanDefinitionReader().loadBeanDefinitions(configModel);
|
return new ConfigurationModelBeanDefinitionReader().loadBeanDefinitions(configModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,8 @@ class AddAnnotationAdapter extends ClassAdapter {
|
||||||
* Ensures that the version of the resulting class is Java 5 or better.
|
* Ensures that the version of the resulting class is Java 5 or better.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void visit(int version, int access, String name, String signature, String superName,
|
public void visit(int version, int access, String name, String signature,
|
||||||
String[] interfaces) {
|
String superName, String[] interfaces) {
|
||||||
int v = (version & 0xFF) < Constants.V1_5 ? Constants.V1_5 : version;
|
int v = (version & 0xFF) < Constants.V1_5 ? Constants.V1_5 : version;
|
||||||
cv.visit(v, access, name, signature, superName, interfaces);
|
cv.visit(v, access, name, signature, superName, interfaces);
|
||||||
}
|
}
|
||||||
|
|
@ -83,8 +83,7 @@ class AddAnnotationAdapter extends ClassAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature,
|
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||||
String[] exceptions) {
|
|
||||||
addAnnotation();
|
addAnnotation();
|
||||||
return cv.visitMethod(access, name, desc, signature, exceptions);
|
return cv.visitMethod(access, name, desc, signature, exceptions);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -109,8 +109,6 @@ class AsmUtils {
|
||||||
*
|
*
|
||||||
* @param bytes byte array that will be provided as input to the new ClassReader
|
* @param bytes byte array that will be provided as input to the new ClassReader
|
||||||
* instance.
|
* instance.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static ClassReader newClassReader(byte[] bytes) {
|
public static ClassReader newClassReader(byte[] bytes) {
|
||||||
return new ClassReader(bytes);
|
return new ClassReader(bytes);
|
||||||
|
|
@ -129,8 +127,7 @@ class AsmUtils {
|
||||||
try {
|
try {
|
||||||
return new ClassReader(is);
|
return new ClassReader(is);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new RuntimeException("An unexpected exception occurred while creating ASM ClassReader: "
|
throw new RuntimeException("An unexpected exception occurred while creating ASM ClassReader: " + ex);
|
||||||
+ ex);
|
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
is.close();
|
is.close();
|
||||||
|
|
|
||||||
|
|
@ -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;
|
package org.springframework.config.java.support;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -140,8 +140,8 @@ final class BeanMethod {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String returnTypeName = returnType == null ? "<unknown>" : returnType.getSimpleName();
|
String returnTypeName = returnType == null ? "<unknown>" : returnType.getSimpleName();
|
||||||
return String.format("%s: name=%s; returnType=%s; modifiers=%d", getClass().getSimpleName(), name,
|
return format("%s: name=%s; returnType=%s; modifiers=%d",
|
||||||
returnTypeName, modifiers);
|
getClass().getSimpleName(), name, returnTypeName, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -187,24 +187,24 @@ final class BeanMethod {
|
||||||
/** {@link Bean} methods must be non-private in order to accommodate CGLIB. */
|
/** {@link Bean} methods must be non-private in order to accommodate CGLIB. */
|
||||||
public class PrivateMethodError extends Problem {
|
public class PrivateMethodError extends Problem {
|
||||||
public PrivateMethodError() {
|
public PrivateMethodError() {
|
||||||
super(format("method '%s' may not be private", getName()), new Location(new FileSystemResource("/dev/null")));
|
super(format("method '%s' may not be private", getName()),
|
||||||
|
new Location(new FileSystemResource("/dev/null")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@link Bean} methods must be non-final in order to accommodate CGLIB. */
|
/** {@link Bean} methods must be non-final in order to accommodate CGLIB. */
|
||||||
public class FinalMethodError extends Problem {
|
public class FinalMethodError extends Problem {
|
||||||
public FinalMethodError() {
|
public FinalMethodError() {
|
||||||
super(format("method '%s' may not be final. remove the final modifier to continue", getName()), new Location(new FileSystemResource("/dev/null")));
|
super(format("method '%s' may not be final. remove the final modifier to continue", getName()),
|
||||||
|
new Location(new FileSystemResource("/dev/null")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InvalidScopedProxyDeclarationError extends Problem {
|
public class InvalidScopedProxyDeclarationError extends Problem {
|
||||||
public InvalidScopedProxyDeclarationError(BeanMethod method) {
|
public InvalidScopedProxyDeclarationError(BeanMethod method) {
|
||||||
super(
|
super(format("method %s contains an invalid annotation declaration: scoped proxies "
|
||||||
String.format("method %s contains an invalid annotation declaration: scoped proxies "
|
+ "cannot be created for singleton/prototype beans", method.getName()),
|
||||||
+ "cannot be created for singleton/prototype beans", method.getName()),
|
new Location(new FileSystemResource("/dev/null")));
|
||||||
new Location(new FileSystemResource("/dev/null"))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,8 @@ class BeanMethodInterceptor implements BeanFactoryAware, MethodInterceptor {
|
||||||
// we have an already existing cached instance of this bean -> retrieve it
|
// we have an already existing cached instance of this bean -> retrieve it
|
||||||
Object cachedBean = beanFactory.getBean(beanName);
|
Object cachedBean = beanFactory.getBean(beanName);
|
||||||
if (log.isInfoEnabled())
|
if (log.isInfoEnabled())
|
||||||
log.info(format("Returning cached singleton object [%s] for @Bean method %s.%s", cachedBean,
|
log.info(format("Returning cached singleton object [%s] for @Bean method %s.%s",
|
||||||
method.getDeclaringClass().getSimpleName(), beanName));
|
cachedBean, method.getDeclaringClass().getSimpleName(), beanName));
|
||||||
|
|
||||||
return cachedBean;
|
return cachedBean;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
package org.springframework.config.java.support;
|
||||||
|
|
||||||
import static java.lang.String.*;
|
import static java.lang.String.*;
|
||||||
|
|
@ -24,8 +39,6 @@ import org.springframework.core.annotation.AnnotationUtils;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
|
||||||
// TODO: SJC-242 document BeanHandler
|
|
||||||
// TODO: SJC-242 make package-private
|
|
||||||
class BeanRegistrar implements BeanDefinitionRegistrar {
|
class BeanRegistrar implements BeanDefinitionRegistrar {
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(BeanRegistrar.class);
|
private static final Log logger = LogFactory.getLog(BeanRegistrar.class);
|
||||||
|
|
@ -41,7 +54,6 @@ class BeanRegistrar implements BeanDefinitionRegistrar {
|
||||||
return AnnotationUtils.findAnnotation(method, Bean.class) != null;
|
return AnnotationUtils.findAnnotation(method, Bean.class) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: SJC-242 method too long
|
|
||||||
public void register(BeanMethod method, BeanDefinitionRegistry registry) {
|
public void register(BeanMethod method, BeanDefinitionRegistry registry) {
|
||||||
RootBeanDefinition beanDef = new ConfigurationClassBeanDefinition();
|
RootBeanDefinition beanDef = new ConfigurationClassBeanDefinition();
|
||||||
|
|
||||||
|
|
@ -119,7 +131,7 @@ class BeanRegistrar implements BeanDefinitionRegistrar {
|
||||||
// is this method annotated with @Scope(scopedProxy=...)?
|
// is this method annotated with @Scope(scopedProxy=...)?
|
||||||
if (scope != null && scope.proxyMode() != ScopedProxyMode.NO) {
|
if (scope != null && scope.proxyMode() != ScopedProxyMode.NO) {
|
||||||
RootBeanDefinition targetDef = beanDef;
|
RootBeanDefinition targetDef = beanDef;
|
||||||
//
|
|
||||||
// Create a scoped proxy definition for the original bean name,
|
// Create a scoped proxy definition for the original bean name,
|
||||||
// "hiding" the target bean in an internal target definition.
|
// "hiding" the target bean in an internal target definition.
|
||||||
String targetBeanName = resolveHiddenScopedProxyBeanName(beanName);
|
String targetBeanName = resolveHiddenScopedProxyBeanName(beanName);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.config.java.support;
|
package org.springframework.config.java.support;
|
||||||
|
|
||||||
|
|
||||||
import static java.lang.String.*;
|
import static java.lang.String.*;
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
|
|
@ -147,7 +146,6 @@ final class ConfigurationClass extends ModelClass {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ConfigurationClass setDeclaringClass(ConfigurationClass configurationClass) {
|
public ConfigurationClass setDeclaringClass(ConfigurationClass configurationClass) {
|
||||||
this.declaringClass = configurationClass;
|
this.declaringClass = configurationClass;
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -190,7 +188,6 @@ final class ConfigurationClass extends ModelClass {
|
||||||
method.validate(problemReporter);
|
method.validate(problemReporter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return format("%s; modifiers=%d; methods=%s", super.toString(), modifiers, methods);
|
return format("%s; modifiers=%d; methods=%s", super.toString(), modifiers, methods);
|
||||||
|
|
@ -252,23 +249,22 @@ final class ConfigurationClass extends ModelClass {
|
||||||
/** Configuration classes must be annotated with {@link Configuration @Configuration}. */
|
/** Configuration classes must be annotated with {@link Configuration @Configuration}. */
|
||||||
public class NonAnnotatedConfigurationError extends Problem {
|
public class NonAnnotatedConfigurationError extends Problem {
|
||||||
public NonAnnotatedConfigurationError() {
|
public NonAnnotatedConfigurationError() {
|
||||||
super(
|
super(format("%s was provided as a Java Configuration class but was not annotated with @%s. "
|
||||||
format("%s was provided as a Java Configuration class but was not annotated with @%s. "
|
+ "Update the class definition to continue.",
|
||||||
+ "Update the class definition to continue.", getSimpleName(), Configuration.class
|
getSimpleName(), Configuration.class.getSimpleName()),
|
||||||
.getSimpleName()),
|
new Location(new FileSystemResource("/dev/null"))
|
||||||
new Location(new FileSystemResource("/dev/null"))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Configuration classes must be non-final to accommodate CGLIB subclassing. */
|
/** Configuration classes must be non-final to accommodate CGLIB subclassing. */
|
||||||
public class FinalConfigurationError extends Problem {
|
public class FinalConfigurationError extends Problem {
|
||||||
public FinalConfigurationError() {
|
public FinalConfigurationError() {
|
||||||
super(
|
super(format("@%s class may not be final. Remove the final modifier to continue.",
|
||||||
format("@%s class may not be final. Remove the final modifier to continue.",
|
Configuration.class.getSimpleName()),
|
||||||
Configuration.class.getSimpleName()),
|
new Location(new FileSystemResource("/dev/null"))
|
||||||
new Location(new FileSystemResource("/dev/null"))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -60,7 +60,7 @@ class ConfigurationClassMethodVisitor extends MethodAdapter {
|
||||||
* @param modifiers modifiers for this method
|
* @param modifiers modifiers for this method
|
||||||
*/
|
*/
|
||||||
public ConfigurationClassMethodVisitor(ConfigurationClass configClass, String methodName,
|
public ConfigurationClassMethodVisitor(ConfigurationClass configClass, String methodName,
|
||||||
String methodDescriptor, int modifiers, ClassLoader classLoader) {
|
String methodDescriptor, int modifiers, ClassLoader classLoader) {
|
||||||
super(AsmUtils.EMPTY_VISITOR);
|
super(AsmUtils.EMPTY_VISITOR);
|
||||||
|
|
||||||
this.configClass = configClass;
|
this.configClass = configClass;
|
||||||
|
|
@ -133,12 +133,12 @@ class ConfigurationClassMethodVisitor extends MethodAdapter {
|
||||||
|
|
||||||
// detect whether the return type is an interface
|
// detect whether the return type is an interface
|
||||||
newClassReader(convertClassNameToResourcePath(returnType.getName()), classLoader).accept(
|
newClassReader(convertClassNameToResourcePath(returnType.getName()), classLoader).accept(
|
||||||
new ClassAdapter(AsmUtils.EMPTY_VISITOR) {
|
new ClassAdapter(AsmUtils.EMPTY_VISITOR) {
|
||||||
@Override
|
@Override
|
||||||
public void visit(int arg0, int arg1, String arg2, String arg3, String arg4, String[] arg5) {
|
public void visit(int arg0, int arg1, String arg2, String arg3, String arg4, String[] arg5) {
|
||||||
returnType.setInterface((arg1 & Opcodes.ACC_INTERFACE) == Opcodes.ACC_INTERFACE);
|
returnType.setInterface((arg1 & Opcodes.ACC_INTERFACE) == Opcodes.ACC_INTERFACE);
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
return returnType;
|
return returnType;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,8 +161,8 @@ public class ConfigurationClassPostProcessor extends AbstractConfigurationClassP
|
||||||
String enhancedClassName = enhancer.enhance(configClassName);
|
String enhancedClassName = enhancer.enhance(configClassName);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug(format("Replacing bean definition '%s' existing class name '%s' with enhanced class name '%s'",
|
logger.debug(format("Replacing bean definition '%s' existing class name '%s' "
|
||||||
beanName, configClassName, enhancedClassName));
|
+ "with enhanced class name '%s'", beanName, configClassName, enhancedClassName));
|
||||||
|
|
||||||
beanDef.setBeanClassName(enhancedClassName);
|
beanDef.setBeanClassName(enhancedClassName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,8 +22,6 @@ import static org.springframework.util.ClassUtils.*;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.objectweb.asm.AnnotationVisitor;
|
import org.objectweb.asm.AnnotationVisitor;
|
||||||
import org.objectweb.asm.ClassAdapter;
|
import org.objectweb.asm.ClassAdapter;
|
||||||
import org.objectweb.asm.ClassReader;
|
import org.objectweb.asm.ClassReader;
|
||||||
|
|
@ -40,7 +38,6 @@ import org.springframework.config.java.Configuration;
|
||||||
*/
|
*/
|
||||||
class ConfigurationClassVisitor extends ClassAdapter {
|
class ConfigurationClassVisitor extends ClassAdapter {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(ConfigurationClassVisitor.class);
|
|
||||||
private static final String OBJECT_DESC = convertClassNameToResourcePath(Object.class.getName());
|
private static final String OBJECT_DESC = convertClassNameToResourcePath(Object.class.getName());
|
||||||
|
|
||||||
private final ConfigurationClass configClass;
|
private final ConfigurationClass configClass;
|
||||||
|
|
@ -63,15 +60,16 @@ class ConfigurationClassVisitor extends ClassAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitSource(String sourceFile, String debug) {
|
public void visitSource(String sourceFile, String debug) {
|
||||||
String resourcePath = convertClassNameToResourcePath(configClass.getName()).substring(0,
|
String resourcePath =
|
||||||
configClass.getName().lastIndexOf('.') + 1).concat(sourceFile);
|
convertClassNameToResourcePath(configClass.getName())
|
||||||
|
.substring(0, configClass.getName().lastIndexOf('.') + 1).concat(sourceFile);
|
||||||
|
|
||||||
configClass.setSource(resourcePath);
|
configClass.setSource(resourcePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(int classVersion, int modifiers, String classTypeDesc, String arg3,
|
public void visit(int classVersion, int modifiers, String classTypeDesc, String arg3,
|
||||||
String superTypeDesc, String[] arg5) {
|
String superTypeDesc, String[] arg5) {
|
||||||
visitSuperType(superTypeDesc);
|
visitSuperType(superTypeDesc);
|
||||||
|
|
||||||
configClass.setName(convertResourcePathToClassName(classTypeDesc));
|
configClass.setName(convertResourcePathToClassName(classTypeDesc));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -67,9 +67,10 @@ class ConfigurationEnhancer {
|
||||||
if (iter.next().accepts(candidateMethod))
|
if (iter.next().accepts(candidateMethod))
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
throw new IllegalStateException(format("No registrar is capable of "
|
throw new IllegalStateException(
|
||||||
+ "handling method [%s]. Perhaps you forgot to add a catch-all registrar?",
|
format("No registrar is capable of handling method [%s]. "
|
||||||
candidateMethod.getName()));
|
+ "Perhaps you forgot to add a catch-all registrar?",
|
||||||
|
candidateMethod.getName()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -98,10 +99,9 @@ class ConfigurationEnhancer {
|
||||||
});
|
});
|
||||||
callbackInstances.add(new MethodInterceptor() {
|
callbackInstances.add(new MethodInterceptor() {
|
||||||
|
|
||||||
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy)
|
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
|
||||||
throws Throwable {
|
return null;
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -127,8 +127,8 @@ class ConfigurationEnhancer {
|
||||||
subclass = nestOneClassDeeperIfAspect(superclass, subclass);
|
subclass = nestOneClassDeeperIfAspect(superclass, subclass);
|
||||||
|
|
||||||
if (log.isInfoEnabled())
|
if (log.isInfoEnabled())
|
||||||
log.info(format("Successfully enhanced %s; enhanced class name is: %s", configClassName, subclass
|
log.info(format("Successfully enhanced %s; enhanced class name is: %s",
|
||||||
.getName()));
|
configClassName, subclass.getName()));
|
||||||
|
|
||||||
return subclass.getName();
|
return subclass.getName();
|
||||||
}
|
}
|
||||||
|
|
@ -193,8 +193,7 @@ class ConfigurationEnhancer {
|
||||||
@Override
|
@Override
|
||||||
protected byte[] transform(byte[] b) throws Exception {
|
protected byte[] transform(byte[] b) throws Exception {
|
||||||
ClassWriter writer = new ClassWriter(false);
|
ClassWriter writer = new ClassWriter(false);
|
||||||
ClassAdapter adapter = new AddAnnotationAdapter(writer,
|
ClassAdapter adapter = new AddAnnotationAdapter(writer, "Lorg/aspectj/lang/annotation/Aspect;");
|
||||||
"Lorg/aspectj/lang/annotation/Aspect;");
|
|
||||||
ClassReader reader = new ClassReader(b);
|
ClassReader reader = new ClassReader(b);
|
||||||
reader.accept(adapter, false);
|
reader.accept(adapter, false);
|
||||||
return writer.toByteArray();
|
return writer.toByteArray();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -26,7 +26,6 @@ import org.springframework.config.java.Configuration;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract representation of a set of user-provided "Configuration classes", usually but
|
* An abstract representation of a set of user-provided "Configuration classes", usually but
|
||||||
* not necessarily annotated with {@link Configuration @Configuration}. The model is
|
* not necessarily annotated with {@link Configuration @Configuration}. The model is
|
||||||
|
|
@ -163,11 +162,9 @@ final class ConfigurationModel {
|
||||||
|
|
||||||
public class EmptyModelError extends Problem {
|
public class EmptyModelError extends Problem {
|
||||||
public EmptyModelError() {
|
public EmptyModelError() {
|
||||||
super(
|
super(format("Configuration model was empty. Make sure at least one "
|
||||||
format("Configuration model was empty. Make sure at least one "
|
+ "@%s class has been specified.", Configuration.class.getSimpleName()),
|
||||||
+ "@%s class has been specified.", Configuration.class.getSimpleName()),
|
new Location(new FileSystemResource("/dev/null")));
|
||||||
new Location(new FileSystemResource("/dev/null"))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -69,8 +69,7 @@ class ConfigurationModelBeanDefinitionReader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a particular {@link ConfigurationClass}, registering bean definitions for the
|
* Reads a particular {@link ConfigurationClass}, registering bean definitions for the
|
||||||
* class itself, all its {@link Bean} methods and all its {@link Extension}
|
* class itself, all its {@link Bean} methods
|
||||||
* annotations.
|
|
||||||
*/
|
*/
|
||||||
private void loadBeanDefinitionsForConfigurationClass(ConfigurationClass configClass) {
|
private void loadBeanDefinitionsForConfigurationClass(ConfigurationClass configClass) {
|
||||||
doLoadBeanDefinitionForConfigurationClass(configClass);
|
doLoadBeanDefinitionForConfigurationClass(configClass);
|
||||||
|
|
@ -90,18 +89,6 @@ class ConfigurationModelBeanDefinitionReader {
|
||||||
*/
|
*/
|
||||||
private void doLoadBeanDefinitionForConfigurationClass(ConfigurationClass configClass) {
|
private void doLoadBeanDefinitionForConfigurationClass(ConfigurationClass configClass) {
|
||||||
|
|
||||||
// TODO: prune support for @Required
|
|
||||||
// Configuration metadata = configClass.getMetadata();
|
|
||||||
// if (metadata.checkRequired() == true) {
|
|
||||||
// RootBeanDefinition requiredAnnotationPostProcessor = new RootBeanDefinition();
|
|
||||||
// Class<?> beanClass = RequiredAnnotationBeanPostProcessor.class;
|
|
||||||
// String beanName = beanClass.getName() + "#0";
|
|
||||||
// requiredAnnotationPostProcessor.setBeanClass(beanClass);
|
|
||||||
// requiredAnnotationPostProcessor
|
|
||||||
// .setResourceDescription("ensures @Required methods have been invoked");
|
|
||||||
// registry.registerBeanDefinition(beanName, requiredAnnotationPostProcessor);
|
|
||||||
// }
|
|
||||||
|
|
||||||
GenericBeanDefinition configBeanDef = new GenericBeanDefinition();
|
GenericBeanDefinition configBeanDef = new GenericBeanDefinition();
|
||||||
configBeanDef.setBeanClassName(configClass.getName());
|
configBeanDef.setBeanClassName(configClass.getName());
|
||||||
|
|
||||||
|
|
@ -111,11 +98,9 @@ class ConfigurationModelBeanDefinitionReader {
|
||||||
// and potentially has PropertyValues and ConstructorArgs)
|
// and potentially has PropertyValues and ConstructorArgs)
|
||||||
if (registry.containsBeanDefinition(configBeanName)) {
|
if (registry.containsBeanDefinition(configBeanName)) {
|
||||||
if (log.isInfoEnabled())
|
if (log.isInfoEnabled())
|
||||||
log.info(format(
|
log.info(format("Copying property and constructor arg values from existing bean definition for "
|
||||||
"Copying property and constructor arg values from existing bean definition for "
|
+ "@Configuration class %s to new bean definition", configBeanName));
|
||||||
+ "@Configuration class %s to new bean definition", configBeanName));
|
AbstractBeanDefinition existing = (AbstractBeanDefinition) registry.getBeanDefinition(configBeanName);
|
||||||
AbstractBeanDefinition existing =
|
|
||||||
(AbstractBeanDefinition) registry.getBeanDefinition(configBeanName);
|
|
||||||
configBeanDef.setPropertyValues(existing.getPropertyValues());
|
configBeanDef.setPropertyValues(existing.getPropertyValues());
|
||||||
configBeanDef.setConstructorArgumentValues(existing.getConstructorArgumentValues());
|
configBeanDef.setConstructorArgumentValues(existing.getConstructorArgumentValues());
|
||||||
configBeanDef.setResource(existing.getResource());
|
configBeanDef.setResource(existing.getResource());
|
||||||
|
|
@ -127,14 +112,12 @@ class ConfigurationModelBeanDefinitionReader {
|
||||||
registry.registerBeanDefinition(configBeanName, configBeanDef);
|
registry.registerBeanDefinition(configBeanName, configBeanDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a particular {@link BeanMethod}, registering bean definitions with
|
* Reads a particular {@link BeanMethod}, registering bean definitions with
|
||||||
* {@link #registry} based on its contents.
|
* {@link #registry} based on its contents.
|
||||||
*/
|
*/
|
||||||
private void loadBeanDefinitionsForModelMethod(BeanMethod method) {
|
private void loadBeanDefinitionsForModelMethod(BeanMethod method) {
|
||||||
new BeanRegistrar().register(method, registry);
|
new BeanRegistrar().register(method, registry);
|
||||||
//method.getRegistrar().register(method, registry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @SuppressWarnings("unchecked")
|
// @SuppressWarnings("unchecked")
|
||||||
|
|
@ -170,5 +153,4 @@ class ConfigurationModelBeanDefinitionReader {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -76,7 +76,7 @@ public class ConfigurationParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigurationModel getConfigurationModel() {
|
public ConfigurationModel getConfigurationModel() {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -27,7 +27,6 @@ import org.springframework.util.ClassUtils;
|
||||||
*
|
*
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
// TODO: Consider eliminating in favor of just ConfigurationClass
|
|
||||||
class ModelClass implements BeanMetadataElement {
|
class ModelClass implements BeanMetadataElement {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
@ -161,3 +160,5 @@ class ModelClass implements BeanMetadataElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Consider eliminating in favor of just ConfigurationClass
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,16 +22,11 @@ import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.objectweb.asm.AnnotationVisitor;
|
import org.objectweb.asm.AnnotationVisitor;
|
||||||
|
|
||||||
|
|
||||||
/** TODO: JAVADOC */
|
|
||||||
class MutableAnnotationArrayVisitor extends AnnotationAdapter {
|
class MutableAnnotationArrayVisitor extends AnnotationAdapter {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(MutableAnnotationArrayVisitor.class);
|
|
||||||
|
|
||||||
private final ArrayList<Object> values = new ArrayList<Object>();
|
private final ArrayList<Object> values = new ArrayList<Object>();
|
||||||
private final MutableAnnotation mutableAnno;
|
private final MutableAnnotation mutableAnno;
|
||||||
private final String attribName;
|
private final String attribName;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -30,7 +30,6 @@ import org.springframework.util.ReflectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
|
||||||
/** TODO: JAVADOC */
|
|
||||||
final class MutableAnnotationInvocationHandler implements InvocationHandler {
|
final class MutableAnnotationInvocationHandler implements InvocationHandler {
|
||||||
|
|
||||||
private final Class<? extends Annotation> annoType;
|
private final Class<? extends Annotation> annoType;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -19,7 +19,6 @@ import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
|
|
||||||
|
|
||||||
/** TODO: JAVADOC */
|
|
||||||
class MutableAnnotationUtils {
|
class MutableAnnotationUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -21,8 +21,6 @@ import static org.springframework.config.java.support.Util.*;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.objectweb.asm.AnnotationVisitor;
|
import org.objectweb.asm.AnnotationVisitor;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
@ -33,8 +31,6 @@ import org.springframework.util.Assert;
|
||||||
*/
|
*/
|
||||||
class MutableAnnotationVisitor implements AnnotationVisitor {
|
class MutableAnnotationVisitor implements AnnotationVisitor {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(MutableAnnotationVisitor.class);
|
|
||||||
|
|
||||||
protected final MutableAnnotation mutableAnno;
|
protected final MutableAnnotation mutableAnno;
|
||||||
|
|
||||||
private final ClassLoader classLoader;
|
private final ClassLoader classLoader;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
package org.springframework.config.java.support;
|
||||||
|
|
||||||
import static java.lang.String.*;
|
import static java.lang.String.*;
|
||||||
|
|
@ -20,10 +35,6 @@ import sun.security.x509.Extension;
|
||||||
*
|
*
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
// TODO: SJC-242 general - check cycles with s101
|
|
||||||
// TODO: SJC-242 general - check tabs & spaces
|
|
||||||
// TODO: SJC-242 general - check apache header
|
|
||||||
// TODO: SJC-242 rename, repackage, document
|
|
||||||
class Util {
|
class Util {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(Util.class);
|
private static final Log log = LogFactory.getLog(Util.class);
|
||||||
|
|
@ -158,8 +169,8 @@ class Util {
|
||||||
InputStream is = classLoader.getResourceAsStream(classFileName);
|
InputStream is = classLoader.getResourceAsStream(classFileName);
|
||||||
|
|
||||||
if (is == null)
|
if (is == null)
|
||||||
throw new RuntimeException(new FileNotFoundException("Class file [" + classFileName
|
throw new RuntimeException(
|
||||||
+ "] not found"));
|
new FileNotFoundException("Class file [" + classFileName + "] not found"));
|
||||||
|
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue