use of org.aspectj.lang.ProceedingJoinPoint in project trainning by fernandotomasio.
the class AtividadesEnsinoMailAdvice method removeMatriculaMethodInterceptor.
@Around("removeMatricula()")
public Object removeMatriculaMethodInterceptor(ProceedingJoinPoint joinPoint) throws Throwable {
Object[] args = joinPoint.getArgs();
Long matriculaId = (Long) args[0];
MatriculaDTO matricula = atividadesEnsinoService.findMatricula(matriculaId);
PessoaDTO pessoa = organizationalService.findPessoa(matricula.getPessoa().getId());
String to = matricula.getIndicacao().getEmail();
String subject = "SGC - EXCLUSÃO DE MATRICULA PARA CURSO";
String textfase = "Fases:\n";
int countfases = 1;
for (FaseDTO fase : matricula.getTurma().getFases()) {
textfase += "" + countfases + " - Modalidade: " + fase.getTipoFase() + " - Descrição: " + fase.getDescricao() + " - Local: " + fase.getLocal().getSigla() + " - Início: " + fase.getDataInicioFormatted() + " - Término: " + fase.getDataTerminoFormatted() + "\n";
countfases++;
}
SimpleDateFormat dfExec = new SimpleDateFormat("yyyy");
String exercicio = dfExec.format(matricula.getTurma().getExercicio());
OrganizacaoDTO OMGEstor = organizationalService.findOrganizacao(matricula.getTurma().getOrganizacaoGestoraId());
OrganizacaoDTO OMResp = organizationalService.findOrganizacao(matricula.getTurma().getResponsavelId());
String text = "Prezado(a), " + pessoa.getTargetaCompletaOM() + "\n\n" + "Sua MATRICULA para participar do seguinte curso foi EXCLUÍDA no SGC:\n\n" + "Curso: " + matricula.getTurma().getCurso().getCodigo() + " - " + matricula.getTurma().getCurso().getDescricao() + "\n" + "Turma: " + matricula.getTurma().getNumeroTurma() + " / " + exercicio + "\n" + "Organização Responsável: " + OMResp.getNome() + " (" + OMResp.getSigla() + ")\n" + "Quantidade de Vagas: " + matricula.getTurma().getQuantidadeVagas() + "\n" + "Data de Início: " + matricula.getTurma().getDataInicioFormatted() + "\n" + "Data de Término: " + matricula.getTurma().getDataTerminoFormatted() + "\n" + "Local: " + matricula.getTurma().getLocal() + "\n" + "Modalidade: " + matricula.getTurma().getTipoTurma() + "\n\n" + textfase + "\n\n==> CABE RESSALTAR QUE ESTE E-MAIL POSSUI CARATER MERAMENTE INFORMATIVO. O DOCUMENTO QUE OFICIALIZA A MATRÍCULA NO CURSO É A PUBLICAÇÃO OFICIAL DA OM GESTORA DA CAPACITAÇÃO. <==\n" + "\nAcesse o Portal da Capacitação para mais informações.\n" + "\nEm caso de dúvidas entre em contato com o setor de capacitação de sua OM " + "ou com a Organização Gestora desta capacitação (" + OMGEstor.getSigla() + ") " + "para verificar a veracidade desta informação.\n\n" + "----------------------------------------------------\n" + "Esse e-mail foi enviado de forma automática para " + to + ", NÃO RESPONDA ESTE E-MAIL.\n" + "Este é um serviço prestado pelo SGC - Sistema de Gerenciamento da Capacitação.\n";
systemService.sendMail(to, subject, text);
// }
return joinPoint.proceed();
}
use of org.aspectj.lang.ProceedingJoinPoint in project commons by craftercms.
the class HasPermissionAnnotationHandler method getAnnotatedSecuredObject.
protected Object getAnnotatedSecuredObject(Method method, ProceedingJoinPoint pjp) {
Annotation[][] paramAnnotations = method.getParameterAnnotations();
Object[] params = pjp.getArgs();
for (int i = 0; i < paramAnnotations.length; i++) {
for (Annotation a : paramAnnotations[i]) {
if (a instanceof SecuredObject) {
return params[i];
}
}
}
return null;
}
use of org.aspectj.lang.ProceedingJoinPoint in project trafficController by amitkhosla.
the class AnnotationSupportImpl method addToTaskChainAsCalledFromParallel.
/**
* Add to task chain when Controlled called from parallel flow.
* @param joinPoint Join point
* @param controlled Controlled
* @param task Parallel Task
* @param taskExecutorPresent Is task executor present
* @param nameForTheTaskExecutor Name of task executor
* @param taskExecutor Task executor
* @return Task executor
*/
protected TaskExecutor addToTaskChainAsCalledFromParallel(ProceedingJoinPoint joinPoint, Controlled controlled, Task task, boolean taskExecutorPresent, String nameForTheTaskExecutor, TaskExecutor taskExecutor) {
int taskId = parallelJoinHelper.getObjectKeyForParalleldTask();
int parallelTaskId = ParallelJoinHelper.getParallelId();
logger.fine("already from same executor..so will be processed directly via different task.");
RunnableToBeExecuted runnableToBeExecuted = () -> {
ParallelJoinHelper.putObject(parallelTaskId, taskId, joinPoint.proceed());
};
// / TODO - IS this check required?
if (taskExecutorPresent) {
taskExecutor = task.getTaskExecutor();
} else {
runnableToBeExecuted = () -> {
try {
TaskExecutorsInUseThreadLocal.setTaskExecutor(nameForTheTaskExecutor);
Object result = joinPoint.proceed();
if (Objects.nonNull(result)) {
ParallelJoinHelper.putObject(parallelTaskId, taskId, result);
}
} finally {
TaskExecutorsInUseThreadLocal.removeTaskExecutor(nameForTheTaskExecutor);
}
};
}
String name = "ParallelId:" + parallelTaskId + " taskId:" + taskId + " " + getTaskNameFromJoinPoint(joinPoint);
org.ak.trafficController.Task.TaskType taskType = convertAnnotationTaskTypeToFrameworkTaskType(controlled.taskType());
Task thisTask;
if (taskType == org.ak.trafficController.Task.TaskType.NORMAL) {
thisTask = taskExecutor.of(runnableToBeExecuted);
} else {
thisTask = taskExecutor.slowOf(runnableToBeExecuted);
}
((ParallelTask) task).addTask(thisTask);
setThreadingDetailsIfAny(thisTask, controlled.threadDetailsDataExtractClass(), controlled.threadDetailsDataExtractMethodName(), controlled.threadDetailsProcessorClass(), controlled.threadDetailsProcessorMethodName(), controlled.threadDetailsCleanerClass(), controlled.threadDetailsCleanerMethodName());
return taskExecutor;
}
use of org.aspectj.lang.ProceedingJoinPoint in project trafficController by amitkhosla.
the class AnnotationSupportImpl method runParallel.
/**
* Handles Parallel annotated methods.
* Parallel if annotated, all method calls to Controlled annotated methods is made in parallel. Join annotated method joins back the the result created by controlled annotated methods.
* It first execute the annotated method and creates task chain to be run in parallel followed by a joiner method which will join these results.
* Parallel should be used only where we are calling different methods annotated with controlled and in different class to allow AOP play its work.
* Output returned will be the output from Join operation or the last operation.
* @param joinPoint Join point
* @param parallel Parallel
* @return Return output of the operation
* @throws Throwable In case of any exception in processing
*/
@Around("execution(@org.ak.trafficController.annotations.api.Parallel * *(..)) && @annotation(parallel)")
public Object runParallel(ProceedingJoinPoint joinPoint, Parallel parallel) throws Throwable {
int currentParallelId = parallelId.incrementAndGet();
parallelJoinHelper.map.put(currentParallelId, new ConcurrentHashMap<>());
AtomicInteger taskId = new AtomicInteger(0);
AtomicInteger earlierParallelTaskId = new AtomicInteger(0);
Task originalTask = parallelJoinHelper.getTask();
boolean isSubParallelTask = originalTask != null;
if (isSubParallelTask) {
// this task is one task of parallel tasks.
taskId.set(parallelJoinHelper.getObjectKeyForParalleldTask());
earlierParallelTaskId.set(parallelJoinHelper.getParallelId());
}
ParallelJoinHelper.setParallelTaskId(currentParallelId);
// if (!isSubParallelTask) {
ExecutableTask thisParallelTask = TaskExecutor.getInstance().of(() -> {
});
setThreadingDetailsIfAny(thisParallelTask, parallel.threadDetailsDataExtractClass(), parallel.threadDetailsDataExtractMethodName(), parallel.threadDetailsProcessorClass(), parallel.threadDetailsProcessorMethodName(), parallel.threadDetailsCleanerClass(), parallel.threadDetailsCleanerMethodName());
thisParallelTask.setName("ParallelTask" + currentParallelId);
ParallelExecutingTask<Object> thenParallel = thisParallelTask.thenParallel(() -> {
});
thenParallel.setName("ParallelTaskName:" + currentParallelId);
// set dummy task
parallelJoinHelper.setTask(thenParallel);
// }
if (!isSubParallelTask) {
Object val = directParallelTaskHandling(joinPoint, currentParallelId, parallel);
return val;
} else {
joinPoint.proceed();
if (originalTask instanceof ParallelTask) {
subProcessHandling(currentParallelId, taskId, earlierParallelTaskId, originalTask, thisParallelTask);
}
return null;
}
}
use of org.aspectj.lang.ProceedingJoinPoint in project trafficController by amitkhosla.
the class TaskHelper method getTaskExecutorBasedOnAsyncProps.
/**
* Get task executor for submit.
* This method creates task executor with max consumer details.
* @param async Submit
* @param joinPoint Join point
* @return Task executor for required inputs
*/
protected TaskExecutor getTaskExecutorBasedOnAsyncProps(Submit async, ProceedingJoinPoint joinPoint) {
int maxConsumers = getConsumers(async.maxConsumer(), joinPoint);
int maxSlowConsumers = getConsumers(async.maxSlowConsumer(), joinPoint);
return getTaskExecutorForConsumersDetails(maxConsumers, maxSlowConsumers);
}
Aggregations