Package org.aspectj.lang

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


    public String[] resolveFrom(final JoinPoint target, final Exception exception) {
        return findService(target);
    }

    private String[] findService(final JoinPoint joinPoint) {
        final JoinPoint j = AopUtils.unWrapJoinPoint(joinPoint);

        final Long id = (Long) j.getArgs()[0];

        if (id == null) {
            return new String[] {""};
        }
View Full Code Here

     *
     * @param point Join point to unwrap.
     * @return Innermost join point; if not nested, simply returns the argument.
     */
    public static JoinPoint unWrapJoinPoint(final JoinPoint point) {
        JoinPoint naked = point;
        while (naked.getArgs().length > 0 && naked.getArgs()[0] instanceof JoinPoint) {
            naked = (JoinPoint) naked.getArgs()[0];
        }
        return naked;
    }
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

    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.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
      private int depth;
     
      public void before(Method method, Object[] args, Object target) throws Throwable {
        JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint();
        assertTrue("Method named in toString", jp.toString().indexOf(method.getName()) != -1);
        // 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

        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

        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

    }

    @SuppressWarnings("boxing")
    @Test
    public void testView() throws Exception {
        JoinPoint jp = mock(JoinPoint.class);
        Signature sig = mock(Signature.class);
        when(jp.getSignature()).thenReturn(sig);
        when(sig.getName()).thenReturn("GreatHeapingMethod");
        when(jp.getArgs()).thenReturn(new String[]{"one", "two"});
        JoinPoint.StaticPart staticPart = mock(JoinPoint.StaticPart.class);
        SourceLocation sl = mock(SourceLocation.class);
        when(sl.getFileName()).thenReturn("Test.java");
        when(sl.getLine()).thenReturn(100);
        when(sl.getWithinType()).thenReturn(this.getClass());
        when(staticPart.getSourceLocation()).thenReturn(sl);
        MethodSignature msig = mock(MethodSignature.class);
        when(staticPart.getSignature()).thenReturn(msig);
        when(jp.getStaticPart()).thenReturn(staticPart);

        // Db
        Operation op = MongoDbOperationCollectionAspect.aspectOf().createOperation(jp);
        op.put(OperationFields.RETURN_VALUE, "my return");
        String content = getRenderingOf(op);
        assertNotNull(content);

        // Cursor
        DBCursor cursor = mock(DBCursor.class);
        when(cursor.getKeysWanted()).thenReturn(new BasicDBObject("everybody", "loves"));
        when(cursor.getQuery()).thenReturn(new BasicDBObject("spring", "insight"));
        when(jp.getTarget()).thenReturn(cursor);
        op = MongoCursorOperationCollectionAspect.aspectOf().createOperation(jp);
        op.put(OperationFields.RETURN_VALUE, "my return");
        content = getRenderingOf(op);
        assertNotNull(content);

        // Collection
        DBCollection collection = mock(DBCollection.class);
        when(collection.getFullName()).thenReturn("this is a super cool collection");
        when(jp.getThis()).thenReturn(collection);
        op = MongoCollectionOperationCollectionAspect.aspectOf().createOperation(jp);
        op.put(OperationFields.RETURN_VALUE, "my return");
        content = getRenderingOf(op);
        assertNotNull(content);
    }
View Full Code Here

            Object target = mi.getThis();
            return getAttributes(mi.getMethod(), target == null ? null : target.getClass());
        }

        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

TOP

Related Classes of org.aspectj.lang.JoinPoint

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.