use of org.aspectj.lang.reflect.MethodSignature in project nextprot-api by calipho-sib.
the class InstrumentationAspect method logService.
@Around("execution(* org.nextprot.api.*.service.*.*(..))")
public Object logService(ProceedingJoinPoint pjp) throws Throwable {
if (enableInstrumentation) {
serviceRequestId.set(serviceRequestIdCounter.incrementAndGet());
MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
Annotation[][] annotations = methodSignature.getMethod().getParameterAnnotations();
Object[] arguments = pjp.getArgs();
StringBuilder sb = new StringBuilder();
sb.append("type=Service;");
addMethodParameters(sb, methodSignature);
addArgumentsParameters(sb, arguments, annotations);
sb.append("serviceRequestId=");
sb.append(serviceRequestIdCounter.get());
sb.append(";");
Long cId = serviceRequestId.get();
if (cId != null) {
sb.append("controllerRequestId=");
sb.append(cId);
sb.append(";");
}
long start = System.currentTimeMillis();
try {
Object result = pjp.proceed();
// LOGGER.info("aspect=before;" + sb);
addTimeElapsed(sb, System.currentTimeMillis() - start);
addResultParameters(sb, result);
serviceRequestId.remove();
LOGGER.info("aspect=after;" + sb);
return result;
} catch (Exception e) {
addTimeElapsed(sb, System.currentTimeMillis() - start);
addExceptionParameters(sb, e);
serviceRequestId.remove();
LOGGER.info("aspect=after;" + sb);
throw e;
}
} else {
return pjp.proceed();
}
}
use of org.aspectj.lang.reflect.MethodSignature in project trafficController by amitkhosla.
the class QueueAnnotationsHandler method getQueueName.
/**
* Get queue name. If name is passed, the same is returned. In case name is not passed, it is created from join point.
* For creation, producer's return type and consumer's parameter type is identified.
* Also if the batch processing (batch put or batch consumer) type is identified from the type of collection.
* @param name Queue name as passed in Queued or consumer
* @param joinPoint Join point of the caller method
* @param shouldVerifyBatch Batch?
* @param producerOrConsumer Producer or consumer?
* @return name of queue
*/
protected String getQueueName(String name, ProceedingJoinPoint joinPoint, boolean shouldVerifyBatch, String producerOrConsumer) {
if (StringUtils.isEmpty(name)) {
Class returnType = null;
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
String nameFromCache = queueNameMapping.get(method);
if (!StringUtils.isEmpty(nameFromCache)) {
return nameFromCache;
}
returnType = getTypeForAnnotatedMethodReturnOrFirstParameter(shouldVerifyBatch, producerOrConsumer, signature, method);
String output = checkPrimitive(returnType);
queueNameMapping.put(method, output);
return output;
}
return name;
}
use of org.aspectj.lang.reflect.MethodSignature in project trafficController by amitkhosla.
the class QueueAnnotationsHandler method processConsumerDetails.
/**
* Process queue consumer if configured to.
* @param queued Queued object
* @param joinPoint Join point
* @param obj Object which is sent to queue, to find the method in class
* @param queueName Name of queue
* @throws InstantiationException if no bean present in application context and we cannot create instance
* @throws IllegalAccessException If method is not found
*/
protected void processConsumerDetails(Queued queued, ProceedingJoinPoint joinPoint, Object obj, String queueName) throws InstantiationException, IllegalAccessException {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
if (queueMethodsProcessedForConsumer.containsKey(method)) {
return;
}
if (queued.consumerClass() == Queued.class) {
queueMethodsProcessedForConsumer.put(method, false);
return;
}
Method actualMethod = getActualConsumerMethod(queued, obj, signature, method);
registerConsumerForQueued(queued, queueName, method, actualMethod);
}
use of org.aspectj.lang.reflect.MethodSignature in project skeleton-commons by skeleton-software-community.
the class LoggingAspect method getRequestDescription.
private String getRequestDescription(ProceedingJoinPoint joinPoint) {
String url = "";
String method = "";
Class<?> proxiedClass = joinPoint.getTarget().getClass();
if (proxiedClass.isAnnotationPresent(RequestMapping.class)) {
RequestMapping requestMapping = proxiedClass.getAnnotation(RequestMapping.class);
if (requestMapping.value() != null && requestMapping.value().length > 0) {
url += requestMapping.value()[0];
}
}
Method proxiedMethod = ((MethodSignature) joinPoint.getSignature()).getMethod();
RequestMapping requestMapping = proxiedMethod.getAnnotation(RequestMapping.class);
if (requestMapping.value() != null && requestMapping.value().length > 0) {
url += requestMapping.value()[0];
}
if (requestMapping.method() != null && requestMapping.method().length > 0) {
method = requestMapping.method()[0].name();
}
return method + " " + url;
}
use of org.aspectj.lang.reflect.MethodSignature in project skeleton-commons by skeleton-software-community.
the class AccessControlAspect method getAccessControlType.
private AccessControlType getAccessControlType(ProceedingJoinPoint joinPoint) {
AccessControlType accessControlType = AccessControlType.PRIVATE;
Method proxiedMethod = ((MethodSignature) joinPoint.getSignature()).getMethod();
AccessControl accessControl = proxiedMethod.getAnnotation(AccessControl.class);
if (accessControl != null) {
accessControlType = accessControl.value();
}
return accessControlType;
}
Aggregations