Example usage for org.aspectj.lang JoinPoint.EnclosingStaticPart getSourceLocation

List of usage examples for org.aspectj.lang JoinPoint.EnclosingStaticPart getSourceLocation

Introduction

In this page you can find the example usage for org.aspectj.lang JoinPoint.EnclosingStaticPart getSourceLocation.

Prototype

SourceLocation getSourceLocation();

Source Link

Document

If there is no source location available, returns null.

Returns the SourceLocation of the defining class for default constructors.

getStaticPart().getSourceLocation() returns the same object.

Usage

From source file:com.newmainsoftech.spray.slingong.datastore.Slim3AnnotationTransactionAspect.java

License:Apache License

/**
 * Handles incident of call to not-read-only method of {@link GlobalTransaction} class during 
 * read-only transaction. // w  ww.  jav  a 2 s  .c om
 * 
 * @param isToTerminate When true, {@link IllegalStateException} will be thrown. When false, only 
 * perform logging such incident.
 * @param joinPoint
 * @param enclosingStaticPart
 */
protected void handleInproperPersistenceIncident(boolean isToTerminate, JoinPoint joinPoint,
        JoinPoint.EnclosingStaticPart enclosingStaticPart) {
    String statementInfo = String.format(
            "Detected the inappropriate call to not-read-only method (%1$s) during read-only "
                    + "trasaction. Call is made from %2$s. ",
            joinPoint.getSignature().toString(), enclosingStaticPart.getSourceLocation().toString());
    if (isToTerminate) {
        throw new IllegalStateException(statementInfo);
    } else {
        Logger logger = Slim3AnnotationTransactionAspect.getLogger();
        if (logger.isWarnEnabled()) {
            logger.warn(statementInfo);
        }
    }
}