All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dynamicextensionsalfresco.aop.MethodAnnotationPointcutAdvisor Maven / Gradle / Ivy

Go to download

Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features

There is a newer version: 3.1.0
Show newest version
package com.github.dynamicextensionsalfresco.aop;

import java.lang.annotation.Annotation;

import org.aopalliance.aop.Advice;
import org.springframework.aop.Pointcut;
import org.springframework.aop.PointcutAdvisor;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.util.Assert;

/**
 * Convenience base class for {@link PointcutAdvisor}s that advise methods annotated with a given annotation.
 * 
 * @author Laurens Fridael
 * 
 */
public class MethodAnnotationPointcutAdvisor implements PointcutAdvisor, DynamicExtensionsAdvisor {

	/* Configuration */

	private final Pointcut pointcut;

	private Advice advice;

	/* Main operations */

	/**
	 * Constructs an instance using a {@link MethodAnnotationPointcut} for the given {@link Annotation} type.
	 * 
	 * @param annotationType
	 */
	protected MethodAnnotationPointcutAdvisor(final Class annotationType) {
		Assert.notNull(annotationType);
		pointcut = new MethodAnnotationPointcut(annotationType);
	}

	@Override
	public Pointcut getPointcut() {
		return pointcut;
	}

	@Override
	public boolean isPerInstance() {
		return false;
	}

	@Override
	public Advice getAdvice() {
		Assert.state(advice != null, "Advice has not been configured.");
		return advice;
	}

	/* Configuration */

	@Required
	public void setAdvice(final Advice advice) {
		Assert.notNull(advice);
		this.advice = advice;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy