/** * Return an EmptyTargetSource for the given target Class. * @param targetClass the target Class (may be {@code null}) * @param isStatic whether the TargetSource should be marked as static * @see #getTargetClass() */ public static EmptyTargetSource forClass(@Nullable Class<?> targetClass, boolean isStatic) { return (targetClass == null && isStatic ? INSTANCE : new EmptyTargetSource(targetClass, isStatic)); }
/** * Return an EmptyTargetSource for the given target Class. * @param targetClass the target Class (may be {@code null}) * @see #getTargetClass() */ public static EmptyTargetSource forClass(@Nullable Class<?> targetClass) { return forClass(targetClass, true); }
/** * Set a target class to be proxied, indicating that the proxy * should be castable to the given class. * <p>Internally, an {@link org.springframework.aop.target.EmptyTargetSource} * for the given target class will be used. The kind of proxy needed * will be determined on actual creation of the proxy. * <p>This is a replacement for setting a "targetSource" or "target", * for the case where we want a proxy based on a target class * (which can be an interface or a concrete class) without having * a fully capable TargetSource available. * @see #setTargetSource * @see #setTarget */ public void setTargetClass(@Nullable Class<?> targetClass) { this.targetSource = EmptyTargetSource.forClass(targetClass); }
/** * Return an EmptyTargetSource for the given target Class. * @param targetClass the target Class (may be {@code null}) * @param isStatic whether the TargetSource should be marked as static * @see #getTargetClass() */ public static EmptyTargetSource forClass(Class<?> targetClass, boolean isStatic) { return (targetClass == null && isStatic ? INSTANCE : new EmptyTargetSource(targetClass, isStatic)); }
/** * Replaces this object with a SingletonTargetSource on serialization. * Protected as otherwise it won't be invoked for subclasses. * (The {@code writeReplace()} method must be visible to the class * being serialized.) * <p>With this implementation of this method, there is no need to mark * non-serializable fields in this class or subclasses as transient. */ protected Object writeReplace() throws ObjectStreamException { if (logger.isDebugEnabled()) { logger.debug("Disconnecting TargetSource [" + this + "]"); } try { // Create disconnected SingletonTargetSource/EmptyTargetSource. Object target = getTarget(); return (target != null ? new SingletonTargetSource(target) : EmptyTargetSource.forClass(getTargetClass())); } catch (Exception ex) { String msg = "Cannot get target for disconnecting TargetSource [" + this + "]"; logger.error(msg, ex); throw new NotSerializableException(msg + ": " + ex); } }
/** * Return an EmptyTargetSource for the given target Class. * @param targetClass the target Class (may be {@code null}) * @param isStatic whether the TargetSource should be marked as static * @see #getTargetClass() */ public static EmptyTargetSource forClass(@Nullable Class<?> targetClass, boolean isStatic) { return (targetClass == null && isStatic ? INSTANCE : new EmptyTargetSource(targetClass, isStatic)); }
/** * Build a configuration-only copy of this AdvisedSupport, * replacing the TargetSource. */ AdvisedSupport getConfigurationOnlyCopy() { AdvisedSupport copy = new AdvisedSupport(); copy.copyFrom(this); copy.targetSource = EmptyTargetSource.forClass(getTargetClass(), getTargetSource().isStatic()); copy.advisorChainFactory = this.advisorChainFactory; copy.interfaces = this.interfaces; copy.advisors = this.advisors; copy.updateAdvisorArray(); return copy; }
/** * Return an EmptyTargetSource for the given target Class. * @param targetClass the target Class (may be {@code null}) * @see #getTargetClass() */ public static EmptyTargetSource forClass(Class<?> targetClass) { return forClass(targetClass, true); }
/** * Set a target class to be proxied, indicating that the proxy * should be castable to the given class. * <p>Internally, an {@link org.springframework.aop.target.EmptyTargetSource} * for the given target class will be used. The kind of proxy needed * will be determined on actual creation of the proxy. * <p>This is a replacement for setting a "targetSource" or "target", * for the case where we want a proxy based on a target class * (which can be an interface or a concrete class) without having * a fully capable TargetSource available. * @see #setTargetSource * @see #setTarget */ public void setTargetClass(Class<?> targetClass) { this.targetSource = EmptyTargetSource.forClass(targetClass); }
/** * Return an EmptyTargetSource for the given target Class. * @param targetClass the target Class (may be {@code null}) * @see #getTargetClass() */ public static EmptyTargetSource forClass(@Nullable Class<?> targetClass) { return forClass(targetClass, true); }
/** * Set a target class to be proxied, indicating that the proxy * should be castable to the given class. * <p>Internally, an {@link org.springframework.aop.target.EmptyTargetSource} * for the given target class will be used. The kind of proxy needed * will be determined on actual creation of the proxy. * <p>This is a replacement for setting a "targetSource" or "target", * for the case where we want a proxy based on a target class * (which can be an interface or a concrete class) without having * a fully capable TargetSource available. * @see #setTargetSource * @see #setTarget */ public void setTargetClass(@Nullable Class<?> targetClass) { this.targetSource = EmptyTargetSource.forClass(targetClass); }
/** * Replaces this object with a SingletonTargetSource on serialization. * Protected as otherwise it won't be invoked for subclasses. * (The {@code writeReplace()} method must be visible to the class * being serialized.) * <p>With this implementation of this method, there is no need to mark * non-serializable fields in this class or subclasses as transient. */ protected Object writeReplace() throws ObjectStreamException { if (logger.isDebugEnabled()) { logger.debug("Disconnecting TargetSource [" + this + "]"); } try { // Create disconnected SingletonTargetSource/EmptyTargetSource. Object target = getTarget(); return (target != null ? new SingletonTargetSource(target) : EmptyTargetSource.forClass(getTargetClass())); } catch (Exception ex) { String msg = "Cannot get target for disconnecting TargetSource [" + this + "]"; logger.error(msg, ex); throw new NotSerializableException(msg + ": " + ex); } }
/** * Build a configuration-only copy of this AdvisedSupport, * replacing the TargetSource. */ AdvisedSupport getConfigurationOnlyCopy() { AdvisedSupport copy = new AdvisedSupport(); copy.copyFrom(this); copy.targetSource = EmptyTargetSource.forClass(getTargetClass(), getTargetSource().isStatic()); copy.advisorChainFactory = this.advisorChainFactory; copy.interfaces = this.interfaces; copy.advisors = this.advisors; copy.updateAdvisorArray(); return copy; }
/** * Build a configuration-only copy of this AdvisedSupport, * replacing the TargetSource. */ AdvisedSupport getConfigurationOnlyCopy() { AdvisedSupport copy = new AdvisedSupport(); copy.copyFrom(this); copy.targetSource = EmptyTargetSource.forClass(getTargetClass(), getTargetSource().isStatic()); copy.advisorChainFactory = this.advisorChainFactory; copy.interfaces = this.interfaces; copy.advisors = this.advisors; copy.updateAdvisorArray(); return copy; }