List of usage examples for org.springframework.aop.framework AopConfigException AopConfigException
public AopConfigException(String msg)
From source file:org.openinfinity.core.util.AspectUtil.java
/** * Returns the specified annotation.// ww w . j a va 2 s . c om * * @param joinPoint Represents the join point. * @return * @return LogLevel representing the log level. */ public static <T extends Annotation> T getAnnotation(JoinPoint joinPoint, Class<T> requiredAnnotationClass) { Method[] methods = joinPoint.getTarget().getClass().getMethods(); for (Method method : methods) { if (method.getName().equals(joinPoint.getSignature().getName())) { Annotation[] annotations = method.getDeclaredAnnotations(); for (Annotation annotation : annotations) { if (requiredAnnotationClass.isAssignableFrom(annotation.getClass())) { return (T) annotation; } } } } throw new SystemException(new AopConfigException("Annotation not found.")); }
From source file:org.springmodules.cache.interceptor.caching.CachingAttributeSourceAdvisor.java
public CachingAttributeSourceAdvisor(MetadataCachingInterceptor i) { super(i);/*from w ww . j a v a2s . com*/ CachingAttributeSource source = i.getCachingAttributeSource(); if (source == null) throw new AopConfigException("<" + i.getClass().getName() + "> has no <" + CachingAttributeSource.class.getName() + "> configured"); cachingAttributeSource = source; }
From source file:org.springmodules.cache.interceptor.flush.FlushingModelSourceAdvisor.java
/** * @param interceptor// ww w. j a v a 2 s . c om * Advice that caches the returned value of intercepted methods. * @throws AopConfigException * if the <code>FlushingAttributeSource</code> of * <code>cacheInterceptor</code> is <code>null</code>. */ public FlushingModelSourceAdvisor(NameMatchFlushingInterceptor interceptor) { super(interceptor); FlushingModelSource tempSource = interceptor.getFlushingModelSource(); if (tempSource == null) { throw new AopConfigException("<" + interceptor.getClass().getName() + "> has no <" + FlushingModelSource.class.getName() + "> configured"); } flushingModelSource = tempSource; }
From source file:org.springmodules.cache.interceptor.flush.FlushingAttributeSourceAdvisor.java
/** * @param cacheInterceptor/* www .j av a 2 s . c o m*/ * Advice that caches the returned values of intercepted methods. * @throws AopConfigException * if the <code>CacheFlushAttributeSource</code> of * <code>cacheInterceptor</code> is <code>null</code>. */ public FlushingAttributeSourceAdvisor(MetadataFlushingInterceptor cacheInterceptor) { super(cacheInterceptor); FlushingAttributeSource tempAttributeSource = cacheInterceptor.getFlushingAttributeSource(); if (tempAttributeSource == null) { throw new AopConfigException("Cannot construct a CacheFlushAttributeSourceAdvisor using a " + "CacheFlushInterceptor that has no CacheFlushAttributeSource configured"); } cacheFlushAttributeSource = tempAttributeSource; }
From source file:org.springmodules.cache.interceptor.caching.CachingModelSourceAdvisor.java
/** * Construct a <code>CachingModelSourceAdvisor</code>. * /*from ww w. j ava2s. c o m*/ * @param interceptor * Advice that caches the returned value of intercepted methods. * @throws AopConfigException * if the <code>CachingAttributeSource</code> of * <code>cacheInterceptor</code> is <code>null</code>. */ public CachingModelSourceAdvisor(NameMatchCachingInterceptor interceptor) { super(interceptor); CachingModelSource tempSource = interceptor.getCachingModelSource(); if (tempSource == null) { throw new AopConfigException("<" + interceptor.getClass().getName() + "> has no <" + CachingModelSource.class.getName() + "> configured"); } cachingModelSource = tempSource; }
From source file:org.springmodules.cache.interceptor.proxy.CacheProxyFactoryBean.java
/** * Creates the proxy for target object. This method is invoked by a * BeanFactory after it has set all bean properties supplied. * //from w w w . j a va 2s .co m * @throws IllegalStateException * if target is <code>null</code>. * @throws AopConfigException * if the proxy interfaces or proxyTargetClass are not set and the * target type is <code>org.springframework.aop.TargetSource</code>. */ public void afterPropertiesSet() throws IllegalStateException, AopConfigException { cachingInterceptor.afterPropertiesSet(); flushingInterceptor.afterPropertiesSet(); if (target == null) { throw new IllegalStateException("Property 'target' is required"); } ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.addAdvisor(new CachingModelSourceAdvisor(cachingInterceptor)); if (hasFlushingModels) { proxyFactory.addAdvisor(new FlushingModelSourceAdvisor(flushingInterceptor)); } proxyFactory.copyFrom(this); TargetSource targetSource = createTargetSource(target); proxyFactory.setTargetSource(targetSource); if (proxyInterfaces != null) { proxyFactory.setInterfaces(proxyInterfaces); } else if (!isProxyTargetClass()) { if (target instanceof TargetSource) { throw new AopConfigException("Either 'proxyInterfaces' or 'proxyTargetClass' is required " + "when using a TargetSource as 'target'"); } // rely on AOP infrastructure to tell us what interfaces to proxy proxyFactory.setInterfaces(ClassUtils.getAllInterfaces(target)); } proxy = proxyFactory.getProxy(); }
From source file:org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.java
@Override public void validate(Class<?> aspectClass) throws AopConfigException { // If the parent has the annotation and isn't abstract it's an error if (aspectClass.getSuperclass().getAnnotation(Aspect.class) != null && !Modifier.isAbstract(aspectClass.getSuperclass().getModifiers())) { throw new AopConfigException("[" + aspectClass.getName() + "] cannot extend concrete aspect [" + aspectClass.getSuperclass().getName() + "]"); }/*from ww w .j a v a2s. c o m*/ AjType<?> ajType = AjTypeSystem.getAjType(aspectClass); if (!ajType.isAspect()) { throw new NotAnAtAspectException(aspectClass); } if (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOW) { throw new AopConfigException(aspectClass.getName() + " uses percflow instantiation model: " + "This is not supported in Spring AOP."); } if (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOWBELOW) { throw new AopConfigException(aspectClass.getName() + " uses percflowbelow instantiation model: " + "This is not supported in Spring AOP."); } }
From source file:org.springframework.aop.framework.AdvisedSupport.java
public void setTargetSource(TargetSource targetSource) { if (isActive() && isOptimize()) { throw new AopConfigException( "Cannot change target with an optimized CGLIB proxy: It has its own target."); }//w w w . j av a 2 s .co m this.targetSource = (targetSource != null ? targetSource : EMPTY_TARGET_SOURCE); }
From source file:org.springframework.aop.framework.AdvisedSupport.java
public void removeAdvisor(int index) throws AopConfigException { if (isFrozen()) { throw new AopConfigException("Cannot remove Advisor: Configuration is frozen."); }/*from www .j ava 2s .co m*/ if (index < 0 || index > this.advisors.size() - 1) { throw new AopConfigException("Advisor index " + index + " is out of bounds: " + "This configuration only has " + this.advisors.size() + " advisors."); } Advisor advisor = (Advisor) this.advisors.get(index); if (advisor instanceof IntroductionAdvisor) { IntroductionAdvisor ia = (IntroductionAdvisor) advisor; // we need to remove interfaces for (int j = 0; j < ia.getInterfaces().length; j++) { removeInterface(ia.getInterfaces()[j]); } } this.advisors.remove(index); updateAdvisorArray(); adviceChanged(); }
From source file:org.springframework.aop.framework.AdvisedSupport.java
private void addAdvisorInternal(int pos, Advisor advice) throws AopConfigException { if (isFrozen()) { throw new AopConfigException("Cannot add advisor: Configuration is frozen."); }/*from ww w . ja v a 2 s . c o m*/ if (pos > this.advisors.size()) { throw new IllegalArgumentException( "Illegal position " + pos + " in advisor list with size " + this.advisors.size()); } this.advisors.add(pos, advice); updateAdvisorArray(); adviceChanged(); }