Examples of Joinpoint


Examples of org.aspectj.lang.JoinPoint

        if (secureObject instanceof MethodInvocation) {
            MethodInvocation invocation = (MethodInvocation) secureObject;
            params = invocation.getMethod().getParameterTypes();
            args = invocation.getArguments();
        } else {
            JoinPoint jp = (JoinPoint) secureObject;
            params = ((CodeSignature) jp.getStaticPart().getSignature()).getParameterTypes();
            args = jp.getArgs();
        }

        for (int i = 0; i < params.length; i++) {
            if (processDomainObjectClass.isAssignableFrom(params[i])) {
                return args[i];
View Full Code Here

Examples of org.aspectj.lang.JoinPoint

  private ModelAspect modelAspect;

  @Test
  public void testModelAspect() {
    Assume.assumeThat(springContext.isServletRequestContext(), is(false));
    JoinPoint joinPoint = mock(JoinPoint.class);
    @SuppressWarnings("unchecked")
    BaseModel<Object> baseModel = mock(BaseModel.class);
    when(joinPoint.getArgs()).thenReturn(new Object[] { baseModel });
    modelAspect.beforeSave(joinPoint);
    verify(baseModel, times(1)).setCreatedDate(any(Date.class));
  }
View Full Code Here

Examples of org.aspectj.lang.JoinPoint

  @Test
  public void testModelAspectOnServletContext() {
    springContext = spy(springContext);
    when(springContext.isServletRequestContext()).thenReturn(true);
    JoinPoint joinPoint = mock(JoinPoint.class);
    @SuppressWarnings("unchecked")
    BaseModel<Object> baseModel = mock(BaseModel.class);
    when(baseModel.exist()).thenReturn(true);
    when(joinPoint.getArgs()).thenReturn(new Object[] { baseModel });
    modelAspect.setSpringContext(springContext);
    modelAspect.beforeSave(joinPoint);
    verify(baseModel, times(1)).setLastModifiedDate(any(Date.class));
  }
View Full Code Here

Examples of org.aspectj.lang.JoinPoint

    MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
    if (!(mi instanceof ProxyMethodInvocation)) {
      throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
    }
    ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
    JoinPoint jp = (JoinPoint) pmi.getUserAttribute(JOIN_POINT_KEY);
    if (jp == null) {
      jp = new MethodInvocationProceedingJoinPoint(pmi);
      pmi.setUserAttribute(JOIN_POINT_KEY, jp);
    }
    return jp;
View Full Code Here

Examples of org.aspectj.lang.JoinPoint

    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();
View Full Code Here

Examples of org.codehaus.aspectwerkz.joinpoint.JoinPoint

                    methodHash, joinPointType, PointcutType.EXECUTION, joinPointInfo,
                    m_targetClass, m_targetClass, targetInstance, targetInstance
            );
        }

        JoinPoint joinPoint = joinPointInfo.joinPoint;

        // if null or redefined -> create a new join point and cache it
        if (joinPoint == null) {
            Map pointcutTypeToAdvicesMap = s_registry.getAdvicesForJoinPoint(m_classHash, methodHash);

            AdviceContainer[] adviceIndexes = null;
            switch (joinPointType) {
                case JoinPointType.METHOD_EXECUTION:
                    adviceIndexes = (AdviceContainer[])pointcutTypeToAdvicesMap.get(PointcutType.EXECUTION);
                    joinPoint = createMethodJoinPoint(
                            methodHash, joinPointType, m_targetClass, adviceIndexes, targetInstance, targetInstance
                    );
                    break;

                case JoinPointType.CONSTRUCTOR_EXECUTION:
                    adviceIndexes = (AdviceContainer[])pointcutTypeToAdvicesMap.get(PointcutType.EXECUTION);
                    joinPoint = createConstructorJoinPoint(
                            methodHash, joinPointType, m_targetClass, adviceIndexes, targetInstance, targetInstance
                    );
                    break;

                default:
                    throw new RuntimeException("join point type not valid");
            }

            // set the join point
            joinPointInfo.joinPoint = joinPoint;

            // update the state
            if (adviceIndexes.length == 0) {
                joinPointInfo.state = JoinPointState.ADVISED;
            }
            else {
                joinPointInfo.state = JoinPointState.HAS_ADVICES;
            }
        }

        // set the RTTI
        ((JoinPointBase)joinPoint).setTargetInstance(targetInstance);
        if (parameters != null) {
            ((CodeRtti)joinPoint.getRtti()).setParameterValues(parameters);
        }

        return ((JoinPointBase)joinPoint).proceed();
    }
View Full Code Here

Examples of org.codehaus.aspectwerkz.joinpoint.JoinPoint

                    methodHash, joinPointType, PointcutType.CALL, joinPointInfo,
                    declaringClass, m_targetClass, targetInstance, targetInstance
            );
        }

        JoinPoint joinPoint = joinPointInfo.joinPoint;

        // if null or redefined -> create a new join point and cache it
        if (joinPoint == null) {
            Map pointcutTypeToAdvicesMap = s_registry.getAdvicesForJoinPoint(m_classHash, methodHash);
            AdviceContainer[] adviceIndexes = null;
            switch (joinPointType) {
                case JoinPointType.METHOD_CALL:
                    adviceIndexes = (AdviceContainer[])pointcutTypeToAdvicesMap.get(PointcutType.CALL);

                    // TODO: make diff between target and this instances
                    joinPoint = createMethodJoinPoint(
                            methodHash, joinPointType, declaringClass, adviceIndexes, targetInstance, targetInstance
                    );
                    break;

                case JoinPointType.CONSTRUCTOR_CALL:
                    adviceIndexes = (AdviceContainer[])pointcutTypeToAdvicesMap.get(PointcutType.CALL);

                    // TODO: make diff between target and this instances
                    joinPoint = createConstructorJoinPoint(
                            methodHash, joinPointType, declaringClass, adviceIndexes, targetInstance, targetInstance
                    );
                    break;

                default:
                    throw new RuntimeException("join point type not valid");
            }

            // set the join point
            joinPointInfo.joinPoint = joinPoint;

            // update the state
            if (adviceIndexes.length == 0) {
                joinPointInfo.state = JoinPointState.ADVISED;
            }
            else {
                joinPointInfo.state = JoinPointState.HAS_ADVICES;
            }
        }

        ((JoinPointBase)joinPoint).setTargetInstance(targetInstance);
        if (parameters != null) {
            ((CodeRtti)joinPoint.getRtti()).setParameterValues(parameters);
        }

        return ((JoinPointBase)joinPoint).proceed();
    }
View Full Code Here

Examples of org.codehaus.aspectwerkz.joinpoint.JoinPoint

                    fieldHash, JoinPointType.FIELD_SET, PointcutType.SET, joinPointInfo,
                    declaringClass, m_targetClass, targetInstance, targetInstance
            );
        }

        JoinPoint joinPoint = joinPointInfo.joinPoint;

        // if null or redefined -> create a new join point and cache it
        if (joinPoint == null) {
            Map pointcutTypeToAdvicesMap = s_registry.getAdvicesForJoinPoint(m_classHash, fieldHash);

            AdviceContainer[] adviceIndexes = null;
            adviceIndexes = (AdviceContainer[])pointcutTypeToAdvicesMap.get(PointcutType.SET);
            joinPoint = createFieldJoinPoint(
                    fieldHash, fieldSignature, JoinPointType.FIELD_SET, m_targetClass,
                    adviceIndexes, targetInstance, targetInstance
            );

            // set the join point
            joinPointInfo.joinPoint = joinPoint;

            // update the state
            if (adviceIndexes.length == 0) {
                joinPointInfo.state = JoinPointState.ADVISED;
            }
            else {
                joinPointInfo.state = JoinPointState.HAS_ADVICES;
            }
        }

        // intialize the join point before each usage
        ((JoinPointBase)joinPoint).setTargetInstance(targetInstance);
        if (fieldValue[0] != null) {
            ((FieldRtti)joinPoint.getRtti()).setFieldValue(fieldValue[0]); // array due to sucky javassist field handling
        }
        ((JoinPointBase)joinPoint).proceed();
    }
View Full Code Here

Examples of org.codehaus.aspectwerkz.joinpoint.JoinPoint

                    fieldHash, JoinPointType.FIELD_GET, PointcutType.GET, joinPointInfo,
                    declaringClass, m_targetClass, targetInstance, targetInstance
            );
        }

        JoinPoint joinPoint = joinPointInfo.joinPoint;

        // if null or redefined -> create a new join point and cache it
        if (joinPoint == null) {
            Map pointcutTypeToAdvicesMap = s_registry.getAdvicesForJoinPoint(m_classHash, fieldHash);
View Full Code Here

Examples of org.codehaus.aspectwerkz.joinpoint.JoinPoint

                    handlerHash, JoinPointType.HANDLER, PointcutType.HANDLER, joinPointInfo,
                    m_targetClass, m_targetClass, targetInstance, targetInstance
            );
        }

        JoinPoint joinPoint = joinPointInfo.joinPoint;

        // if null or redefined -> create a new join point and cache it
        if (joinPoint == null) {
            Map pointcutTypeToAdvicesMap = s_registry.getAdvicesForJoinPoint(m_classHash, handlerHash);

            AdviceContainer[] adviceIndexes = (AdviceContainer[])pointcutTypeToAdvicesMap.get(PointcutType.HANDLER);
            joinPoint = createCatchClauseJoinPoint(
                    exceptionInstance.getClass(), m_targetClass, handlerSignature,
                    adviceIndexes, targetInstance, targetInstance
            );

            // set the join point
            joinPointInfo.joinPoint = joinPoint;

            // update the state
            if (adviceIndexes.length == 0) {
                joinPointInfo.state = JoinPointState.ADVISED;
            }
            else {
                joinPointInfo.state = JoinPointState.HAS_ADVICES;
            }
        }

        // intialize the join point before each usage
        ((JoinPointBase)joinPoint).setTargetInstance(targetInstance);
        ((CatchClauseRtti)joinPoint.getRtti()).setParameterValue(exceptionInstance);

        ((JoinPointBase)joinPoint).proceed();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.