<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Interesting trick to finding Java caller</title>
	<atom:link href="http://www.warneronstine.com/2008/03/27/interesting-trick-to-finding-java-caller/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.warneronstine.com/2008/03/27/interesting-trick-to-finding-java-caller/</link>
	<description>Where technology and art disappear</description>
	<lastBuildDate>Wed, 17 Nov 2010 10:52:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Brian</title>
		<link>http://www.warneronstine.com/2008/03/27/interesting-trick-to-finding-java-caller/comment-page-1/#comment-144</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<guid isPermaLink="false"></guid>
		<description>You can also just ask the current thread for its stack trace rather than creating the exception.</description>
		<content:encoded><![CDATA[<p>You can also just ask the current thread for its stack trace rather than creating the exception.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://www.warneronstine.com/2008/03/27/interesting-trick-to-finding-java-caller/comment-page-1/#comment-145</link>
		<dc:creator>James</dc:creator>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<guid isPermaLink="false"></guid>
		<description>This is cool.  Now...how do you get the calling Object?</description>
		<content:encoded><![CDATA[<p>This is cool.  Now&#8230;how do you get the calling Object?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Leo</title>
		<link>http://www.warneronstine.com/2008/03/27/interesting-trick-to-finding-java-caller/comment-page-1/#comment-146</link>
		<dc:creator>Leo</dc:creator>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<guid isPermaLink="false"></guid>
		<description>It&#039;s a Throwable, but it&#039;s also probably getting the stack trace from the current Thread, so that&#039;s a good idea.

Also attainable from the StackTraceElement is the method name in case you want to know who&#039;s calling you. It&#039;s useful if you want supergeneric recursion or callback by convention.</description>
		<content:encoded><![CDATA[<p>It&#8217;s a Throwable, but it&#8217;s also probably getting the stack trace from the current Thread, so that&#8217;s a good idea.</p>
<p>Also attainable from the StackTraceElement is the method name in case you want to know who&#8217;s calling you. It&#8217;s useful if you want supergeneric recursion or callback by convention.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://www.warneronstine.com/2008/03/27/interesting-trick-to-finding-java-caller/comment-page-1/#comment-147</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<guid isPermaLink="false"></guid>
		<description>It used to be that Thread.getStackTrace accompished its task by doing the throw too. I suspect things haven&#039;t changed.

Nicely done.</description>
		<content:encoded><![CDATA[<p>It used to be that Thread.getStackTrace accompished its task by doing the throw too. I suspect things haven&#8217;t changed.</p>
<p>Nicely done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anjan bacchu</title>
		<link>http://www.warneronstine.com/2008/03/27/interesting-trick-to-finding-java-caller/comment-page-1/#comment-148</link>
		<dc:creator>anjan bacchu</dc:creator>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<guid isPermaLink="false"></guid>
		<description>hi there,

  I didn&#039;t understand how getLog() gets used in info() call. Sorry for being dense -- can you explain with lil more details -- probably there are others who might not get it.

I&#039;ve been using the new Throwable() trick for a long time but this one I don&#039;t grok.

BR,
~A</description>
		<content:encoded><![CDATA[<p>hi there,</p>
<p>  I didn&#8217;t understand how getLog() gets used in info() call. Sorry for being dense &#8212; can you explain with lil more details &#8212; probably there are others who might not get it.</p>
<p>I&#8217;ve been using the new Throwable() trick for a long time but this one I don&#8217;t grok.</p>
<p>BR,<br />
~A</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Warner Onstine</title>
		<link>http://www.warneronstine.com/2008/03/27/interesting-trick-to-finding-java-caller/comment-page-1/#comment-149</link>
		<dc:creator>Warner Onstine</dc:creator>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<guid isPermaLink="false"></guid>
		<description>@anjun
Here&#039;s how `info()` works

    public static final void info(String pattern, Object ... objs) {
        getLog().debug(getMessage(pattern, objs));
    }

Which you can do a static import on:

    import static FormattedLogging.info

and then directly reference in your class. This way you no longer have to do `LogFactory.getLog(MyClass.class)`, this will do it for you automatically.

@Andy
The credit belongs all to Leo :-).</description>
		<content:encoded><![CDATA[<p>@anjun<br />
Here&#8217;s how `info()` works</p>
<p>    public static final void info(String pattern, Object &#8230; objs) {<br />
        getLog().debug(getMessage(pattern, objs));<br />
    }</p>
<p>Which you can do a static import on:</p>
<p>    import static FormattedLogging.info</p>
<p>and then directly reference in your class. This way you no longer have to do `LogFactory.getLog(MyClass.class)`, this will do it for you automatically.</p>
<p>@Andy<br />
The credit belongs all to Leo <img src='http://www.warneronstine.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Casper</title>
		<link>http://www.warneronstine.com/2008/03/27/interesting-trick-to-finding-java-caller/comment-page-1/#comment-150</link>
		<dc:creator>Casper</dc:creator>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<guid isPermaLink="false"></guid>
		<description>I&#039;ve used this numerous times as a means to achieve IOC during DBUnit tests, inject test data into the database by tracing the class and test method and load data from a file named the same.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve used this numerous times as a means to achieve IOC during DBUnit tests, inject test data into the database by tracing the class and test method and load data from a file named the same.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gagan</title>
		<link>http://www.warneronstine.com/2008/03/27/interesting-trick-to-finding-java-caller/comment-page-1/#comment-151</link>
		<dc:creator>Gagan</dc:creator>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<guid isPermaLink="false"></guid>
		<description>Stack trace creation is a heavy operation isn&#039;t it, i wonder about the performance aspects of this?</description>
		<content:encoded><![CDATA[<p>Stack trace creation is a heavy operation isn&#8217;t it, i wonder about the performance aspects of this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arnaud</title>
		<link>http://www.warneronstine.com/2008/03/27/interesting-trick-to-finding-java-caller/comment-page-1/#comment-152</link>
		<dc:creator>Arnaud</dc:creator>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<guid isPermaLink="false"></guid>
		<description>@Gagan it must be pretty costly also I never mesure the performance it. It would probably be usefull to cache the Logger in a way or another.

I use the Exception trick to store when a connection was open to detect not close exception years ago - the state was capture in the finalizer, which print the stack trace to indicate where the leak came from -.</description>
		<content:encoded><![CDATA[<p>@Gagan it must be pretty costly also I never mesure the performance it. It would probably be usefull to cache the Logger in a way or another.</p>
<p>I use the Exception trick to store when a connection was open to detect not close exception years ago &#8211; the state was capture in the finalizer, which print the stack trace to indicate where the leak came from -.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Notafan</title>
		<link>http://www.warneronstine.com/2008/03/27/interesting-trick-to-finding-java-caller/comment-page-1/#comment-153</link>
		<dc:creator>Notafan</dc:creator>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<guid isPermaLink="false"></guid>
		<description>You&#039;ve really got to be asking yourself why you are writing ugly hacks like this. It&#039;s expensive and clumsy. What if you want to use AOP to intercept calls?

Seems ok for test code but if it makes it to your production code you&#039;ve got to question your design.</description>
		<content:encoded><![CDATA[<p>You&#8217;ve really got to be asking yourself why you are writing ugly hacks like this. It&#8217;s expensive and clumsy. What if you want to use AOP to intercept calls?</p>
<p>Seems ok for test code but if it makes it to your production code you&#8217;ve got to question your design.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
