List of usage examples for org.aspectj.lang ProceedingJoinPoint getArgs
Object[] getArgs();
From source file:de.hybris.platform.acceleratorservices.dataimport.batch.aop.TimeMeasurementAspect.java
License:Open Source License
/** * Invokes a method and measures the execution time. * /*from w ww .j a va 2 s . c om*/ * @param pjp * @return result of the invocation * @throws Throwable */ public Object measure(final ProceedingJoinPoint pjp) throws Throwable { final String methodName = pjp.getTarget().getClass().getSimpleName() + "." + pjp.getSignature().getName(); final Object[] args = pjp.getArgs(); final long start = System.currentTimeMillis(); final Object result = pjp.proceed(); if (LOG.isInfoEnabled()) { final BatchHeader header = AspectUtils.getHeader(args); LOG.info("Processed " + methodName + (header == null ? "" : " [header=" + header + "]") + " in " + (System.currentTimeMillis() - start) + "ms"); } return result; }
From source file:de.hybris.platform.acceleratorstorefrontcommons.checkout.steps.validation.CheckoutStepValidationAspect.java
License:Open Source License
public Object validateCheckoutStep(final ProceedingJoinPoint pjp) throws Throwable { final MethodSignature methodSignature = (MethodSignature) pjp.getSignature(); final PreValidateCheckoutStep preValidateCheckoutStep = methodSignature.getMethod() .getAnnotation(PreValidateCheckoutStep.class); final CheckoutGroup checkoutGroup = getCheckoutFlowGroupMap() .get(getCheckoutFacade().getCheckoutFlowGroupForCheckout()); final CheckoutStep checkoutStepBean = checkoutGroup.getCheckoutStepMap() .get(preValidateCheckoutStep.checkoutStep()); final ValidationResults validationResults = checkoutStepBean .validate((RedirectAttributesModelMap) pjp.getArgs()[1]); if (checkoutStepBean.checkIfValidationErrors(validationResults)) { return checkoutStepBean.onValidation(validationResults); }/*from w w w. ja v a2 s.c o m*/ return pjp.proceed(); }
From source file:de.hybris.platform.acceleratorstorefrontcommons.checkout.steps.validation.QuoteCheckoutStepValidationAspect.java
License:Open Source License
public Object validateQuoteCheckoutStep(final ProceedingJoinPoint pjp) throws Throwable // NOSONAR { if (getCartFacade().hasSessionCart()) { final QuoteData quoteData = getCartFacade().getSessionCart().getQuoteData(); if (quoteData != null && !getQuoteFacade().isQuoteSessionCartValidForCheckout()) { getQuoteFacade().removeQuoteCart(quoteData.getCode()); GlobalMessages.addFlashMessage((RedirectAttributesModelMap) pjp.getArgs()[1], GlobalMessages.ERROR_MESSAGES_HOLDER, "quote.cart.checkout.error"); return String.format(REDIRECT_QUOTE_DETAILS, quoteData.getCode()); }/*from w ww. j av a 2 s . co m*/ } return pjp.proceed(); }
From source file:de.hybris.platform.assistedservicestorefront.aspect.ChannelDecisionAspect.java
License:Open Source License
private boolean isAssistedServiceMode(final ProceedingJoinPoint joinPoint) { boolean assistedServiceModeRequested = false; if (joinPoint.getArgs()[0] instanceof FilterInvocation) { final FilterInvocation invocation = (FilterInvocation) joinPoint.getArgs()[0]; assistedServiceModeRequested = Boolean.parseBoolean(invocation.getHttpRequest().getParameter("asm")); }//from w ww.jav a2 s.c om return assistedServiceModeRequested || assistedServiceFacade.isAssistedServiceModeLaunched(); }
From source file:de.hybris.platform.assistedservicestorefront.aspect.ChannelDecisionAspect.java
License:Open Source License
private void processSecureChannelProcessor(final ProceedingJoinPoint joinPoint) throws IOException, ServletException { final SecureChannelProcessor processor = (SecureChannelProcessor) joinPoint.getTarget(); final FilterInvocation invocation = (FilterInvocation) joinPoint.getArgs()[0]; /* redirect any insecure request to HTTPS independent of its config */ if (!invocation.getHttpRequest().isSecure()) { processor.getEntryPoint().commence(invocation.getHttpRequest(), invocation.getHttpResponse()); }//ww w. j av a2s .c o m }
From source file:de.hybris.platform.assistedservicestorefront.aspect.ChannelDecisionAspect.java
License:Open Source License
private void processChannelDecisionManager(final ProceedingJoinPoint joinPoint) throws Throwable { final Collection<ConfigAttribute> config = (Collection<ConfigAttribute>) joinPoint.getArgs()[1]; final Collection<ConfigAttribute> filteredConfig = new ArrayList(); /*/*from www.j a v a 2s .co m*/ * filter out all "ANY_CHANNEL" attributes, so that the ChannelDecisionManager delegates all invocations to its * ChannelProcessors */ for (final ConfigAttribute attribute : config) { if (!"ANY_CHANNEL".equals(attribute.getAttribute())) { filteredConfig.add(attribute); } } final Object[] args = { joinPoint.getArgs()[0], filteredConfig }; joinPoint.proceed(args); }
From source file:de.hybris.platform.mpintgordermanagement.aspects.ConsignmentActionAspect.java
License:Open Source License
/** * Get the consignment model from the join point. * * @param joinPoint// ww w .jav a2s . c o m * - the join point object * @return the consignment model */ protected ConsignmentModel getConsignment(final ProceedingJoinPoint joinPoint) { return (ConsignmentModel) joinPoint.getArgs()[0]; }
From source file:de.hybris.platform.security.captcha.ReCaptchaAspect.java
License:Open Source License
public Object prepare(final ProceedingJoinPoint joinPoint) throws Throwable { final List<Object> args = Arrays.asList(joinPoint.getArgs()); final HttpServletRequest request = (HttpServletRequest) CollectionUtils.find(args, PredicateUtils.instanceofPredicate(HttpServletRequest.class)); if (request != null) { final boolean captcaEnabledForCurrentStore = isCaptcaEnabledForCurrentStore(); request.setAttribute("captcaEnabledForCurrentStore", Boolean.valueOf(captcaEnabledForCurrentStore)); if (captcaEnabledForCurrentStore) { request.setAttribute("recaptchaPublicKey", getSiteConfigService().getProperty(RECAPTCHA_PUBLIC_KEY_PROPERTY)); }/*from w w w. ja v a 2s . c o m*/ } return joinPoint.proceed(); }
From source file:de.hybris.platform.security.captcha.ReCaptchaAspect.java
License:Open Source License
public Object advise(final ProceedingJoinPoint joinPoint) throws Throwable { final boolean captcaEnabledForCurrentStore = isCaptcaEnabledForCurrentStore(); if (captcaEnabledForCurrentStore) { final List<Object> args = Arrays.asList(joinPoint.getArgs()); HttpServletRequest request = (HttpServletRequest) CollectionUtils.find(args, PredicateUtils.instanceofPredicate(HttpServletRequest.class)); if (request == null && RequestContextHolder.getRequestAttributes() instanceof ServletRequestAttributes) { final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder .getRequestAttributes(); request = requestAttributes.getRequest(); }//from w w w .j a va2 s.co m if (request != null) { request.setAttribute("captcaEnabledForCurrentStore", Boolean.valueOf(captcaEnabledForCurrentStore)); request.setAttribute("recaptchaPublicKey", getSiteConfigService().getProperty(RECAPTCHA_PUBLIC_KEY_PROPERTY)); final String challengeFieldValue = request.getParameter(RECAPTCHA_CHALLENGE_FIELD_PARAM); final String responseFieldValue = request.getParameter(RECAPTCHA_RESPONSE_FIELD_PARAM); if ((StringUtils.isBlank(challengeFieldValue) || StringUtils.isBlank(responseFieldValue)) || !checkAnswer(request, challengeFieldValue, responseFieldValue)) { // if there is an error add a message to binding result. final BindingResult bindingResult = (BindingResult) CollectionUtils.find(args, PredicateUtils.instanceofPredicate(BindingResult.class)); if (bindingResult != null) { bindingResult.reject("recaptcha.challenge.field.invalid", "Challenge Answer is invalid."); } request.setAttribute("recaptchaChallangeAnswered", Boolean.FALSE); } } } return joinPoint.proceed(); }
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. * //from w w w .j av a2 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 saveComponentModelAdvice(ProceedingJoinPoint pjp) throws Throwable { if (!activated) { return pjp.proceed(); } Object[] args = pjp.getArgs(); BuildingBlock bb = getEntity(args[0]); if (bb == null || bb.getSubscribedUsers().isEmpty()) { return pjp.proceed(); } BuildingBlock buildingBlockClone = cloneBb(bb); Map<String, List<TimeseriesEntry>> oldTimeseriesEntries = getTimeseriesEntriesForBb(buildingBlockClone); final Object retVal = pjp.proceed(); if (buildingBlockClone != null) { BuildingBlock buildingBlock = load(buildingBlockClone); List<String> changedTimeseries = determineChangedTimeseries(oldTimeseriesEntries, buildingBlock); String messageKey = GENERIC + UPDATED; sendEmail(buildingBlockClone, buildingBlock, changedTimeseries, messageKey, buildingBlock.getSubscribedUsers()); } return retVal; }