org.aspectj.lang.JoinPoint Java Examples
The following examples show how to use
org.aspectj.lang.JoinPoint.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TipConfigModuleImpl.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
@Profiled( logFailuresSeparately = true, tag = "TipConfigModuleImpl#getLatestProductFilter", logger = "org.perf4j.TimingLogger_Executor" ) public void getLatestProductFilter() throws IntegrationModuleException { JoinPoint var16 = Factory.makeJP(ajc$tjp_0, this, this); TimingAspect var10000 = TimingAspect.aspectOf(); Object[] var17 = new Object[]{this, var16}; ProceedingJoinPoint var10001 = (new TipConfigModuleImpl$AjcClosure1(var17)).linkClosureAndJoinPoint(69648); Annotation var10002 = ajc$anno$0; if (ajc$anno$0 == null) { var10002 = ajc$anno$0 = TipConfigModuleImpl.class.getDeclaredMethod("getLatestProductFilter").getAnnotation(Profiled.class); } var10000.doPerfLogging(var10001, (Profiled)var10002); }
Example #2
Source File: BindingResultAop.java From paascloud-master with Apache License 2.0 | 6 votes |
/** * Do after. * * @param joinPoint the join point */ @AfterReturning(pointcut = "validateAnnotation()") public void doAfter(final JoinPoint joinPoint) { String methodName = joinPoint.getSignature().getName(); Object target = joinPoint.getTarget(); //得到拦截的方法 Method method = getMethodByClassAndName(target.getClass(), methodName); Object[] objects = joinPoint.getArgs(); //方法的参数 assert method != null; ValidateAnnotation annotation = (ValidateAnnotation) getAnnotationByMethod(method, ValidateAnnotation.class); if (annotation != null) { BindingResult bindingResult = null; for (Object arg : objects) { if (arg instanceof BindingResult) { bindingResult = (BindingResult) arg; } } if (bindingResult != null && bindingResult.hasErrors()) { String errorInfo = bindingResult.getFieldError().getDefaultMessage(); throw new IllegalArgumentException(errorInfo); } } }
Example #3
Source File: ExecutorIntegrationModuleV3Impl.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
@Profiled( logFailuresSeparately = true, tag = "0.ExecutorIntegrationModule#markAsArchived" ) public void markAsArchived(String rid) throws IntegrationModuleException { JoinPoint var6 = Factory.makeJP(ajc$tjp_1, this, this, (Object)rid); TimingAspect var10000 = TimingAspect.aspectOf(); Object[] var7 = new Object[]{this, rid, var6}; ProceedingJoinPoint var10001 = (new ExecutorIntegrationModuleV3Impl$AjcClosure3(var7)).linkClosureAndJoinPoint(69648); Annotation var10002 = ajc$anno$1; if (ajc$anno$1 == null) { var10002 = ajc$anno$1 = ExecutorIntegrationModuleV3Impl.class.getDeclaredMethod("markAsArchived", String.class).getAnnotation(Profiled.class); } var10000.doPerfLogging(var10001, (Profiled)var10002); }
Example #4
Source File: ApiLogAspect.java From java-tutorial with MIT License | 6 votes |
/** * 定义前置通知(需要在切点方法的前面需要执行的动作处理) */ @Before("apiRequestLog()") public void doBefore(JoinPoint joinPoint) { logger.info("前置通知日志输出"); ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request = requestAttributes.getRequest(); // 获取url logger.info("url={}", request.getRequestURL()); //获取请求method logger.info("method={}", request.getMethod()); //获取请求ip logger.info("ip={}", request.getRemoteAddr()); // 获取处理请求的类方法 logger.info("class_method={}", joinPoint.getSignature().getDeclaringType() + "." + joinPoint.getSignature().getName()); // 获取请求方法传入的参数 logger.info("args={}", joinPoint.getArgs()); }
Example #5
Source File: KmehrHelper.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
@Profiled( logFailuresSeparately = true, tag = "IntegrationModule#XMLNotificationValidation" ) public void assertValidNotification(byte[] xmlDocument) throws IntegrationModuleException { JoinPoint var3 = Factory.makeJP(ajc$tjp_0, this, this, (Object)xmlDocument); TimingAspect var10000 = TimingAspect.aspectOf(); Object[] var4 = new Object[]{this, xmlDocument, var3}; ProceedingJoinPoint var10001 = (new KmehrHelper$AjcClosure1(var4)).linkClosureAndJoinPoint(69648); Annotation var10002 = ajc$anno$0; if (ajc$anno$0 == null) { var10002 = ajc$anno$0 = KmehrHelper.class.getDeclaredMethod("assertValidNotification", byte[].class).getAnnotation(Profiled.class); } var10000.doPerfLogging(var10001, (Profiled)var10002); }
Example #6
Source File: WebLogAspect.java From SpringBoot-Home with Apache License 2.0 | 6 votes |
/** * 前置通知: * 1. 在执行目标方法之前执行,比如请求接口之前的登录验证; * 2. 在前置通知中设置请求日志信息,如开始时间,请求参数,注解内容等 * * @param joinPoint * @throws Throwable */ @Before("webLogPointcut()") public void doBefore(JoinPoint joinPoint) { // 接收到请求,记录请求内容 ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request = attributes.getRequest(); //获取请求头中的User-Agent UserAgent userAgent = UserAgent.parseUserAgentString(request.getHeader("User-Agent")); //打印请求的内容 startTime = System.currentTimeMillis(); log.info("请求开始时间:{}" , LocalDateTime.now()); log.info("请求Url : {}" , request.getRequestURL().toString()); log.info("请求方式 : {}" , request.getMethod()); log.info("请求ip : {}" , request.getRemoteAddr()); log.info("请求参数 : {}" , Arrays.toString(joinPoint.getArgs())); // 系统信息 log.info("浏览器:{}", userAgent.getBrowser().toString()); log.info("浏览器版本:{}", userAgent.getBrowserVersion()); log.info("操作系统: {}", userAgent.getOperatingSystem().toString()); }
Example #7
Source File: MyCareNetIntegrationModuleImpl.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
static final String getInsurability_aroundBody0(MyCareNetIntegrationModuleImpl ajc$this, String userName, String password, String pharmacyHolder, String pharmacySSIN, String pharmcayNihii, String date, String type, String careReceiverSSIN, String careReceiverMutuality, String careReceiverRegNrWithMut, String packageName, String reference, String userReference, JoinPoint var14) { ApplicationConfig.getInstance().assertValidSession(); try { MyCareNetRequest myCareNet = new MyCareNetRequest(); LOG.debug("******************** Call MyCarenet for insurability ******************** "); GetInsurabilityForPharmacistResponse ins = InsurabilityConsultationServiceImpl.getInstance().getInsurabilityForPharmacist(myCareNet.createRequest(userName, password, pharmacyHolder, pharmacySSIN, pharmcayNihii, date, type, careReceiverSSIN, careReceiverMutuality, careReceiverRegNrWithMut, packageName, reference, userReference)); String insXml = null; if (ins != null) { insXml = JaxContextCentralizer.getInstance().toXml(GetInsurabilityForPharmacistResponse.class, ins); LOG.debug("******************** Call MyCarenet for insurability response: " + insXml + " ******************** "); } return insXml; } catch (Throwable var20) { Exceptionutils.errorHandler(var20); return null; } }
Example #8
Source File: AbstractAspectJAdvice.java From java-technology-stack with MIT License | 6 votes |
public void setArgumentNamesFromStringArray(String... args) { this.argumentNames = new String[args.length]; for (int i = 0; i < args.length; i++) { this.argumentNames[i] = StringUtils.trimWhitespace(args[i]); if (!isVariableName(this.argumentNames[i])) { throw new IllegalArgumentException( "'argumentNames' property of AbstractAspectJAdvice contains an argument name '" + this.argumentNames[i] + "' that is not a valid Java identifier"); } } if (this.argumentNames != null) { if (this.aspectJAdviceMethod.getParameterCount() == this.argumentNames.length + 1) { // May need to add implicit join point arg name... Class<?> firstArgType = this.aspectJAdviceMethod.getParameterTypes()[0]; if (firstArgType == JoinPoint.class || firstArgType == ProceedingJoinPoint.class || firstArgType == JoinPoint.StaticPart.class) { String[] oldNames = this.argumentNames; this.argumentNames = new String[oldNames.length + 1]; this.argumentNames[0] = "THIS_JOIN_POINT"; System.arraycopy(oldNames, 0, this.argumentNames, 1, oldNames.length); } } } }
Example #9
Source File: DataScopeAspect.java From supplierShop with MIT License | 6 votes |
protected void handleDataScope(final JoinPoint joinPoint) { // 获得注解 DataScope controllerDataScope = getAnnotationLog(joinPoint); if (controllerDataScope == null) { return; } // 获取当前的用户 SysUser currentUser = ShiroUtils.getSysUser(); if (currentUser != null) { // 如果是超级管理员,则不过滤数据 if (!currentUser.isAdmin()) { dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), controllerDataScope.userAlias()); } } }
Example #10
Source File: ExecutorIntegrationModuleV3Impl.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
@Profiled( logFailuresSeparately = true, tag = "0.ExecutorIntegrationModule#listNotifications" ) public List<ListNotificationsItem> listNotifications(boolean readFlag) throws IntegrationModuleException { JoinPoint var7 = Factory.makeJP(ajc$tjp_5, this, this, (Object)Conversions.booleanObject(readFlag)); TimingAspect var10000 = TimingAspect.aspectOf(); Object[] var8 = new Object[]{this, Conversions.booleanObject(readFlag), var7}; ProceedingJoinPoint var10001 = (new ExecutorIntegrationModuleV3Impl$AjcClosure11(var8)).linkClosureAndJoinPoint(69648); Annotation var10002 = ajc$anno$5; if (ajc$anno$5 == null) { var10002 = ajc$anno$5 = ExecutorIntegrationModuleV3Impl.class.getDeclaredMethod("listNotifications", Boolean.TYPE).getAnnotation(Profiled.class); } return (List)var10000.doPerfLogging(var10001, (Profiled)var10002); }
Example #11
Source File: DefaultAspect.java From java-client with Apache License 2.0 | 5 votes |
@Before(EXECUTION_CHANGE_VALUE) public void beforeChangeValueOf(JoinPoint joinPoint) throws Throwable { try { listener.beforeChangeValueOf(castTarget(joinPoint), driver); } catch (Throwable t) { throw getRootCause(t); } }
Example #12
Source File: SmartOperateLogAspect.java From smart-admin with MIT License | 5 votes |
private OperateLog getAnnotationLog(JoinPoint joinPoint) throws Exception { Signature signature = joinPoint.getSignature(); MethodSignature methodSignature = (MethodSignature) signature; Method method = methodSignature.getMethod(); OperateLog classAnnotation = AnnotationUtils.findAnnotation(method.getDeclaringClass(), OperateLog.class); if (method != null) { return classAnnotation; } return null; }
Example #13
Source File: DefaultAspect.java From java-client with Apache License 2.0 | 5 votes |
@Before(EXECUTION_CONTEXT) public void beforeSwitchingToContext(JoinPoint joinPoint) throws Throwable { try { listener.beforeSwitchingToContext(driver, String.valueOf(joinPoint.getArgs()[0])); } catch (Throwable t) { throw getRootCause(t); } }
Example #14
Source File: AutomonSpringAspectTest.java From automon with Apache License 2.0 | 5 votes |
@Test public void testMonitorPerformance() throws Throwable { HelloWorld monitorMe = context.getBean("monitorMe", HelloWorld.class); Object START_CONTEXT = new Object(); when(openMon.start(any(JoinPoint.StaticPart.class))).thenReturn(START_CONTEXT); monitorMe.getString(); verify(openMon).start(any(JoinPoint.StaticPart.class)); verify(openMon).stop(START_CONTEXT); }
Example #15
Source File: DefaultAspect.java From java-client with Apache License 2.0 | 5 votes |
@Before(EXECUTION_TAKE_SCREENSHOT_AS) public void beforeTakeScreenShot(JoinPoint joinPoint) throws Throwable { try { listener.beforeGetScreenshotAs(castArgument(joinPoint, 0)); } catch (Throwable t) { throw getRootCause(t); } }
Example #16
Source File: AbstractAspectJAdvice.java From lams with GNU General Public License v2.0 | 5 votes |
private boolean maybeBindJoinPoint(Class<?> candidateParameterType) { if (JoinPoint.class == candidateParameterType) { this.joinPointArgumentIndex = 0; return true; } else { return false; } }
Example #17
Source File: LoggingAspect.java From okta-jhipster-microservices-oauth-example with Apache License 2.0 | 5 votes |
/** * Advice that logs methods throwing exceptions. * * @param joinPoint join point for advice * @param e exception */ @AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e") public void logAfterThrowing(JoinPoint joinPoint, Throwable e) { if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) { log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e); } else { log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL"); } }
Example #18
Source File: DaoAspect.java From Qualitis with Apache License 2.0 | 5 votes |
@AfterReturning(pointcut = "templateMidTableInputMetaAspect()", returning = "object") public void templateMidTableInputMetaAspectAfter(JoinPoint joinPoint, Object object) throws InvocationTargetException, IllegalAccessException { ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request = attributes.getRequest(); String localeStr = request.getHeader("Content-Language"); if (object != null) { replaceMessage(object, localeStr); } }
Example #19
Source File: DefaultAspect.java From java-client with Apache License 2.0 | 5 votes |
@After(EXECUTION_WINDOW_SET_POSITION) public void afterWindowIsMoved(JoinPoint joinPoint) throws Throwable { try { listener.afterWindowIsMoved(driver, castTarget(joinPoint), castArgument(joinPoint, 0)); } catch (Throwable t) { throw getRootCause(t); } }
Example #20
Source File: WebLogAspect.java From docs-manage with MIT License | 5 votes |
@Before("webLog()") public void doBefore(JoinPoint joinPoint) { startTime.set(System.currentTimeMillis()); ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request = attributes.getRequest(); logger.info("HTTP_METHOD: {}, URL: {}, IP: {}, CLASS_METHOD: {}, ARGS: {}", request.getMethod(), request.getRequestURL().toString(), request.getRemoteAddr(), joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs())); }
Example #21
Source File: LogContextAspects.java From cloudbreak with Apache License 2.0 | 5 votes |
@Before("com.sequenceiq.cloudbreak.cloud.logger.LogContextAspects.interceptCloudPlatformEventHandlersAcceptMethod()") public void buildLogContextForCloudPlatformEventHandler(JoinPoint joinPoint) { Event<CloudPlatformRequest<?>> event = (Event<CloudPlatformRequest<?>>) joinPoint.getArgs()[0]; CloudPlatformRequest<?> cloudPlatformRequest = event.getData(); CloudContext cloudContext = cloudPlatformRequest.getCloudContext(); buildMdcContext(cloudContext, event); LOGGER.debug("A CloudPlatformEventHandler's 'accept' method has been intercepted: {}, MDC logger context is built.", joinPoint.toShortString()); }
Example #22
Source File: SwitcherProxyImpl.java From onetwo with Apache License 2.0 | 5 votes |
@Override public void processSwitchInfo(JoinPoint pjp){ final MethodSignature ms = (MethodSignature) pjp.getSignature(); SwitcherInfo info = null; info = contextHolder.getContextAttribute(SwitcherInfo.CURRENT_SWITCHER_INFO); if(info!=null) return ; try { info = this.switcherCaches.get(ms.getMethod(), new Callable<SwitcherInfo>() { @Override public SwitcherInfo call() throws Exception { SwitcherInfo switcherInfo = null; Switcher dsw = AnnotationUtils.findAnnotationWithStopClass(ms.getDeclaringType(), ms.getMethod(), Switcher.class, Object.class); if(dsw==null){ Transactional tnl = AnnotationUtils.findAnnotationWithStopClass(ms.getDeclaringType(), ms.getMethod(), Transactional.class, Object.class); if(tnl!=null){ switcherInfo = new SwitcherInfo(tnl.value(), Type.TransactionManager); }else{ switcherInfo = SwitcherInfo.DEFAULT_INFO; } }else{ switcherInfo = new SwitcherInfo(dsw.value()); } return switcherInfo; } }); } catch (ExecutionException e) { throw new BaseException("get switcher error: " + ms.getMethod()); } contextHolder.setContextAttribute(SwitcherInfo.CURRENT_SWITCHER_INFO, info); }
Example #23
Source File: AutomonAnnotationsTest.java From automon with Apache License 2.0 | 5 votes |
@Test public void testAnnotated_Constructor() throws Exception { AutomonAnnotatedMethod obj = new AutomonAnnotatedMethod(); // not monitored obj = new AutomonAnnotatedMethod("monitor me!"); // monitored verify(openMon).start(any(JoinPoint.StaticPart.class)); verify(openMon).stop(any()); }
Example #24
Source File: MonitorLock.java From tracing-framework with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void released(Object lock, long request, long acquire, long release, JoinPoint.StaticPart jp) { if (AGGREGATION_ENABLED) LocalResources.getLockAggregator(lockName(lock, jp)).released(Retro.getTenant(), request, acquire, release); if (xtrace.valid()) { if (XTraceBaggageInterface.hasParents()) { Long acquirexmd = acquire_xmds.get().remove(lock); xtrace.log(jp, "lockrelease", "Operation", "lockrelease","LockID", System.identityHashCode(lock), "Lock", lockClass(lock).getName(), "LockType", lockType(lock), "LockRequest", request, "LockAcquire", acquire, "LockRelease", release, "LockAcquireEdge", acquirexmd == null ? "none" : acquirexmd); } else { xtrace.log(jp, "lockrelease", "Operation", "lockrelease","LockID", System.identityHashCode(lock), "Lock", lockClass(lock).getName(), "LockType", lockType(lock), "LockRequest", request, "LockAcquire", acquire, "LockRelease", release); } } }
Example #25
Source File: GenericControllerAspect.java From controller-logger with Apache License 2.0 | 5 votes |
@AfterThrowing( pointcut = "allPublicControllerMethodsPointcut() && " + "methodLoggingNotDisabledPointcut() && " + "methodOrClassLoggingEnabledPointcut()", throwing = "t") public void onException(@Nonnull JoinPoint joinPoint, @Nonnull Throwable t) { String methodName = joinPoint.getSignature().getName() + "()"; LOG.info(methodName + " threw exception: [" + t + "]"); }
Example #26
Source File: AbstractAspectJAdvice.java From java-technology-stack with MIT License | 5 votes |
private boolean maybeBindJoinPointStaticPart(Class<?> candidateParameterType) { if (JoinPoint.StaticPart.class == candidateParameterType) { this.joinPointStaticPartArgumentIndex = 0; return true; } else { return false; } }
Example #27
Source File: RunContext.java From tracing-framework with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Called after a runnable has completed, and its ending context is being rejoined (eg, from a call to * Thread.join()) */ public void JoinSavedBaggageIfPossible(JoinPoint.StaticPart jp) { if (baggage != null) { XTraceReport.entering(jp); Baggage.join(baggage); XTraceReport.left(jp); baggage = null; } }
Example #28
Source File: JavaSimonAnnotationsTest.java From automon with Apache License 2.0 | 5 votes |
@Test public void testAnnotated_Class() throws Exception { JavaSimonAnnotatedClass obj = new JavaSimonAnnotatedClass(); obj.annotatedClass_method1(); // monitored obj.annotatedClass_method2(); // monitored obj.nonPublicMethod(); // not monitored verify(openMon, times(2)).start(any(JoinPoint.StaticPart.class)); verify(openMon, times(2)).stop(any()); }
Example #29
Source File: LoggingAspect.java From java-microservices-examples with Apache License 2.0 | 5 votes |
/** * Advice that logs methods throwing exceptions. * * @param joinPoint join point for advice. * @param e exception. */ @AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e") public void logAfterThrowing(JoinPoint joinPoint, Throwable e) { if (env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT))) { log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e); } else { log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL"); } }
Example #30
Source File: ReflectUtil.java From Milkomeda with MIT License | 5 votes |
/** * 获得方法上的注解 * @param joinPoint 切点连接点 * @param annotationClazz 注解类型 * @param <T> 注解类型 * @return 注解实现 */ public static <T extends Annotation> T getAnnotation(JoinPoint joinPoint, Class<T> annotationClazz) { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); Method method = signature.getMethod(); T annotation = method.getAnnotation(annotationClazz); if (null != annotation) { return annotation; } Class<?> targetClass = joinPoint.getTarget().getClass(); return targetClass.getDeclaredAnnotation(annotationClazz); }