use of javax.interceptor.AroundInvoke in project microservice_framework by CJSCommonPlatform.
the class JmsLoggerMetadataInterceptor method addRequestDataToMappedDiagnosticContext.
@AroundInvoke
protected Object addRequestDataToMappedDiagnosticContext(final InvocationContext context) throws Exception {
traceLogger.trace(logger, () -> "Adding Request data to MDC");
final Object[] parameters = context.getParameters();
parameterChecker.check(parameters);
final TextMessage message = (TextMessage) parameters[0];
final JsonObjectBuilder builder = createObjectBuilder();
addServiceContextNameIfPresent(builder);
addMetaDataToBuilder(message, builder);
MDC.put(REQUEST_DATA, builder.build().toString());
traceLogger.trace(logger, () -> "Request data added to MDC");
final Object result = context.proceed();
traceLogger.trace(logger, () -> "Clearing MDC");
MDC.clear();
return result;
}
use of javax.interceptor.AroundInvoke in project camunda-bpm-platform by camunda.
the class StartProcessInterceptor method invoke.
@AroundInvoke
public Object invoke(InvocationContext ctx) throws Exception {
try {
Object result = ctx.proceed();
StartProcess startProcessAnnotation = ctx.getMethod().getAnnotation(StartProcess.class);
String key = startProcessAnnotation.value();
Map<String, Object> variables = extractVariables(startProcessAnnotation, ctx);
businessProcess.startProcessByKey(key, variables);
return result;
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause != null && cause instanceof Exception) {
throw (Exception) cause;
} else {
throw e;
}
} catch (Exception e) {
throw new ProcessEngineException("Error while starting process using @StartProcess on method '" + ctx.getMethod() + "': " + e.getMessage(), e);
}
}
use of javax.interceptor.AroundInvoke in project ART-TIME by Artezio.
the class ShiroSecuredInterceptor method interceptShiroSecurity.
@AroundInvoke
public Object interceptShiroSecurity(InvocationContext context) throws Exception {
Subject subject = SecurityUtils.getSubject();
Class<?> clas = context.getTarget().getClass();
Method method = context.getMethod();
if (!subject.isAuthenticated() && hasAnnotation(clas, method, RequiresAuthentication.class)) {
throw new UnauthenticatedException("Authentication required");
}
if (subject.getPrincipal() != null && hasAnnotation(clas, method, RequiresGuest.class)) {
throw new UnauthenticatedException("Guest required");
}
if (subject.getPrincipal() == null && hasAnnotation(clas, method, RequiresUser.class)) {
throw new UnauthenticatedException("User required");
}
RequiresRoles roles = getAnnotation(clas, method, RequiresRoles.class);
if (roles != null) {
subject.checkRoles(Arrays.asList(roles.value()));
}
RequiresPermissions permissions = getAnnotation(clas, method, RequiresPermissions.class);
if (permissions != null) {
subject.checkPermissions(permissions.value());
}
return context.proceed();
}
use of javax.interceptor.AroundInvoke in project microservice_framework by CJSCommonPlatform.
the class JsonSchemaValidationInterceptor method validate.
@AroundInvoke
protected Object validate(final InvocationContext context) throws Exception {
final Object[] parameters = context.getParameters();
parametersChecker.check(parameters);
final TextMessage message = (TextMessage) parameters[0];
if (shouldValidate(message)) {
validate(message);
}
return context.proceed();
}
use of javax.interceptor.AroundInvoke in project Payara by payara.
the class ClusterScopedInterceptor method lockAndRefresh.
@AroundInvoke
public Object lockAndRefresh(InvocationContext invocationContext) throws Exception {
Class<?> beanClass = invocationContext.getMethod().getDeclaringClass();
Clustered clusteredAnnotation = getAnnotation(beanManager, beanClass);
try {
lock(beanClass, clusteredAnnotation);
return invocationContext.proceed();
} finally {
refresh(beanClass, invocationContext.getTarget());
unlock(beanClass, clusteredAnnotation);
}
}
Aggregations