List of usage examples for org.aspectj.lang JoinPoint toLongString
String toLongString();
From source file:com.earldouglas.xjdl.LicenseManager.java
License:Apache License
@Before("@annotation(com.earldouglas.xjdl.Licensed)") public void authorize(JoinPoint joinPoint) { License license = getLicenseLoader().loadLicense(); if (license == null) { log.warn("unlicensed feature: " + joinPoint.toLongString()); throw new LicenseInvalidException(); } else {// w w w. j ava 2s . c om license.authorize(); } }
From source file:cz.muni.fi.pa165.carpark.config.LoggingAspect.java
@Before("inWebLayer() || inServiceLayer() || inDaoLayer()") public void logBeforeExecution(JoinPoint joinPoint) { LOGGER.debug("BEFORE: " + joinPoint.toLongString()); }
From source file:cz.muni.fi.pa165.carpark.config.LoggingAspect.java
@AfterReturning(pointcut = "inWebLayer() || inServiceLayer() || inDaoLayer()", returning = "retValue") public void logAfterExecution(JoinPoint joinPoint) { LOGGER.debug("AFTER: " + joinPoint.toLongString()); }
From source file:cz.muni.fi.pa165.carpark.config.LoggingAspect.java
@AfterThrowing(pointcut = "inWebLayer() || inServiceLayer() || inDaoLayer()", throwing = "error") public void logAfterThrowing(JoinPoint joinPoint, Throwable error) { LOGGER.error("AFTER: " + joinPoint.toLongString() + ", THROWN: with msg [" + error.getMessage() + "], cause: " + error); }
From source file:cz.muni.fi.pa165.carpark.web.client.config.LoggingAspect.java
@Before("inWebLayer()") public void logBeforeExecution(JoinPoint joinPoint) { LOGGER.debug("BEFORE: " + joinPoint.toLongString()); }
From source file:cz.muni.fi.pa165.carpark.web.client.config.LoggingAspect.java
@AfterReturning(pointcut = "inWebLayer()", returning = "retValue") public void logAfterExecution(JoinPoint joinPoint) { LOGGER.debug("AFTER: " + joinPoint.toLongString()); }
From source file:cz.muni.fi.pa165.carpark.web.client.config.LoggingAspect.java
@AfterThrowing(pointcut = "inWebLayer()", throwing = "error") public void logAfterThrowing(JoinPoint joinPoint, Throwable error) { LOGGER.error("AFTER: " + joinPoint.toLongString() + ", THROWN: with msg [" + error.getMessage() + "], cause: " + error); }
From source file:edu.umn.msi.tropix.webgui.server.aop.SecurityAspect.java
License:Open Source License
@Before(value = "@annotation(serviceMethod)", argNames = "serviceMethod") public void doAccessCheck(final JoinPoint joinPoint, final ServiceMethod serviceMethod) { if (serviceMethod.secure() && !userSession.isLoggedIn()) { LOG.warn("Invalid access attempting on method [" + joinPoint.toLongString() + "]"); throw new IllegalStateException("Attempt to call secure method by an user who is not logged in."); } else if (serviceMethod.adminOnly()) { final String gridId = userSession.getGridId(); if (gridId == null || !userSession.isAdmin()) { LOG.warn("Invalid access attempting on method [" + joinPoint.toLongString() + "]"); throw new IllegalStateException("Attempt to call an admin method by a user who is not an admin."); }//w w w.j av a 2 s . c o m } }
From source file:hello.ServiceMonitor.java
License:Apache License
@After("execution(* hello..*Controller.*(..))") public void logServiceAfter(JoinPoint joinPoint) { System.out.println("After: " + joinPoint.toLongString()); System.out.println("After: " + joinPoint.toShortString()); System.out.println("After: " + joinPoint.getArgs()[0].toString()); System.out.println("After: " + joinPoint.getKind()); System.out.println("After: " + joinPoint.getClass()); System.out.println("After: " + joinPoint.getSignature()); System.out.println("After: " + joinPoint.getSourceLocation()); System.out.println("After: " + joinPoint.getStaticPart()); System.out.println("After: " + joinPoint.getTarget()); }
From source file:org.springframework.aop.aspectj.MethodInvocationProceedingJoinPointTests.java
License:Apache License
@Test public void testCanGetMethodSignatureFromJoinPoint() { final Object raw = new TestBean(); // Will be set by advice during a method call final int newAge = 23; ProxyFactory pf = new ProxyFactory(raw); pf.setExposeProxy(true);/* www .ja v a 2s.com*/ pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR); pf.addAdvice(new MethodBeforeAdvice() { private int depth; @Override public void before(Method method, Object[] args, Object target) throws Throwable { JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint(); assertTrue("Method named in toString", jp.toString().contains(method.getName())); // Ensure that these don't cause problems jp.toShortString(); jp.toLongString(); assertSame(target, AbstractAspectJAdvice.currentJoinPoint().getTarget()); assertFalse(AopUtils.isAopProxy(AbstractAspectJAdvice.currentJoinPoint().getTarget())); ITestBean thisProxy = (ITestBean) AbstractAspectJAdvice.currentJoinPoint().getThis(); assertTrue(AopUtils.isAopProxy(AbstractAspectJAdvice.currentJoinPoint().getThis())); assertNotSame(target, thisProxy); // Check getting again doesn't cause a problem assertSame(thisProxy, AbstractAspectJAdvice.currentJoinPoint().getThis()); // Try reentrant call--will go through this advice. // Be sure to increment depth to avoid infinite recursion if (depth++ == 0) { // Check that toString doesn't cause a problem thisProxy.toString(); // Change age, so this will be returned by invocation thisProxy.setAge(newAge); assertEquals(newAge, thisProxy.getAge()); } assertSame(AopContext.currentProxy(), thisProxy); assertSame(target, raw); assertSame(method.getName(), AbstractAspectJAdvice.currentJoinPoint().getSignature().getName()); assertEquals(method.getModifiers(), AbstractAspectJAdvice.currentJoinPoint().getSignature().getModifiers()); MethodSignature msig = (MethodSignature) AbstractAspectJAdvice.currentJoinPoint().getSignature(); assertSame("Return same MethodSignature repeatedly", msig, AbstractAspectJAdvice.currentJoinPoint().getSignature()); assertSame("Return same JoinPoint repeatedly", AbstractAspectJAdvice.currentJoinPoint(), AbstractAspectJAdvice.currentJoinPoint()); assertEquals(method.getDeclaringClass(), msig.getDeclaringType()); assertTrue(Arrays.equals(method.getParameterTypes(), msig.getParameterTypes())); assertEquals(method.getReturnType(), msig.getReturnType()); assertTrue(Arrays.equals(method.getExceptionTypes(), msig.getExceptionTypes())); msig.toLongString(); msig.toShortString(); } }); ITestBean itb = (ITestBean) pf.getProxy(); // Any call will do assertEquals("Advice reentrantly set age", newAge, itb.getAge()); }