[jboss-user] [JBoss AOP] - Problems when debug EJB intercepted by JBoss AOP

Gustavo Gomes do-not-reply at jboss.com
Mon Aug 22 18:40:55 EDT 2011


Gustavo Gomes [http://community.jboss.org/people/gustavo.gomesc] created the discussion

"Problems when debug EJB intercepted by JBoss AOP"

To view the discussion, visit: http://community.jboss.org/message/622277#622277

--------------------------------------------------------------
I am using the JBoss AOP for intercept a static method.

The jboss-aop.xml used is:
<?xml version="1.0" encoding="UTF-8"?>
<aop xmlns="urn:jboss:aop-beans:1.0">
    <interceptor class="com.prana.tools.jee.log.LogInterceptor" 
            scope="PER_VM" />

    <bind pointcut="call(* com.prana.tools.jee.log.Log->getMessageKey(java.lang.Object))
            OR call(* com.prana.tools.jee.log.Log->key(java.lang.Object))">
        <interceptor-ref name="com.prana.tools.jee.log.LogInterceptor" />
    </bind>
</aop>

The EJB class that will be intercepted is:

@Stateless
public class TesteMkImpl implements TesteMkLocal, TesteMkRemote {
    private CampoMonetario teste1;
    private CampoTexto teste2, teste3;

    public TesteMkImpl() {
    }

    private String test(int a, int b) {
        return Boolean.toString(a > b);
    }

    public void executaTeste() throws TesteMkException {
        teste1 = new CampoMonetario(10);
        teste2 = new CampoTexto("N");
        teste3 = new CampoTexto("B./ID 9004915410/32460");

        validaNroControleParticipante2();
        validaNroControleParticipante(teste1, teste2, teste3);

        if (!teste1.isPreenchido()
                || teste1.getValorBigDecimal().toString().equalsIgnoreCase("")) {
            Object[] param = { "Teste", "Teste2" };
            throw new TesteMkException(*Log.getMessageKey("teste")*, param);
        }

        if (!teste1.isPreenchido()
                || teste1.getValorBigDecimal().toString().equalsIgnoreCase("")) {
            Object[] param = { "Teste", "Teste2" };
            throw new TesteMkException(*Log.getMessageKey("teste")*, param);
        }
        if (test(5, 6).equalsIgnoreCase("XPTO")) {
            Object[] param = { "Teste", "Teste2" };
            throw new TesteMkException(*Log.getMessageKey("teste")*, param);
        }
        if (test(6, 7).equalsIgnoreCase("XPTO")) {
            Object[] param = { "Teste", "Teste2" };
            throw new TesteMkException(*Log.getMessageKey("teste")*, param);
        }
    }

    private void execute() throws TesteMkException {
        int i = 1;
        Object[] param = null;

        if (Boolean.parseBoolean(test(1, 2))
                || (test(3, 4).equalsIgnoreCase("XPTO"))
                || test(5, 6).equalsIgnoreCase("XYZ")) {
            param = new Object[] { "Teste" + i, "Teste" + (i * 2) };
        }
        i++;
        if (Boolean.parseBoolean(test(1, 2))
                || (test(3, 4).equalsIgnoreCase("XPTO"))
                || test(5, 6).equalsIgnoreCase("XYZ")) {
            param = new Object[] { "Teste" + i, "Teste" + (i * 2) };
        }
        i++;
        if (Boolean.parseBoolean(test(1, 2))
                || (test(3, 4).equalsIgnoreCase("XPTO"))
                || test(5, 6).equalsIgnoreCase("XYZ")) {
            param = new Object[] { "Teste" + i, "Teste" + (i * 2) };
        }
        i++;
        if (Boolean.parseBoolean(test(1, 2))
                || (test(3, 4).equalsIgnoreCase("XPTO"))
                || test(5, 6).equalsIgnoreCase("XYZ")) {
            param = new Object[] { "Teste" + i, "Teste" + (i * 2) };
        }
        i++;
        ...
        repeat this if condition some times.
         ... 
        if (Boolean.parseBoolean(test(1, 2))
                || (test(3, 4).equalsIgnoreCase("XPTO"))
                || test(5, 6).equalsIgnoreCase("XYZ")) {
            param = new Object[] { "Teste" + i, "Teste" + (i * 2) };
        }
        i++;
... repe
   }
}

And the class that test this EJB is:

public class TesteMkTest {
    private TesteMkRemote testeMk;
    private TestLookup lookup;
    private TesteMkImpl testeMkImpl;

    public void setUp() throws Exception {
        lookup = new TestLookup();
        testeMk = (TesteMkRemote)lookup.getInitialContext().lookup("testeMk/TesteMkImpl/remote");
        testeMkImpl = new TesteMkImpl();
    }

    public void executeRemote() throws TesteMkException{
        testeMk.execute();
    }


    public void executeLocal() throws TesteMkException{
        testeMkImpl.execute();
    }

    public static void main(String[] args) throws Exception {
        TesteMkTest test = new TesteMkTest();
        test.setUp();
        test.executeRemote();
        test.executeLocal();
    }
}

I deploy the EJB with the interception configuration (jboss-aop.xml) in the JBoss AS 5.1.0.GA that uses JBoss AOP 2.1.1.GA in debug mode.
When I run the test class with a breakpoint on the first line of the method execute of the EJB and step over the method lines, the debug shows the wrong line after some step over on the executeRemote call, but no problems on the executeLocal call.

Does anyone know if this is a bug?
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/622277#622277]

Start a new discussion in JBoss AOP at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2027]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110822/835f00b6/attachment-0001.html 


More information about the jboss-user mailing list