<?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/"
	>

<channel>
	<title>Caucho Technology</title>
	<atom:link href="http://blog.caucho.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.caucho.com</link>
	<description>Inside info, thoughts, and opinions from Caucho engineers</description>
	<pubDate>Thu, 26 Aug 2010 19:22:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Resin and IDE support</title>
		<link>http://blog.caucho.com/?p=547</link>
		<comments>http://blog.caucho.com/?p=547#comments</comments>
		<pubDate>Thu, 26 Aug 2010 19:22:29 +0000</pubDate>
		<dc:creator>emil</dc:creator>
		
		<category><![CDATA[Community]]></category>

		<category><![CDATA[ant]]></category>

		<category><![CDATA[eclipse]]></category>

		<category><![CDATA[ide]]></category>

		<category><![CDATA[maven]]></category>

		<category><![CDATA[netbeans]]></category>

		<category><![CDATA[resin]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=547</guid>
		<description><![CDATA[ Hello, web developers!
We&#8217;d like to get a sense of the development tools you&#8217;re using with Resin and what tools you&#8217;d like to use with Resin. If you could post your thoughts, we&#8217;d appreciate it and will try to incorporate your ideas into our upcoming development efforts. There are a few framing questions below, but [...]]]></description>
			<content:encoded><![CDATA[<!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div style='float:left'><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://blog.caucho.com/?p=547&amp;t=Resin+and+IDE+support++&amp;s=icon' height='16' width='16' frameborder='0' scrolling='no'></iframe></td></table></div><p>Hello, web developers!</p>
<p>We&#8217;d like to get a sense of the development tools you&#8217;re using with Resin and what tools you&#8217;d like to use with Resin. If you could post your thoughts, we&#8217;d appreciate it and will try to incorporate your ideas into our upcoming development efforts. There are a few framing questions below, but please feel free to comment on any other development issues that we&#8217;ve missed:</p>
<ul>
<li>Do you use an IDE when developing with Resin? Which one?</li>
<li>    If you use Eclipse, do you use the plugin from <a href="http://caucho.com/eclipse">http://caucho.com/eclipse?</a></li>
<li>    If you didn&#8217;t know about the Resin eclipse plugin, where do you expect to find it? (e.g. on our webpage, in the Eclipse update system, etc.)</li>
<li>    Do you use other tools such as Maven to develop with Resin?</li>
<li>    If you use Maven or some other command line tool, what plugins and/or features would you like to see from Resin?</li>
<li>    Do you deploy to Resin in production directly from an IDE or command line tool? If not, is that a desirable feature?</li>
</ul>
<p>You can also reply to <a href="http://forum.caucho.com/showthread.php?t=16022">this related topic</a> on our forums and/or take the poll there.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/?feed=rss2&amp;p=547</wfw:commentRss>
		</item>
		<item>
		<title>Resin 4.0.10</title>
		<link>http://blog.caucho.com/?p=545</link>
		<comments>http://blog.caucho.com/?p=545#comments</comments>
		<pubDate>Thu, 26 Aug 2010 16:37:31 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=545</guid>
		<description><![CDATA[ Resin 4.0.10 is now available.

Several threading and alarm/timing fixes for 4.0.9
Created HealthService to generalize the ping and health checks
Improved Resin/Watchdog communication, giving more information on restarts

]]></description>
			<content:encoded><![CDATA[<!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div style='float:left'><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://blog.caucho.com/?p=545&amp;t=Resin+4.0.10&amp;s=icon' height='16' width='16' frameborder='0' scrolling='no'></iframe></td></table></div><p>Resin 4.0.10 is now available.</p>
<ol>
<li>Several threading and alarm/timing fixes for 4.0.9
<li>Created HealthService to generalize the ping and health checks
<li>Improved Resin/Watchdog communication, giving more information on restarts
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/?feed=rss2&amp;p=545</wfw:commentRss>
		</item>
		<item>
		<title>heartbeat cluster service</title>
		<link>http://blog.caucho.com/?p=543</link>
		<comments>http://blog.caucho.com/?p=543#comments</comments>
		<pubDate>Mon, 23 Aug 2010 21:18:32 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=543</guid>
		<description><![CDATA[ As part of our Resin 4.0 work, we&#8217;re going through the various Resin services and improving the testing and quality of each service. In Resin 4.0.9, we revamped the heartbeat service which is at the center of Resin&#8217;s clustering configuration.
In each cluster, Resin assigns the first three servers to be the triad servers, the [...]]]></description>
			<content:encoded><![CDATA[<!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div style='float:left'><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://blog.caucho.com/?p=543&amp;t=heartbeat+cluster+service&amp;s=icon' height='16' width='16' frameborder='0' scrolling='no'></iframe></td></table></div><p>As part of our Resin 4.0 work, we&#8217;re going through the various Resin services and improving the testing and quality of each service. In Resin 4.0.9, we revamped the heartbeat service which is at the center of Resin&#8217;s clustering configuration.</p>
<p>In each cluster, Resin assigns the first three servers to be the triad servers, the triple-redundant hub for the clustering model. Each of the triad servers can act as a backup for any of the others.</p>
<p>For the heartbeat service, every Resin server in the cluster connects to each triad server and sends a heartbeat every minute.  If the connection drops or the heartbeat is missing, the triad knows immediately that the server has failed and can take appropriate measures to deal with the failure. For example, if a server is down, Resin won&#8217;t waste effort trying to send messages to the dead server. The heartbeat, however, retries the downed server every 60 seconds, so Resin will know the status as soon as it comes up.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/?feed=rss2&amp;p=543</wfw:commentRss>
		</item>
		<item>
		<title>code is free</title>
		<link>http://blog.caucho.com/?p=539</link>
		<comments>http://blog.caucho.com/?p=539#comments</comments>
		<pubDate>Fri, 20 Aug 2010 18:36:51 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=539</guid>
		<description><![CDATA[ Well, not really, but in most of the specifications I&#8217;ve worked with, the architect-types (people who haven&#8217;t touched code in years) assume that the cost of adding complexity is zero.
There&#8217;s a weird discussion in the websocket spec where people are arguing that saving one (1) byte in the frame header will lead to massive [...]]]></description>
			<content:encoded><![CDATA[<!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div style='float:left'><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://blog.caucho.com/?p=539&amp;t=code+is+free&amp;s=icon' height='16' width='16' frameborder='0' scrolling='no'></iframe></td></table></div><p>Well, not really, but in most of the specifications I&#8217;ve worked with, the architect-types (people who haven&#8217;t touched code in years) assume that the cost of adding complexity is zero.</p>
<p>There&#8217;s a weird discussion in the websocket spec where people are arguing that saving one (1) byte in the frame header will lead to massive improvements in latency, and at the same time assume the additional code complexity required to pack the frame into the small frame is zero. In reality, the savings from one (1) byte is pretty small, practically unmeasurable, and although the extra code complexity isn&#8217;t huge, it&#8217;s also not zero.</p>
<p>Now, in the proposal even a tweet can&#8217;t fit into the small frame (127 bytes), because a full tweet with metadata is about 350 bytes.</p>
<p>That point was brushed away with the argument that a <em>compressed tweet</em> would fit into 127 bytes. Assuming, I think, that compression is also free because it&#8217;s code. So in order to save one byte in a TCP packet, they&#8217;re assuming all the overhead of compression.</p>
<p>The thinking that code is free has twisted specifications in the past. EJB is a notorious one. The working assumption was that the EJB design could be messy (in particular the XML), because people would write IDE tools to solve the problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/?feed=rss2&amp;p=539</wfw:commentRss>
		</item>
		<item>
		<title>SSL vs JSSE</title>
		<link>http://blog.caucho.com/?p=538</link>
		<comments>http://blog.caucho.com/?p=538#comments</comments>
		<pubDate>Mon, 26 Jul 2010 21:03:56 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=538</guid>
		<description><![CDATA[ Just some quick numbers between SSL vs JSSE on Resin because some people have asked:

485 ops, SSL 1k hello file, no keepalive
135 ops, JSSE 1k hello file, no keepalive

272 ops SSL, 64k file, keepalive
51 ops, JSSE 64k hello file, 4 keepalive

The first set of numbers is for a single request, showing the startup cost [...]]]></description>
			<content:encoded><![CDATA[<!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div style='float:left'><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://blog.caucho.com/?p=538&amp;t=SSL+vs+JSSE&amp;s=icon' height='16' width='16' frameborder='0' scrolling='no'></iframe></td></table></div><p>Just some quick numbers between SSL vs JSSE on Resin because some people have asked:</p>
<pre>
485 ops, SSL 1k hello file, no keepalive
135 ops, JSSE 1k hello file, no keepalive

272 ops SSL, 64k file, keepalive
51 ops, JSSE 64k hello file, 4 keepalive
</pre>
<p>The first set of numbers is for a single request, showing the startup cost of SSL vs JSSE.</p>
<p>The second set shows a more typical page load, with multiple objects (4) and larger 64k, showing the long-term, actual costs of the two.</p>
<p>In both cases, the difference is about 3-4x.</p>
<p>For faster performance, a hardware accelerator would be even faster.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/?feed=rss2&amp;p=538</wfw:commentRss>
		</item>
		<item>
		<title>MacOS-X Resin launchctl</title>
		<link>http://blog.caucho.com/?p=534</link>
		<comments>http://blog.caucho.com/?p=534#comments</comments>
		<pubDate>Mon, 19 Jul 2010 01:18:35 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=534</guid>
		<description><![CDATA[ 


]]></description>
			<content:encoded><![CDATA[<!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div style='float:left'><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://blog.caucho.com/?p=534&amp;t=MacOS-X+Resin+launchctl&amp;s=icon' height='16' width='16' frameborder='0' scrolling='no'></iframe></td></table></div><div class="codesnip-container" >
<pre>
&#038;lt?xml version="1.0" encoding="UTF-8"?>
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
&lt;plist version="1.0">
&lt;dict>
        &lt;key>Label&lt;/key>
        &lt;string>com.caucho.resin&lt;/string>
        &lt;key>ProgramArguments&lt;/key>
        &lt;array>
 	        &lt;string>/usr/bin/java&lt;/string>
                &lt;string>-jar&lt;/string>
	        &lt;string>/Users/scottferguson/resin-4.0.8/lib/resin.jar&lt;/string>
                &lt;string>console&lt;/string>
	&lt;/array>
        &lt;key>StandardErrorPath&lt;/key>
	&lt;string>/Users/scottferguson/resin-4.0.8/log/test.err&lt;/string>
        &lt;key>StandardOutPath&lt;/key>
	&lt;string>/Users/scottferguson/resin-4.0.8/log/test.log&lt;/string>
&lt;/dict>
&lt;/plist></div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/?feed=rss2&amp;p=534</wfw:commentRss>
		</item>
		<item>
		<title>CDI as a Catalyst</title>
		<link>http://blog.caucho.com/?p=532</link>
		<comments>http://blog.caucho.com/?p=532#comments</comments>
		<pubDate>Tue, 06 Jul 2010 18:57:45 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=532</guid>
		<description><![CDATA[ Although engineers understand the purpose and value of CDI for frameworks and applications, it&#8217;s been a little more complicated to explain to non-technical staff. One metaphor that&#8217;s helped is explaining CDI as a catalyst.
With the idea of a catalyst in mind, it&#8217;s not that it&#8217;s impossible to write a framework or an application without [...]]]></description>
			<content:encoded><![CDATA[<!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div style='float:left'><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://blog.caucho.com/?p=532&amp;t=CDI+as+a+Catalyst&amp;s=icon' height='16' width='16' frameborder='0' scrolling='no'></iframe></td></table></div><p>Although engineers understand the purpose and value of CDI for frameworks and applications, it&#8217;s been a little more complicated to explain to non-technical staff. One metaphor that&#8217;s helped is explaining CDI as a catalyst.</p>
<p>With the idea of a catalyst in mind, it&#8217;s not that it&#8217;s impossible to write a framework or an application without CDI, or that CDI provides a specific capability, but CDI makes development faster and more extensible than coding alone.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/?feed=rss2&amp;p=532</wfw:commentRss>
		</item>
		<item>
		<title>CDI migration: module inside a framework</title>
		<link>http://blog.caucho.com/?p=526</link>
		<comments>http://blog.caucho.com/?p=526#comments</comments>
		<pubDate>Fri, 25 Jun 2010 17:13:22 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Engineering]]></category>

		<category><![CDATA[cdi]]></category>

		<category><![CDATA[migration]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=526</guid>
		<description><![CDATA[ For people who want to use CDI, the most difficult problem is a large legacy of existing code. Rewriting an entire codebase is not possible (and not wise) and evolutionary change has proven itself as more effective and manageable, even if it doesn&#8217;t sounds as impressive as a full rewrite. So the trick to [...]]]></description>
			<content:encoded><![CDATA[<!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div style='float:left'><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://blog.caucho.com/?p=526&amp;t=CDI+migration%3A+module+inside+a+framework&amp;s=icon' height='16' width='16' frameborder='0' scrolling='no'></iframe></td></table></div><p>For people who want to use CDI, the most difficult problem is a large legacy of existing code. Rewriting an entire codebase is not possible (and not wise) and evolutionary change has proven itself as more effective and manageable, even if it doesn&#8217;t sounds as impressive as a full rewrite. So the trick to migrating to CDI is finding ways to change one piece of the project.</p>
<p>If you have a service-oriented architecture (when used a legitimate design pattern, not the web services buzzword), you can explore CDI with one service, and transition between the styles using JNDI to enter the CDI environment. A module inside a framework also fits this pattern, like an application within wicket. Essentially, any case where the framework is non-CDI but you want to write a module using CDI. The key is getting access to CDI&#8217;s programmatic interface BeanManager using JNDI.</p>
<p>The code to load a CDI-enabled service inside a framework with JNDI is boilerplate. You&#8217;ll want to put it in a utility class. The class you load with the utility will be your main service entry, or a root node in a component graph. You&#8217;ll use the code like the following, where &#8220;myBean&#8221; is a fully CDI-enabled bean with injection, interception, XA annotations, events, etc:</p>
<div class="codesnip-container" >CandiUtil candi = new CandiUtil();</p>
<p>MyCdiBean myBean = candi.getReference(MyCdiBean.class);</p></div>
<p>The utility class is boilerplate code. The BeanManager code is an SPI interface and it&#8217;s a bit more verbose than API code, but the added flexibility for framework integration is worth the added complexity. This integration code is only needed at the boundary of CDI and inside a foreign web framework; it&#8217;s not needed within a CDI module.</p>
<div class="codesnip-container" >
<pre>
import javax.naming.*;
import javax.enterprise.context.spi.*;
import javax.enterprise.inject.spi.*;
import java.util.*;

public class CandiUtil {
  private BeanManager _cdiManager;

  public &lt;T> T getReference(Class&lt;T> beanClass)
  {
     BeanManager cdiManager = getBeanManager();

     Bean&lt;T> bean = (Bean&lt;T>) cdiManager.resolve(cdi.getBeans(beanClass));
     CreationalContext&lt;T> env = cdiManager.createCreationalContext(bean);

     return cdiManager.getReference(bean, beanClass, env);
  }

  private BeanManger getBeanManager()
  {
     if (_cdiManager == null) {
        try {
           InitialContext ic = new InitialContext();
           _cdiManager = (BeanManager) ic.lookup("java:comp/BeanManager");
       } catch (Exception e) {
           throw new RuntimeException(e);
        }
    }

    return _cdiManager;
  }
}
</pre>
</div>
<p>Once you have this utility code, you can migrate your service to CDI without asking permission from the rest of the framework. Use this CandiUtil.getReference method to create your main service instance once, and all of its dependencies will be CDI-enabled. In an agile-style short release cycle, you can easily add this CandiUtil in one cycle and migrate the service itself bit-by-bit in following cycles. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/?feed=rss2&amp;p=526</wfw:commentRss>
		</item>
		<item>
		<title>Finishing up the CDI TCK</title>
		<link>http://blog.caucho.com/?p=524</link>
		<comments>http://blog.caucho.com/?p=524#comments</comments>
		<pubDate>Wed, 23 Jun 2010 15:54:06 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=524</guid>
		<description><![CDATA[ We&#8217;re cleaning up the Resin 4.0.8 release this week, passing our own regression tests after finishing up the CDI TCK. Although there are still 9 failures, those all appear to be problems with the TCK itself; as we work on finishing all of the JavaEE WebProfile TCK, we&#8217;ll be cleaning those up.
Passing the CDI [...]]]></description>
			<content:encoded><![CDATA[<!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div style='float:left'><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://blog.caucho.com/?p=524&amp;t=Finishing+up+the+CDI+TCK&amp;s=icon' height='16' width='16' frameborder='0' scrolling='no'></iframe></td></table></div><p>We&#8217;re cleaning up the Resin 4.0.8 release this week, passing our own regression tests after finishing up the CDI TCK. Although there are still 9 failures, those all appear to be problems with the TCK itself; as we work on finishing all of the JavaEE WebProfile TCK, we&#8217;ll be cleaning those up.</p>
<p>Passing the CDI TCK has given us a chance to plug holes in our own test suite, primarily validation of invalid application classes, but also several important lifecycle issues related to interceptors, alternatives, specializing and producers.</p>
<p>It&#8217;s also given a chance to refactor the CanDI implementation a bit, organizing it to make it more maintainable, and improving performance in a number of places.</p>
<p>We&#8217;ve still got a ways to go for the full JavaEE 6 WebProfile. The next release will be primarily passing the JTA TCK, and after that finishing up EJBs.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/?feed=rss2&amp;p=524</wfw:commentRss>
		</item>
		<item>
		<title>CanDI for database integration</title>
		<link>http://blog.caucho.com/?p=518</link>
		<comments>http://blog.caucho.com/?p=518#comments</comments>
		<pubDate>Mon, 21 Jun 2010 17:04:20 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=518</guid>
		<description><![CDATA[ In the large projects that most of us work with, it&#8217;s not feasible to rewrite the entire project around a new technology like CDI, even though a redesigned project around CDI would be a better crafted solution. But what you can do is add CDI incrementally and improve your project&#8217;s quality piece by piece [...]]]></description>
			<content:encoded><![CDATA[<!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div style='float:left'><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://blog.caucho.com/?p=518&amp;t=CanDI+for+database+integration&amp;s=icon' height='16' width='16' frameborder='0' scrolling='no'></iframe></td></table></div><p>In the large projects that most of us work with, it&#8217;s not feasible to rewrite the entire project around a new technology like CDI, even though a redesigned project around CDI would be a better crafted solution. But what you can do is add CDI incrementally and improve your project&#8217;s quality piece by piece as time goes on. For example, in an agile-style short release cycle, you&#8217;d want to break up the CDI migration task into something small enough to fit in your 2-3 week cycle.</p>
<p>If you&#8217;re using JDBC directly, the quickest benefit for CDI is replacing your current DataSource injection (or JNDI) with CDI, since Resin&#8217;s database configuration integrates with the CDI injection.<br />
<span id="more-518"></span><br />
First, you need to decide on the qualifiers for the database, a tiny set of adjectives describing each DataSource that you use by its functionality. If you have only one DataSource, you can use the builtin @Default qualifier. If you have two or more, you&#8217;ll create your own qualifiers. For example, you might have a @Login database separate from your @Account database. When you inject them, it&#8217;ll look like:</p>
<div class="codesnip-container" >import javax.inject.Inject;<br />
import javax.sql.DataSource;</p>
<p>public class MyServlet extends GenericServlet {<br />
  @Inject @Account DataSource _accountDataSource;<br />
  &#8230;<br />
}</p></div>
<p>The @Account qualifier is simple boilerplate code, which looks like the following:</p>
<div class="codesnip-container" >package com.mycom.mypkg;</p>
<p>import static java.lang.annotation.ElementType.*;<br />
import static java.lang.annotation.RetentionPolicy.*;<br />
import java.lang.annotation.Retention;<br />
import java.lang.annotation.Target;<br />
import javax.inject.Qualifier;</p>
<p>@Target({TYPE,FIELD,METHOD,PARAMETER})<br />
@Retention(RUNTIME)<br />
@Qualifier<br />
public @interface Account {<br />
}</p></div>
<p>We&#8217;re almost done. The only thing left is to modify the &lt;database> configuration in the resin-web.xml to attach the @Account qualifier to the &lt;database>.</p>
<div class="codesnip-container" >&lt;web-app xmlns=&#8221;http://caucho.com/ns/resin&#8221;<br />
                    xmlns:mypkg=&#8221;urn:java:com.mycom.mypkg&#8221;></p>
<p>  &lt;database jndi-name=&#8221;jdbc/account&#8221;><br />
    &lt;mypkg:Account/><br />
    &lt;driver type=&#8221;com.mysql.jdbc.Driver&#8221;><br />
      &lt;url>jdbc:mysql://localhost:3306/account&lt;/url><br />
      &lt;user>myuser&lt;/user><br />
      &lt;password>mypassword&lt;/password><br />
    &lt;/driver><br />
  &lt;/database></p>
<p>&lt;/web-app></p></div>
<p>The &lt;mypkg:Account/> adds the @Account qualifier to the Resin &lt;database> configuration, making it available for the CanDI injection in your code.</p>
<p>So with a simple change to your code and configuration, your DataSource injection is now type-safe, validated at application startup time by Resin, and self-documenting the source of the injection at the injection point with @Inject @Account DataSource.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/?feed=rss2&amp;p=518</wfw:commentRss>
		</item>
	</channel>
</rss>
