diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/TargetClassAware.java b/org.springframework.aop/src/main/java/org/springframework/aop/TargetClassAware.java
index 994e5c43b52..5334ae26fff 100644
--- a/org.springframework.aop/src/main/java/org/springframework/aop/TargetClassAware.java
+++ b/org.springframework.aop/src/main/java/org/springframework/aop/TargetClassAware.java
@@ -34,6 +34,6 @@ public interface TargetClassAware {
* (typically a proxy configuration or an actual proxy).
* @return the target Class, or null if not known
*/
- Class getTargetClass();
+ Class> getTargetClass();
}
diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/TargetSource.java b/org.springframework.aop/src/main/java/org/springframework/aop/TargetSource.java
index 7d2604c29da..f5be5fdb9b1 100644
--- a/org.springframework.aop/src/main/java/org/springframework/aop/TargetSource.java
+++ b/org.springframework.aop/src/main/java/org/springframework/aop/TargetSource.java
@@ -1,5 +1,5 @@
/*<
- * Copyright 2002-2007 the original author or authors.
+ * Copyright 2002-2010 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.
@@ -39,7 +39,7 @@ public interface TargetSource extends TargetClassAware {
* target class.
* @return the type of targets returned by this {@link TargetSource}
*/
- Class getTargetClass();
+ Class> getTargetClass();
/**
* Will all calls to {@link #getTarget()} return the same object?
diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java b/org.springframework.aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java
index c550afb7e7c..ebb59896ec6 100644
--- a/org.springframework.aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java
+++ b/org.springframework.aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2010 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.
@@ -162,7 +162,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
this.targetSource = EmptyTargetSource.forClass(targetClass);
}
- public Class getTargetClass() {
+ public Class> getTargetClass() {
return this.targetSource.getTargetClass();
}
diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/target/AbstractBeanFactoryBasedTargetSource.java b/org.springframework.aop/src/main/java/org/springframework/aop/target/AbstractBeanFactoryBasedTargetSource.java
index 2bd3e3b44c5..2980b0bf426 100644
--- a/org.springframework.aop/src/main/java/org/springframework/aop/target/AbstractBeanFactoryBasedTargetSource.java
+++ b/org.springframework.aop/src/main/java/org/springframework/aop/target/AbstractBeanFactoryBasedTargetSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2010 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.
@@ -16,15 +16,12 @@
package org.springframework.aop.target;
-import java.io.NotSerializableException;
-import java.io.ObjectStreamException;
import java.io.Serializable;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.TargetSource;
-import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.util.ClassUtils;
@@ -65,7 +62,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource
private String targetBeanName;
/** Class of the target */
- private Class targetClass;
+ private Class> targetClass;
/**
* BeanFactory that owns this TargetSource. We need to hold onto this
@@ -108,7 +105,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource
* Set the owning BeanFactory. We need to save a reference so that we can
* use the getBean method on every invocation.
*/
- public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+ public void setBeanFactory(BeanFactory beanFactory) {
if (this.targetBeanName == null) {
throw new IllegalStateException("Property'targetBeanName' is required");
}
@@ -123,7 +120,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource
}
- public synchronized Class getTargetClass() {
+ public synchronized Class> getTargetClass() {
if (this.targetClass == null && this.beanFactory != null) {
// Determine type of the target bean.
this.targetClass = this.beanFactory.getType(this.targetBeanName);
@@ -131,7 +128,10 @@ public abstract class AbstractBeanFactoryBasedTargetSource
if (logger.isTraceEnabled()) {
logger.trace("Getting bean with name '" + this.targetBeanName + "' in order to determine type");
}
- this.targetClass = this.beanFactory.getBean(this.targetBeanName).getClass();
+ Object beanInstance = this.beanFactory.getBean(this.targetBeanName);
+ if (beanInstance != null) {
+ this.targetClass = beanInstance.getClass();
+ }
}
}
return this.targetClass;
diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/target/AbstractLazyCreationTargetSource.java b/org.springframework.aop/src/main/java/org/springframework/aop/target/AbstractLazyCreationTargetSource.java
index 647a67937e3..3119e847f1b 100644
--- a/org.springframework.aop/src/main/java/org/springframework/aop/target/AbstractLazyCreationTargetSource.java
+++ b/org.springframework.aop/src/main/java/org/springframework/aop/target/AbstractLazyCreationTargetSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 the original author or authors.
+ * Copyright 2002-2010 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.
@@ -64,7 +64,7 @@ public abstract class AbstractLazyCreationTargetSource implements TargetSource {
* a meaningful value when the target is still null.
* @see #isInitialized()
*/
- public synchronized Class getTargetClass() {
+ public synchronized Class> getTargetClass() {
return (this.lazyTarget != null ? this.lazyTarget.getClass() : null);
}
diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java b/org.springframework.aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java
index 889bea66d3b..d67b03f0f3c 100644
--- a/org.springframework.aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java
+++ b/org.springframework.aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 the original author or authors.
+ * Copyright 2002-2010 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.
@@ -89,7 +89,7 @@ public class EmptyTargetSource implements TargetSource, Serializable {
/**
* Always returns the specified target Class, or null if none.
*/
- public Class getTargetClass() {
+ public Class> getTargetClass() {
return this.targetClass;
}
diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/target/HotSwappableTargetSource.java b/org.springframework.aop/src/main/java/org/springframework/aop/target/HotSwappableTargetSource.java
index a2aa38943c5..14c32af6e26 100644
--- a/org.springframework.aop/src/main/java/org/springframework/aop/target/HotSwappableTargetSource.java
+++ b/org.springframework.aop/src/main/java/org/springframework/aop/target/HotSwappableTargetSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 the original author or authors.
+ * Copyright 2002-2010 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.
@@ -59,7 +59,7 @@ public class HotSwappableTargetSource implements TargetSource, Serializable {
* Return the type of the current target object.
*
The returned type should usually be constant across all target objects. */ - public synchronized Class getTargetClass() { + public synchronized Class> getTargetClass() { return this.target.getClass(); } diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/target/SingletonTargetSource.java b/org.springframework.aop/src/main/java/org/springframework/aop/target/SingletonTargetSource.java index 26b1edc9bb4..08ae6534a64 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/target/SingletonTargetSource.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/target/SingletonTargetSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2010 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. @@ -55,7 +55,7 @@ public class SingletonTargetSource implements TargetSource, Serializable { } - public Class getTargetClass() { + public Class> getTargetClass() { return this.target.getClass(); } diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/target/dynamic/AbstractRefreshableTargetSource.java b/org.springframework.aop/src/main/java/org/springframework/aop/target/dynamic/AbstractRefreshableTargetSource.java index 04449566cf9..befbcf39392 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/target/dynamic/AbstractRefreshableTargetSource.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/target/dynamic/AbstractRefreshableTargetSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 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. @@ -63,7 +63,7 @@ public abstract class AbstractRefreshableTargetSource implements TargetSource, R } - public synchronized Class getTargetClass() { + public synchronized Class> getTargetClass() { if (this.targetObject == null) { refresh(); }