Java Code Examples for org.aspectj.lang.reflect.AjType

The following examples show how to use org.aspectj.lang.reflect.AjType. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@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() + "]");
	}

	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.");
	}
}
 
Example 2
@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() + "]");
	}

	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.");
	}
}
 
Example 3
@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() + "]");
	}

	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.");
	}
}
 
Example 4
@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() + "]");
	}

	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.");
	}
}
 
Example 5
Source Project: spring-analysis-note   Source File: AspectMetadata.java    License: MIT License 4 votes vote down vote up
/**
 * Create a new AspectMetadata instance for the given aspect class.
 * @param aspectClass the aspect class
 * @param aspectName the name of the aspect
 */
public AspectMetadata(Class<?> aspectClass, String aspectName) {
	this.aspectName = aspectName;

	Class<?> currClass = aspectClass;
	AjType<?> ajType = null;
	while (currClass != Object.class) {
		AjType<?> ajTypeToCheck = AjTypeSystem.getAjType(currClass);
		if (ajTypeToCheck.isAspect()) {
			ajType = ajTypeToCheck;
			break;
		}
		currClass = currClass.getSuperclass();
	}
	if (ajType == null) {
		throw new IllegalArgumentException("Class '" + aspectClass.getName() + "' is not an @AspectJ aspect");
	}
	if (ajType.getDeclarePrecedence().length > 0) {
		throw new IllegalArgumentException("DeclarePrecendence not presently supported in Spring AOP");
	}
	this.aspectClass = ajType.getJavaClass();
	this.ajType = ajType;

	switch (this.ajType.getPerClause().getKind()) {
		case SINGLETON:
			this.perClausePointcut = Pointcut.TRUE;
			return;
		case PERTARGET:
		case PERTHIS:
			AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
			ajexp.setLocation(aspectClass.getName());
			ajexp.setExpression(findPerClause(aspectClass));
			ajexp.setPointcutDeclarationScope(aspectClass);
			this.perClausePointcut = ajexp;
			return;
		case PERTYPEWITHIN:
			// Works with a type pattern
			this.perClausePointcut = new ComposablePointcut(new TypePatternClassFilter(findPerClause(aspectClass)));
			return;
		default:
			throw new AopConfigException(
					"PerClause " + ajType.getPerClause().getKind() + " not supported by Spring AOP for " + aspectClass);
	}
}
 
Example 6
Source Project: spring-analysis-note   Source File: AspectMetadata.java    License: MIT License 4 votes vote down vote up
/**
 * Return AspectJ reflection information.
 */
public AjType<?> getAjType() {
	return this.ajType;
}
 
Example 7
Source Project: java-technology-stack   Source File: AspectMetadata.java    License: MIT License 4 votes vote down vote up
/**
 * Create a new AspectMetadata instance for the given aspect class.
 * @param aspectClass the aspect class
 * @param aspectName the name of the aspect
 */
public AspectMetadata(Class<?> aspectClass, String aspectName) {
	this.aspectName = aspectName;

	Class<?> currClass = aspectClass;
	AjType<?> ajType = null;
	while (currClass != Object.class) {
		AjType<?> ajTypeToCheck = AjTypeSystem.getAjType(currClass);
		if (ajTypeToCheck.isAspect()) {
			ajType = ajTypeToCheck;
			break;
		}
		currClass = currClass.getSuperclass();
	}
	if (ajType == null) {
		throw new IllegalArgumentException("Class '" + aspectClass.getName() + "' is not an @AspectJ aspect");
	}
	if (ajType.getDeclarePrecedence().length > 0) {
		throw new IllegalArgumentException("DeclarePrecendence not presently supported in Spring AOP");
	}
	this.aspectClass = ajType.getJavaClass();
	this.ajType = ajType;

	switch (this.ajType.getPerClause().getKind()) {
		case SINGLETON:
			this.perClausePointcut = Pointcut.TRUE;
			return;
		case PERTARGET:
		case PERTHIS:
			AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
			ajexp.setLocation(aspectClass.getName());
			ajexp.setExpression(findPerClause(aspectClass));
			ajexp.setPointcutDeclarationScope(aspectClass);
			this.perClausePointcut = ajexp;
			return;
		case PERTYPEWITHIN:
			// Works with a type pattern
			this.perClausePointcut = new ComposablePointcut(new TypePatternClassFilter(findPerClause(aspectClass)));
			return;
		default:
			throw new AopConfigException(
					"PerClause " + ajType.getPerClause().getKind() + " not supported by Spring AOP for " + aspectClass);
	}
}
 
Example 8
Source Project: java-technology-stack   Source File: AspectMetadata.java    License: MIT License 4 votes vote down vote up
/**
 * Return AspectJ reflection information.
 */
public AjType<?> getAjType() {
	return this.ajType;
}
 
Example 9
Source Project: lams   Source File: AspectMetadata.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a new AspectMetadata instance for the given aspect class.
 * @param aspectClass the aspect class
 * @param aspectName the name of the aspect
 */
public AspectMetadata(Class<?> aspectClass, String aspectName) {
	this.aspectName = aspectName;

	Class<?> currClass = aspectClass;
	AjType<?> ajType = null;
	while (currClass != Object.class) {
		AjType<?> ajTypeToCheck = AjTypeSystem.getAjType(currClass);
		if (ajTypeToCheck.isAspect()) {
			ajType = ajTypeToCheck;
			break;
		}
		currClass = currClass.getSuperclass();
	}
	if (ajType == null) {
		throw new IllegalArgumentException("Class '" + aspectClass.getName() + "' is not an @AspectJ aspect");
	}
	if (ajType.getDeclarePrecedence().length > 0) {
		throw new IllegalArgumentException("DeclarePrecendence not presently supported in Spring AOP");
	}
	this.aspectClass = ajType.getJavaClass();
	this.ajType = ajType;

	switch (this.ajType.getPerClause().getKind()) {
		case SINGLETON:
			this.perClausePointcut = Pointcut.TRUE;
			return;
		case PERTARGET:
		case PERTHIS:
			AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
			ajexp.setLocation(aspectClass.getName());
			ajexp.setExpression(findPerClause(aspectClass));
			ajexp.setPointcutDeclarationScope(aspectClass);
			this.perClausePointcut = ajexp;
			return;
		case PERTYPEWITHIN:
			// Works with a type pattern
			this.perClausePointcut = new ComposablePointcut(new TypePatternClassFilter(findPerClause(aspectClass)));
			return;
		default:
			throw new AopConfigException(
					"PerClause " + ajType.getPerClause().getKind() + " not supported by Spring AOP for " + aspectClass);
	}
}
 
Example 10
Source Project: lams   Source File: AspectMetadata.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return AspectJ reflection information.
 */
public AjType<?> getAjType() {
	return this.ajType;
}
 
Example 11
Source Project: spring4-understanding   Source File: AspectMetadata.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Create a new AspectMetadata instance for the given aspect class.
 * @param aspectClass the aspect class
 * @param aspectName the name of the aspect
 */
public AspectMetadata(Class<?> aspectClass, String aspectName) {
	this.aspectName = aspectName;

	Class<?> currClass = aspectClass;
	AjType<?> ajType = null;
	while (currClass != Object.class) {
		AjType<?> ajTypeToCheck = AjTypeSystem.getAjType(currClass);
		if (ajTypeToCheck.isAspect()) {
			ajType = ajTypeToCheck;
			break;
		}
		currClass = currClass.getSuperclass();
	}
	if (ajType == null) {
		throw new IllegalArgumentException("Class '" + aspectClass.getName() + "' is not an @AspectJ aspect");
	}
	this.ajType = ajType;
	if (this.ajType.getDeclarePrecedence().length > 0) {
		throw new IllegalArgumentException("DeclarePrecendence not presently supported in Spring AOP");
	}

	switch (this.ajType.getPerClause().getKind()) {
		case SINGLETON :
			this.perClausePointcut = Pointcut.TRUE;
			return;
		case PERTARGET : case PERTHIS :
			AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
			ajexp.setLocation("@Aspect annotation on " + aspectClass.getName());
			ajexp.setExpression(findPerClause(aspectClass));
			this.perClausePointcut = ajexp;
			return;
		case PERTYPEWITHIN :
			// Works with a type pattern
			this.perClausePointcut = new ComposablePointcut(new TypePatternClassFilter(findPerClause(aspectClass)));
			return;
		default :
			throw new AopConfigException(
					"PerClause " + ajType.getPerClause().getKind() + " not supported by Spring AOP for " + aspectClass);
	}
}
 
Example 12
Source Project: spring4-understanding   Source File: AspectMetadata.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Return AspectJ reflection information.
 */
public AjType<?> getAjType() {
	return this.ajType;
}