Package org.aspectj.lang

Examples of org.aspectj.lang.JoinPoint$StaticPart


        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


  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

  @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

    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

    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

      @Override
      public void before(Method method, Object[] args, Object target) throws Throwable {
        // makeEncSJP, although meant for computing the enclosing join point,
        // it serves our purpose here
        JoinPoint.StaticPart aspectJVersionJp = Factory.makeEncSJP(method);
        JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint();

        assertEquals(aspectJVersionJp.getSignature().toLongString(), jp.getSignature().toLongString());
        assertEquals(aspectJVersionJp.getSignature().toShortString(), jp.getSignature().toShortString());
        assertEquals(aspectJVersionJp.getSignature().toString(), jp.getSignature().toString());

        assertEquals(aspectJVersionJp.toLongString(), jp.toLongString());
        assertEquals(aspectJVersionJp.toShortString(), jp.toShortString());
        assertEquals(aspectJVersionJp.toString(), jp.toString());
      }
    });
    ITestBean itb = (ITestBean) pf.getProxy();
    itb.getAge();
    itb.setName("foo");
View Full Code Here

    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

            return getAttributes(mi.getMethod(), targetClass);
        }

        if (object instanceof JoinPoint) {
            JoinPoint jp = (JoinPoint) object;
            Class<?> targetClass;

            if (jp.getTarget() != null) {
                targetClass = jp.getTarget().getClass();
            } else {
                // SEC-1295: target may be null if an ITD is in use
                targetClass = jp.getSignature().getDeclaringType();
            }
            String targetMethodName = jp.getStaticPart().getSignature().getName();
            Class<?>[] types = ((CodeSignature) jp.getStaticPart().getSignature()).getParameterTypes();
            Class<?> declaringType = ((CodeSignature) jp.getStaticPart().getSignature()).getDeclaringType();

            Method method = ClassUtils.getMethodIfAvailable(declaringType, targetMethodName, types);
            Assert.notNull(method, "Could not obtain target method from JoinPoint: '"+ jp + "'");

            return getAttributes(method, targetClass);
View Full Code Here

        if (object instanceof MethodInvocation) {
            return this.lookupAttributes(((MethodInvocation) object).getMethod());
        }

        if (object instanceof JoinPoint) {
            JoinPoint jp = (JoinPoint) object;
            Class targetClazz = jp.getTarget().getClass();
            String targetMethodName = jp.getStaticPart().getSignature().getName();
            Class[] types = ((CodeSignature) jp.getStaticPart().getSignature())
                    .getParameterTypes();

            if (logger.isDebugEnabled()) {
                logger.debug("Target Class: " + targetClazz);
                logger.debug("Target Method Name: " + targetMethodName);
View Full Code Here

        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

TOP

Related Classes of org.aspectj.lang.JoinPoint$StaticPart

Copyright © 2018 www.massapicom. 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.