List of usage examples for org.springframework.aop.framework AopConfigException AopConfigException
public AopConfigException(String msg)
From source file:org.springframework.aop.framework.AdvisedSupport.java
/** * Cannot add introductions this way unless the advice implements IntroductionInfo. */// w ww . jav a2s. co m public void addAdvice(int pos, Advice advice) throws AopConfigException { if (advice instanceof Interceptor && !(advice instanceof MethodInterceptor)) { throw new AopConfigException(getClass().getName() + " only handles AOP Alliance MethodInterceptors"); } if (advice instanceof IntroductionInfo) { // We don't need an IntroductionAdvisor for this kind of introduction: // It's fully self-describing. addAdvisor(pos, new DefaultIntroductionAdvisor(advice, (IntroductionInfo) advice)); } else if (advice instanceof DynamicIntroductionAdvice) { // We need an IntroductionAdvisor for this kind of introduction. throw new AopConfigException( "DynamicIntroductionAdvice may only be added as part of IntroductionAdvisor"); } else { addAdvisor(pos, new DefaultPointcutAdvisor(advice)); } }
From source file:org.springframework.aop.framework.autoproxy.metadata.ModifiableAdvisor.java
/** * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() *//* w w w . jav a2 s.c o m*/ public void afterPropertiesSet() throws Exception { if (this.attributes == null) throw new AopConfigException("Must set Attributes property on ModifiableAdvice"); }
From source file:org.springframework.aop.framework.Cglib2AopProxy.java
/** * Create a new Cglib2AopProxy for the given AOP configuration. * @throws AopConfigException if the config is invalid. We try to throw an informative * exception in this case, rather than let a mysterious failure happen later. *//*from www . j a v a 2s . c om*/ protected Cglib2AopProxy(AdvisedSupport config) throws AopConfigException { if (config == null) { throw new AopConfigException("Cannot create AopProxy with null ProxyConfig"); } if (config.getAdvisors().length == 0 && config.getTargetSource() == AdvisedSupport.EMPTY_TARGET_SOURCE) { throw new AopConfigException("Cannot create AopProxy with no advisors and no target source"); } //DK - is this check really necessary? //should this 'config.getTargetSource() == AdvisedSupport.EMPTY_TARGET_SOURCE' be enough? if (config.getTargetSource().getTargetClass() == null) { throw new AopConfigException("Either an interface or a target is required for proxy creation"); } this.advised = config; }
From source file:org.springframework.aop.framework.CglibAopProxy.java
/** * Create a new CglibAopProxy for the given AOP configuration. * @param config the AOP configuration as AdvisedSupport object * @throws AopConfigException if the config is invalid. We try to throw an informative * exception in this case, rather than let a mysterious failure happen later. */// w ww . j av a 2s . c o m public CglibAopProxy(AdvisedSupport config) throws AopConfigException { Assert.notNull(config, "AdvisedSupport must not be null"); if (config.getAdvisors().length == 0 && config.getTargetSource() == AdvisedSupport.EMPTY_TARGET_SOURCE) { throw new AopConfigException("No advisors and no TargetSource specified"); } this.advised = config; this.advisedDispatcher = new AdvisedDispatcher(this.advised); }
From source file:org.springframework.aop.framework.DefaultAopProxyFactory.java
public AopProxy createAopProxy(AdvisedSupport advisedSupport) throws AopConfigException { if (advisedSupport.isOptimize() || advisedSupport.isProxyTargetClass() || advisedSupport.getProxiedInterfaces().length == 0) { if (!cglibAvailable) { throw new AopConfigException("Cannot proxy target class because CGLIB2 is not available. " + "Add CGLIB to the class path or specify proxy interfaces."); }// w w w.j av a 2s .co m return CglibProxyFactory.createCglibProxy(advisedSupport); } else { return new JdkDynamicAopProxy(advisedSupport); } }
From source file:org.springframework.aop.framework.JdkDynamicAopProxy.java
/** * Construct a new JdkDynamicAopProxy for the given AOP configuration. * @param config the AOP configuration as AdvisedSupport object * @throws AopConfigException if the config is invalid. We try to throw an informative * exception in this case, rather than let a mysterious failure happen later. */// w ww . j a va 2 s .c o m public JdkDynamicAopProxy(AdvisedSupport config) throws AopConfigException { Assert.notNull(config, "AdvisedSupport must not be null"); if (config.getAdvisors().length == 0 && config.getTargetSource() == AdvisedSupport.EMPTY_TARGET_SOURCE) { throw new AopConfigException("No advisors and no TargetSource specified"); } this.advised = config; }
From source file:org.springframework.aop.framework.OptimizedJdkDynamicAopProxy.java
/** * Construct a new JDK proxy.// w ww . j a v a 2 s .c om * @throws AopConfigException if the config is invalid. We try * to throw an informative exception in this case, rather than let * a mysterious failure happen later. */ protected OptimizedJdkDynamicAopProxy(AdvisedSupport config) throws AopConfigException { if (config == null) throw new AopConfigException("Cannot create AopProxy with null ProxyConfig"); if (config.getAdvisors().length == 0 && config.getTargetSource() == AdvisedSupport.EMPTY_TARGET_SOURCE) throw new AopConfigException("Cannot create AopProxy with no advisors and no target source"); this.advised = config; this.advisors = config.getAdvisors(); if (!config.targetSource.isStatic()) { throw new AopConfigException("Can't use Optimized JDK proxy with non-static target source"); } if (config.exposeProxy) { throw new AopConfigException("Can't use Optimized JDK proxy if proxy needs to be exposed"); } try { // TODO must be frozen System.err.println("Caching lockable target"); this.target = config.targetSource.getTarget(); this.targetClass = target.getClass(); } catch (Exception ex) { throw new AopConfigException("Can't obtain target from static TargetSource", ex); } }
From source file:org.springframework.aop.framework.ProxyFactoryBean.java
/** * Create the advisor (interceptor) chain. Advisors that are sourced * from a BeanFactory will be refreshed each time a new prototype instance * is added. Interceptors added programmatically through the factory API * are unaffected by such changes./*w w w . j a v a 2s. co m*/ */ private synchronized void initializeAdvisorChain() throws AopConfigException, BeansException { if (this.advisorChainInitialized) { return; } if (!ObjectUtils.isEmpty(this.interceptorNames)) { if (this.beanFactory == null) { throw new IllegalStateException("No BeanFactory available anymore (probably due to serialization) " + "- cannot resolve interceptor names " + Arrays.asList(this.interceptorNames)); } // Globals can't be last unless we specified a targetSource using the property... if (this.interceptorNames[this.interceptorNames.length - 1].endsWith(GLOBAL_SUFFIX) && this.targetName == null && this.targetSource == EMPTY_TARGET_SOURCE) { throw new AopConfigException("Target required after globals"); } // Materialize interceptor chain from bean names. for (String name : this.interceptorNames) { if (logger.isTraceEnabled()) { logger.trace("Configuring advisor or advice '" + name + "'"); } if (name.endsWith(GLOBAL_SUFFIX)) { if (!(this.beanFactory instanceof ListableBeanFactory)) { throw new AopConfigException( "Can only use global advisors or interceptors with a ListableBeanFactory"); } addGlobalAdvisor((ListableBeanFactory) this.beanFactory, name.substring(0, name.length() - GLOBAL_SUFFIX.length())); } else { // If we get here, we need to add a named interceptor. // We must check if it's a singleton or prototype. Object advice; if (this.singleton || this.beanFactory.isSingleton(name)) { // Add the real Advisor/Advice to the chain. advice = this.beanFactory.getBean(name); } else { // It's a prototype Advice or Advisor: replace with a prototype. // Avoid unnecessary creation of prototype bean just for advisor chain initialization. advice = new PrototypePlaceholderAdvisor(name); } addAdvisorOnChainCreation(advice, name); } } } this.advisorChainInitialized = true; }