<?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>Technotrance, Illusions and Perspectives &#187; aop</title>
	<atom:link href="http://myblog.shriharisc.com/tag/aop/feed/" rel="self" type="application/rss+xml" />
	<link>http://myblog.shriharisc.com</link>
	<description>A dose of everyday bruises with Java/JEE</description>
	<lastBuildDate>Mon, 02 Aug 2010 17:45:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Method entry-exit logging in Google Guice through AOP</title>
		<link>http://myblog.shriharisc.com/2009/07/30/method-entry-exit-logging-in-guice-with-aop/</link>
		<comments>http://myblog.shriharisc.com/2009/07/30/method-entry-exit-logging-in-guice-with-aop/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 17:59:50 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[jee-light]]></category>
		<category><![CDATA[aop]]></category>
		<category><![CDATA[google-guice]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=83</guid>
		<description><![CDATA[This cool tip explains 2 step logic to log all methods entry and exit information with profiling in Guice with AOP (aop-alliance)
1) Define a Guice Module with a method level logging Interceptor binding at all class levels and method levels.

public class MyModule extends AbstractModule
{     public void configure()
     [...]]]></description>
			<content:encoded><![CDATA[<p>This cool tip explains 2 step logic to log all methods entry and exit information with profiling in Guice with AOP (aop-alliance)</p>
<p>1) Define a Guice Module with a method level logging Interceptor binding at all class levels and method levels.</p>
<pre class="brush: java">
public class MyModule extends AbstractModule
{     public void configure()
      {      bindInterceptor(Matchers.any(), Matchers.any(), new LoggingMethodInterceptor());
      }
}
</pre>
<p>2) Define a method level logging interceptor to log entry and exit messages with profiled information.</p>
<pre class="brush: java">
public class LoggingMethodInterceptor implements MethodInterceptor
{   public Object invoke(MethodInvocation invocation) throws Throwable
    {    Object returnValue = null;
    	 long start = System.currentTimeInMillis();
         System.out.println(&quot;Method &quot;+invocation.getMethod()+&quot; entered from &quot;+invocation.getThis()+&quot; with arguments &quot;+invocation.getArguments());
         returnValue = invocation.proceed();
         long end = System.currentTimeInMillis();
         System.out.println(&quot;Method &quot;+invocation.getMethod()+&quot; exited in &quot;+((end-start)/1000L)+&quot; seconds&quot;);
         return returnValue;
    }
}
</pre>
<p>One could use this logic to extend and introduce many cross-cutting concerns such as Transaction Management, secure access to method </p>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/07/30/method-entry-exit-logging-in-guice-with-aop/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
