<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jayway Team Blog &#187; tracing</title>
	<atom:link href="http://blog.jayway.com/tag/tracing/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jayway.com</link>
	<description>Sharing Experience</description>
	<lastBuildDate>Sun, 05 Sep 2010 20:32:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Indented Tracing Using AspectJ</title>
		<link>http://blog.jayway.com/2006/12/15/indented-tracing-using-aspectj/</link>
		<comments>http://blog.jayway.com/2006/12/15/indented-tracing-using-aspectj/#comments</comments>
		<pubDate>Fri, 15 Dec 2006 15:36:14 +0000</pubDate>
		<dc:creator>Ulrik Sandberg</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[aop]]></category>
		<category><![CDATA[aspectj]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tracing]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=188</guid>
		<description><![CDATA[Given inspiration from the book "AspectJ In Action", I wrote a little aspect that provides indented tracing of method executions. This means that the aspect keeps track of the current indentation level in a call flow, giving an output like the following: Entering [org.springframework.ldap.LdapTemplateListTest.] Exiting [org.springframework.ldap.LdapTemplateListTest.] Entering [org.springframework.ldap.LdapTemplateListTest.setUp] Entering [org.springframework.ldap.LdapTemplate.] Entering [org.springframework.ldap.DefaultNamingExceptionTranslator.] Exiting [org.springframework.ldap.DefaultNamingExceptionTranslator.] Exiting [...]]]></description>
			<content:encoded><![CDATA[<p>Given inspiration from the book "AspectJ In Action", I wrote a little aspect that provides indented tracing of method executions. This means that the aspect keeps track of the current indentation level in a call flow<span id="more-188"></span>, giving an output like the following:</p>
<pre>Entering [org.springframework.ldap.LdapTemplateListTest.]
Exiting [org.springframework.ldap.LdapTemplateListTest.]
Entering [org.springframework.ldap.LdapTemplateListTest.setUp]
  Entering [org.springframework.ldap.LdapTemplate.]
    Entering [org.springframework.ldap.DefaultNamingExceptionTranslator.]
    Exiting [org.springframework.ldap.DefaultNamingExceptionTranslator.]
  Exiting [org.springframework.ldap.LdapTemplate.]
  Entering [org.springframework.ldap.LdapTemplate.setExceptionTranslator]
  Exiting [org.springframework.ldap.LdapTemplate.setExceptionTranslator]
Exiting [org.springframework.ldap.LdapTemplateListTest.setUp]
Entering [org.springframework.ldap.LdapTemplateListTest.testList_Name]
  Entering [org.springframework.ldap.LdapTemplateListTest.expectGetReadOnlyContext]
  ...</pre>
<p>The part that keeps track of the indentation level was written as a reusable aspect:</p>
<pre class="java"><span style="color: #000000; font-weight: bold;">package</span> org.<span style="color: #006600;">springframework</span>.<span style="color: #006600;">ldap</span>.<span style="color: #006600;">aspects</span>; 
&nbsp;
<span style="color: #a1a100;">import org.apache.commons.logging.Log;</span>
<span style="color: #a1a100;">import org.apache.commons.logging.LogFactory;</span>
<span style="color: #a1a100;">import org.aspectj.lang.JoinPoint; </span>
&nbsp;
<span style="color: #808080; font-style: italic;">/**
 * Abstract logging aspect for producing indented logging. Override the
 * &lt;code&gt;loggingOperations&lt;/code&gt; pointcut in order to provide the joinpoints
 * where you would like the logging to be applied. Also override the methods
 * &lt;code&gt;beforeLog&lt;/code&gt; and &lt;code&gt;afterLog&lt;/code&gt; to provide the actual
 * logging statements. The current indentation string will be provided to these
 * methods, along with an instance of &lt;code&gt;JoinPoint&lt;/code&gt;.
 *
 * @author Ulrik Sandberg
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">abstract</span> aspect IndentedLogging <span style="color: #66cc66;">&#123;</span>
    Log log = LogFactory.<span style="color: #006600;">getLog</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;trace&quot;</span><span style="color: #66cc66;">&#41;</span>; 
&nbsp;
    <span style="color: #808080; font-style: italic;">/**
     * The current number of indentation levels.
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">int</span> indentationlevel = <span style="color: #cc66cc;">0</span>; 
&nbsp;
    <span style="color: #808080; font-style: italic;">/**
     * Override and provide pointcut to log.
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">abstract</span> pointcut loggingOperations<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
&nbsp;
    <span style="color: #808080; font-style: italic;">/**
     * Override and provide the actual logging statement for when the logged
     * method is entered.
     *
     * @param indent
     *            The string of spaces that provides the current indentation.
     * @param joinPoint
     *            Information about the current joinpoint.
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #993333;">void</span> beforeLog<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> indent, JoinPoint joinPoint<span style="color: #66cc66;">&#41;</span>; 
&nbsp;
    <span style="color: #808080; font-style: italic;">/**
     * Override and provide the actual logging statement for when the logged
     * method is exited.
     *
     * @param indent
     *            The string of spaces that provides the current indentation.
     * @param joinPoint
     *            Information about the current joinpoint.
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #993333;">void</span> afterLog<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> indent, JoinPoint joinPoint<span style="color: #66cc66;">&#41;</span>; 
&nbsp;
    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> around<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>: loggingOperations<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AStringBuffer+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">StringBuffer</span></a> sb = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AStringBuffer+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">StringBuffer</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>log.<span style="color: #006600;">isInfoEnabled</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            indentationlevel++;
            <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>, spaces = indentationlevel * <span style="color: #cc66cc;">2</span>; i &amp;lt; spaces; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                sb.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot; &quot;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
            beforeLog<span style="color: #66cc66;">&#40;</span>sb.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, thisJoinPoint<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> result;
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
            result = proceed<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>log.<span style="color: #006600;">isInfoEnabled</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                afterLog<span style="color: #66cc66;">&#40;</span>sb.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, thisJoinPoint<span style="color: #66cc66;">&#41;</span>;
                indentationlevel--;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> result;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>
<p>Since the reusable aspect does all the grunt work, the actual tracing aspect becomes rather small:</p>
<pre class="java"><span style="color: #000000; font-weight: bold;">package</span> org.<span style="color: #006600;">springframework</span>.<span style="color: #006600;">ldap</span>.<span style="color: #006600;">aspects</span>; 
&nbsp;
<span style="color: #a1a100;">import org.aspectj.lang.JoinPoint; </span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> aspect TraceAspect <span style="color: #000000; font-weight: bold;">extends</span> IndentedLogging <span style="color: #66cc66;">&#123;</span>
    declare precedence: TraceAspect, *; 
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> pointcut loggingOperations<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:
        <span style="color: #66cc66;">&#40;</span>execution<span style="color: #66cc66;">&#40;</span>* *.<span style="color: #006600;">*</span><span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> || execution<span style="color: #66cc66;">&#40;</span>*.<span style="color: #000000; font-weight: bold;">new</span><span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        &amp;amp;&amp;amp; !within<span style="color: #66cc66;">&#40;</span>IndentedLogging+<span style="color: #66cc66;">&#41;</span>; 
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> beforeLog<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> indent, JoinPoint joinPoint<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        log.<span style="color: #006600;">info</span><span style="color: #66cc66;">&#40;</span>indent + <span style="color: #ff0000;">&quot;Entering [&quot;</span>
                + joinPoint.<span style="color: #006600;">getSignature</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDeclaringTypeName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;.&quot;</span>
                + joinPoint.<span style="color: #006600;">getSignature</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;]&quot;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span> 
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> afterLog<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> indent, JoinPoint joinPoint<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        log.<span style="color: #006600;">info</span><span style="color: #66cc66;">&#40;</span>indent + <span style="color: #ff0000;">&quot;Exiting [&quot;</span>
                + joinPoint.<span style="color: #006600;">getSignature</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDeclaringTypeName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;.&quot;</span>
                + joinPoint.<span style="color: #006600;">getSignature</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;]&quot;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>
<p>Now, let's say we don't want to trace each and every method and constructor execution, but rather a small subset, like for example only the normal methods (no constructors) in any subclass of <code>NameClassPairCallbackHandler</code>. We'll remove the execution of <code>new</code> from the pointcut and add the handler subclass condition:</p>
<pre class="java"><span style="color: #000000; font-weight: bold;">public</span> aspect TraceAspect <span style="color: #000000; font-weight: bold;">extends</span> IndentedLogging <span style="color: #66cc66;">&#123;</span>
    declare precedence: TraceAspect, *; 
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> pointcut loggingOperations<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:
        execution<span style="color: #66cc66;">&#40;</span>* *.<span style="color: #006600;">*</span><span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">// just plain methods</span>
        &amp;amp;&amp;amp; !within<span style="color: #66cc66;">&#40;</span>IndentedLogging+<span style="color: #66cc66;">&#41;</span>
        &amp;amp;&amp;amp; within<span style="color: #66cc66;">&#40;</span>org.<span style="color: #006600;">springframework</span>.<span style="color: #006600;">ldap</span>.<span style="color: #006600;">NameClassPairCallbackHandler</span>+<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// added</span>
    ...</pre>
<p>The output becomes:</p>
<pre>Entering [org.springframework.ldap.CollectingNameClassPairCallbackHandler.handleNameClassPair]
  Entering [org.springframework.ldap.LdapTemplate$MappingCollectingNameClassPairCallbackHandler.getObjectFromNameClassPair]
  Exiting [org.springframework.ldap.LdapTemplate$MappingCollectingNameClassPairCallbackHandler.getObjectFromNameClassPair]
Exiting [org.springframework.ldap.CollectingNameClassPairCallbackHandler.handleNameClassPair]
Entering [org.springframework.ldap.CollectingNameClassPairCallbackHandler.getList]
Exiting [org.springframework.ldap.CollectingNameClassPairCallbackHandler.getList]</pre>
<p>You might argue that it would be good to see the arguments to each call. That could easily be done by using <code>JoinPoint.getArgs()</code> in the tracing aspect. It would look like this:</p>
<pre class="java"><span style="color: #000000; font-weight: bold;">package</span> org.<span style="color: #006600;">springframework</span>.<span style="color: #006600;">ldap</span>.<span style="color: #006600;">aspects</span>; 
&nbsp;
<span style="color: #a1a100;">import org.aspectj.lang.JoinPoint; </span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> aspect TraceAspect <span style="color: #000000; font-weight: bold;">extends</span> IndentedLogging <span style="color: #66cc66;">&#123;</span>
    declare precedence: TraceAspect, *; 
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> pointcut loggingOperations<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:
        <span style="color: #66cc66;">&#40;</span>execution<span style="color: #66cc66;">&#40;</span>* *.<span style="color: #006600;">*</span><span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        &amp;amp;&amp;amp; !within<span style="color: #66cc66;">&#40;</span>IndentedLogging+<span style="color: #66cc66;">&#41;</span>
        &amp;amp;&amp;amp; within<span style="color: #66cc66;">&#40;</span>*..<span style="color: #006600;">NameClassPairCallbackHandler</span>+<span style="color: #66cc66;">&#41;</span>; 
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> beforeLog<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> indent, JoinPoint joinPoint<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        log.<span style="color: #006600;">info</span><span style="color: #66cc66;">&#40;</span>indent + <span style="color: #ff0000;">&quot;Entering [&quot;</span>
                + joinPoint.<span style="color: #006600;">getSignature</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDeclaringTypeName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;.&quot;</span>
                + joinPoint.<span style="color: #006600;">getSignature</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
                + createParameterMessage<span style="color: #66cc66;">&#40;</span>indent, joinPoint<span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;]&quot;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span> 
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> afterLog<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> indent, JoinPoint joinPoint<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        log.<span style="color: #006600;">info</span><span style="color: #66cc66;">&#40;</span>indent + <span style="color: #ff0000;">&quot;Exiting [&quot;</span>
                + joinPoint.<span style="color: #006600;">getSignature</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDeclaringTypeName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;.&quot;</span>
                + joinPoint.<span style="color: #006600;">getSignature</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
                + createParameterMessage<span style="color: #66cc66;">&#40;</span>indent, joinPoint<span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;]&quot;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span> 
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> createParameterMessage<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> indent, JoinPoint joinPoint<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AStringBuffer+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">StringBuffer</span></a> sb = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AStringBuffer+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">StringBuffer</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;(&quot;</span><span style="color: #66cc66;">&#41;</span>;
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args = joinPoint.<span style="color: #006600;">getArgs</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>args.<span style="color: #006600;">length</span> &amp;gt; <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            sb.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>    &quot;</span> + indent<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
        <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>; i &amp;lt; args.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            sb.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>i != args.<span style="color: #006600;">length</span> - <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                sb.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">','</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
        sb.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;)&quot;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #000000; font-weight: bold;">return</span> sb.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>
<p>And the output would be this:</p>
<pre>Entering [org.springframework.ldap.CollectingNameClassPairCallbackHandler.handleNameClassPair(
    o=example.com: com.example.SomeClass)]
  Entering [org.springframework.ldap.LdapTemplate$MappingCollectingNameClassPairCallbackHandler.getObjectFromNameClassPair(
      o=example.com: com.example.SomeClass)]
  Exiting [org.springframework.ldap.LdapTemplate$MappingCollectingNameClassPairCallbackHandler.getObjectFromNameClassPair(
      o=example.com: com.example.SomeClass)]
Exiting [org.springframework.ldap.CollectingNameClassPairCallbackHandler.handleNameClassPair(
    o=example.com: com.example.SomeClass)]
Entering [org.springframework.ldap.CollectingNameClassPairCallbackHandler.getList()]
Exiting [org.springframework.ldap.CollectingNameClassPairCallbackHandler.getList()]</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2006/12/15/indented-tracing-using-aspectj/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
