Example usage for org.aspectj.lang ProceedingJoinPoint proceed

List of usage examples for org.aspectj.lang ProceedingJoinPoint proceed

Introduction

In this page you can find the example usage for org.aspectj.lang ProceedingJoinPoint proceed.

Prototype

public Object proceed() throws Throwable;

Source Link

Document

Proceed with the next advice or target method invocation

Usage

From source file:de.iteratec.iteraplan.businesslogic.common.SubscriptionsAdvice.java

License:Open Source License

/**
 * Intercepts the {@link de.iteratec.iteraplan.presentation.dialog.BuildingBlockFrontendService#saveComponentModel(MemBean, Integer, org.springframework.webflow.execution.RequestContext, org.springframework.webflow.execution.FlowExecutionContext)}
 * method and sends the notification email.
 * //ww w  .j a  v  a  2 s .c om
 * @param pjp the ProceedingJoinPoint, which exposes the proceed(..) method in order to support around advice in aspects
 * @return the result of the intercepted method
 * @throws Throwable if any exceptions occurs executing method
 */
public Object saveNewReleaseComponentModelAdvice(ProceedingJoinPoint pjp) throws Throwable {
    if (!activated) {
        return pjp.proceed();
    }

    Object[] args = pjp.getArgs();

    final Object retVal = pjp.proceed();

    if (retVal != null) {
        BuildingBlock buildingBlock = getEntity(args[0]);

        if (buildingBlock != null && BBT_TO_MESSAGE_KEY.containsKey(buildingBlock.getTypeOfBuildingBlock())) {
            buildingBlock = load(buildingBlock);
            List<String> changedTimeseries = determineChangedTimeseries(
                    Maps.<String, List<TimeseriesEntry>>newHashMap(), buildingBlock);

            String messageKey = GENERIC + RELEASE_NEW;
            sendEmail(null, buildingBlock, changedTimeseries, messageKey,
                    buildingBlock.getBuildingBlockType().getSubscribedUsers());
        }
    }

    return retVal;
}

From source file:de.iteratec.iteraplan.businesslogic.common.SubscriptionsAdvice.java

License:Open Source License

/**
 * Intercepts the {@link de.iteratec.iteraplan.presentation.dialog.BuildingBlockFrontendService#saveComponentModel(MemBean, Integer, org.springframework.webflow.execution.RequestContext, org.springframework.webflow.execution.FlowExecutionContext)}
 * method and sends the notification email.
 * /*  www . jav a 2 s. co  m*/
 * @param pjp the ProceedingJoinPoint, which exposes the proceed(..) method in order to support around advice in aspects
 * @return the result of the intercepted method
 * @throws Throwable if any exceptions occurs executing method
 */
public Object saveCopyReleaseComponentModelAdvice(ProceedingJoinPoint pjp) throws Throwable {
    if (!activated) {
        return pjp.proceed();
    }

    Object[] args = pjp.getArgs();

    final Object retVal = pjp.proceed();

    if (retVal != null) {
        BuildingBlock buildingBlock = getEntity(args[0]);

        if (buildingBlock != null && BBT_TO_MESSAGE_KEY.containsKey(buildingBlock.getTypeOfBuildingBlock())) {
            buildingBlock = load(buildingBlock);
            List<String> changedTimeseries = determineChangedTimeseries(
                    Maps.<String, List<TimeseriesEntry>>newHashMap(), buildingBlock);

            String messageKey = GENERIC + RELEASE_COPY;
            sendEmail(null, buildingBlock, changedTimeseries, messageKey,
                    buildingBlock.getBuildingBlockType().getSubscribedUsers());
        }
    }

    return retVal;
}

From source file:de.iteratec.iteraplan.businesslogic.common.SubscriptionsAdvice.java

License:Open Source License

/**
 * Intercepts the {@link de.iteratec.iteraplan.businesslogic.service.BuildingBlockService#deleteEntity(de.iteratec.iteraplan.model.interfaces.Entity)}
 * method and sends the notification email.
 * /*  w  w  w. j  ava2s  .c o m*/
 * @param pjp the ProceedingJoinPoint, which exposes the proceed(..) method in order to support around advice in aspects
 * @throws Throwable if any exceptions occurs executing method
 */
public void deleteEntityAdvice(ProceedingJoinPoint pjp) throws Throwable {
    if (!activated) {
        pjp.proceed();
        return;
    }

    Object[] args = pjp.getArgs();
    BuildingBlock buildingBlock = load((BuildingBlock) args[0], SUBSCRIBED_USERS);

    pjp.proceed();

    if (BBT_TO_MESSAGE_KEY.containsKey(buildingBlock.getTypeOfBuildingBlock())) {
        Collection<User> users = new HashSet<User>(buildingBlock.getSubscribedUsers());
        users.addAll(buildingBlock.getBuildingBlockType().getSubscribedUsers());
        String messageKey = GENERIC + DELETED;
        sendEmail(null, buildingBlock, null, messageKey, users);
    }

}

From source file:de.iteratec.iteraplan.businesslogic.common.SubscriptionsAdvice.java

License:Open Source License

/**
 * Intercepts the {@link MassUpdateServiceImpl#updateLine(MassUpdateLine)} method and sends the notification email.
 * /*www  .j a va2 s .c om*/
 * @param pjp the ProceedingJoinPoint, which exposes the proceed(..) method in order to support around advice in aspects
 * @return the result of the intercepted method
 * @throws Throwable if any exceptions occurs executing method
 */
@SuppressWarnings("unchecked")
public Object massUpdateLineAdvice(ProceedingJoinPoint pjp) throws Throwable {
    if (!activated) {
        return pjp.proceed();
    }

    Object[] args = pjp.getArgs();
    MassUpdateLine<BuildingBlock> line = (MassUpdateLine<BuildingBlock>) args[0];
    BuildingBlock bb = line.getBuildingBlockToUpdate();
    if (bb == null) {
        return pjp.proceed();
    }
    bb = load(bb, SUBSCRIBED_USERS);

    if (bb.getSubscribedUsers().isEmpty()) {
        return pjp.proceed();
    }

    BuildingBlock buildingBlockClone = cloneBb(bb);

    Object retVal = pjp.proceed();

    if (buildingBlockClone != null && bb.getId() != null) {
        BuildingBlock buildingBlock = load(buildingBlockClone, SUBSCRIBED_USERS);
        String messageKey = GENERIC + UPDATED;
        sendEmail(buildingBlockClone, buildingBlock, null, messageKey, buildingBlock.getSubscribedUsers());
    }

    return retVal;
}

From source file:de.iteratec.iteraplan.businesslogic.common.SubscriptionsAdvice.java

License:Open Source License

/**
 * Intercepts the {@link de.iteratec.iteraplan.presentation.dialog.BuildingBlockFrontendService#saveComponentModel(MemBean, Integer, org.springframework.webflow.execution.RequestContext, org.springframework.webflow.execution.FlowExecutionContext)}
 * method and sends the notification email.
 * /*  ww w. j  a  v  a 2 s . c o m*/
 * @param pjp the ProceedingJoinPoint, which exposes the proceed(..) method in order to support around advice in aspects
 * @throws Throwable if any exceptions occurs executing method
 */
public void excelImportAdvice(ProceedingJoinPoint pjp) throws Throwable {
    if (!activated) {
        pjp.proceed();
        return;
    }

    Object[] args = pjp.getArgs();

    List<BuildingBlockHolder> elements = ((LandscapeData) args[0]).getBuildingBlocks();
    List<BuildingBlock> added = new ArrayList<BuildingBlock>();
    List<BuildingBlock> updated = new ArrayList<BuildingBlock>();

    for (BuildingBlockHolder holder : elements) {
        BuildingBlock buildingBlock = holder.getBuildingBlock();
        if (buildingBlock != null && BBT_TO_MESSAGE_KEY.containsKey(buildingBlock.getTypeOfBuildingBlock())) {
            BuildingBlock reloaded = bbServiceLocator.getService(buildingBlock.getTypeOfBuildingBlock())
                    .loadObjectByIdIfExists(buildingBlock.getId());
            if (reloaded != null) {
                updated.add(holder.getClone());
            } else {
                added.add(buildingBlock);
            }
        }

    }

    pjp.proceed();

    for (BuildingBlock bb : added) {
        if (bb.getId() != null) {
            BuildingBlock buildingBlock = load(bb, SUBSCRIBED_USERS);
            String messageKey = GENERIC + CREATED;
            String messageKeySub = GENERIC + SUBSCRIBED;
            Collection<User> subscribedUsers = new HashSet<User>(buildingBlock.getSubscribedUsers());
            subscribedUsers.addAll(buildingBlock.getBuildingBlockType().getSubscribedUsers());
            sendEmail(null, buildingBlock, null, messageKeySub, buildingBlock.getSubscribedUsers());
            sendEmail(null, buildingBlock, null, messageKey, subscribedUsers);
        }
    }

    for (BuildingBlock bb : updated) {
        if (bb.getId() != null) {
            BuildingBlock buildingBlock = load(bb, SUBSCRIBED_USERS);
            String messageKey = GENERIC + UPDATED;
            String messageKeySub = GENERIC + SUBSCRIBED;
            String messageKeyUnsub = GENERIC + UNSUBSCRIBED;
            Collection<User> subscribedUsers = new HashSet<User>(buildingBlock.getSubscribedUsers());
            subscribedUsers.removeAll(bb.getSubscribedUsers());
            Collection<User> unsubscribedUsers = new HashSet<User>(bb.getSubscribedUsers());
            unsubscribedUsers.removeAll(buildingBlock.getSubscribedUsers());
            sendEmail(null, buildingBlock, null, messageKeySub, subscribedUsers);
            sendEmail(null, buildingBlock, null, messageKeyUnsub, unsubscribedUsers);
            sendEmail(bb, buildingBlock, null, messageKey, buildingBlock.getSubscribedUsers());
        }
    }
}

From source file:de.kaiserpfalzEdv.commons.jee.spring.ServiceLogging.java

License:Apache License

@Around("execution(* de.kaiserpfalzEdv..service..*Impl.*(..))")
public Object updateMDC(ProceedingJoinPoint joinPoint) throws Throwable {
    String id = retrieveIdFromMDCOrGenerateNewUUID(joinPoint);
    MDC.put("id", id);

    Object result;/*from   w ww . j  a  va  2  s .c  o m*/

    if (oplog.isInfoEnabled()) {
        String serviceName = retrieveMethodNameFromSignature(joinPoint);

        OffsetDateTime start = OffsetDateTime.now(UTC);
        oplog.info("Service '{}' started. id={}, start={}", serviceName, id, start);

        result = joinPoint.proceed();

        OffsetDateTime end = OffsetDateTime.now(UTC);

        oplog.info("Service '{}' ended. id={}, start={}, duration={}",
                retrieveMethodNameFromSignature(joinPoint), id, start, Duration.between(start, end));
    } else {
        result = joinPoint.proceed();
    }

    MDC.remove("id");

    return result;
}

From source file:de.rahn.finances.services.securities.SecuritiesServiceMetricsAspect.java

License:Apache License

@Around("execution(org.springframework.data.domain.Page de.rahn.finances.services.SecuritiesService.getSecurities(org.springframework.data.domain.Pageable))")
public Object doGetSecuritiesTimer(ProceedingJoinPoint joinPoint) throws Throwable {
    long start = currentTimeMillis();

    Object returnValue = joinPoint.proceed();

    gaugeService.submit(PREFIX_METRICNAME_TIMER, currentTimeMillis() - start);

    return returnValue;
}