<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>K3andme &#187; java</title>
	<atom:link href="http://k3andme.wordpress.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://k3andme.wordpress.com</link>
	<description>Java, Maven, NetBeans et al</description>
	<lastBuildDate>Wed, 26 Nov 2008 21:21:41 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='k3andme.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/05a444d01cf598e80ff5465f9f87d4b0?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>K3andme &#187; java</title>
		<link>http://k3andme.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://k3andme.wordpress.com/osd.xml" title="K3andme" />
		<item>
		<title>Converting Ant to Maven in NetBeans</title>
		<link>http://k3andme.wordpress.com/2008/10/30/converting-ant-to-maven-in-netbeans/</link>
		<comments>http://k3andme.wordpress.com/2008/10/30/converting-ant-to-maven-in-netbeans/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 19:05:02 +0000</pubDate>
		<dc:creator>k3andme</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://k3andme.wordpress.com/?p=12</guid>
		<description><![CDATA[After a good couple of days spent converting ant projects over to maven, here is what I consider the easiest method. This is using NetBeans 6.5rc1 but probably works in 6.1.
Here are the steps for converting an ant project to a maven project in NetBeans.
This presumes your ~/.m2/settings.xml is already set up (not shown here [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=k3andme.wordpress.com&blog=5273037&post=12&subd=k3andme&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>After a good couple of days spent converting <a href="http://ant.apache.org/" target="_blank">ant</a> projects over to <a href="http://maven.apache.org/" target="_blank">maven</a>, here is what I consider the easiest method. This is using <a href="http://www.netbeans.org/">NetBeans</a> 6.5rc1 but probably works in 6.1.</p>
<p>Here are the steps for converting an ant project to a <a href="http://maven.apache.org/">maven</a> project in <a href="http://www.netbeans.org/">NetBeans</a>.<br />
This presumes your ~/.m2/settings.xml is already set up (not shown here for security purposes) and you have installed the <a href="http://www.netbeans.org/">Netbeans</a> <a href="http://maven.apache.org/">maven2</a> plugin:</p>
<p>1. Open ant project<br />
2. Create new maven project using the &#8220;<a href="http://maven.apache.org/">Maven</a> Quickstart Archetype&#8221;<br />
3. Properties -&gt; Sources -&gt; Change to 1.6<br />
4. pom.xml -&gt; Add distribution management</p>
<pre>&lt;distributionManagement&gt;
  &lt;repository&gt;
    &lt;id&gt;nexus&lt;/id&gt;
    &lt;name&gt;Internal Releases&lt;/name&gt;
    &lt;url&gt;<em>YourInternalReleaseURL</em>&lt;/url&gt;
  &lt;/repository&gt;
&lt;/distributionManagement&gt;</pre>
<p>5. Files tab -&gt; src/main -&gt; add folder &#8220;resources&#8221;. This will create an &#8220;Other Sources/resources&#8221; entry in the project view<br />
6. Delete existing source and test package stubs<br />
7. Copy java sources and test sources across from ant project<br />
8. Move all config xml files (such as applicationContext.xml) over to &#8220;Other Sources/resources&#8221;<br />
9. If you have any <a href="http://www.hibernate.org/">hibernate</a> .hbm.xml files, create a folder structure under &#8220;Other Sources/resources&#8221; identical to the package structure, and copy the files to there<br />
10. Resolve dependencies. The easiest way to do this is go through red-underlined classes, copy the missing required classname, right-click the libraries node and hit &#8220;Find Dependency&#8221;<br />
11. If a dependency is purely for a test class, add &#8220;&lt;scope&gt;test&lt;/scope&gt;&#8221; to reduce the resulting jar filesize<br />
12. mvn install or deploy</p>
<p>If the <a href="http://ant.apache.org/">ant</a> project exposes a WebService:<br />
1. Add the following plugin to the pom.xml:</p>
<pre>&lt;plugin&gt;
  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
  &lt;artifactId&gt;jaxws-maven-plugin&lt;/artifactId&gt;
  &lt;executions&gt;
    &lt;execution&gt;
      &lt;goals&gt;
        &lt;goal&gt;wsimport&lt;/goal&gt;
      &lt;/goals&gt;
      &lt;configuration&gt;
        &lt;wsdlUrls&gt;
          &lt;wsdlUrl&gt;<em>yourWSDLExposedUrl</em>&lt;/wsdlUrl&gt;
        &lt;/wsdlUrls&gt;
        &lt;packageName&gt;<em>yourWSClientPackageName</em>&lt;/packageName&gt;
        &lt;sourceDestDir&gt;${basedir}/src/main/java&lt;/sourceDestDir&gt;
      &lt;/configuration&gt;
    &lt;/execution&gt;
  &lt;/executions&gt;
&lt;/plugin&gt;</pre>
<p>2. Change the wsdl location and packageName as necessary. Without the sourceDestDir, the generated sources live under target/ and code completion won&#8217;t work. Setting the package name to the same package as the ws-client solves this. Compilation works either way.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/k3andme.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/k3andme.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/k3andme.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/k3andme.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/k3andme.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/k3andme.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/k3andme.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/k3andme.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/k3andme.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/k3andme.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=k3andme.wordpress.com&blog=5273037&post=12&subd=k3andme&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://k3andme.wordpress.com/2008/10/30/converting-ant-to-maven-in-netbeans/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c0543dd2391cafdecd5c8b5a2d63b051?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">k3andme</media:title>
		</media:content>
	</item>
		<item>
		<title>ehcache and spring</title>
		<link>http://k3andme.wordpress.com/2008/10/23/ehcache-and-spring/</link>
		<comments>http://k3andme.wordpress.com/2008/10/23/ehcache-and-spring/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 16:28:24 +0000</pubDate>
		<dc:creator>k3andme</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ehcache]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://k3andme.wordpress.com/?p=7</guid>
		<description><![CDATA[As used by Hibernate, ehcache is a great little caching implementation which ought to be part of every Java coders arsenal. Although its complexities may seem overwhelming, it&#8217;s very easy to use as a simple caching solution.
In my situation, I needed to prevent db hits when validating codes (ie seeing if they already exist in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=k3andme.wordpress.com&blog=5273037&post=7&subd=k3andme&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>As used by <a href="http://www.hibernate.org/" target="_blank">Hibernate</a>, <a href="http://ehcache.sourceforge.net/" target="_blank">ehcache</a> is a great little caching implementation which ought to be part of every Java coders arsenal. Although its complexities may seem overwhelming, it&#8217;s very easy to use as a simple caching solution.</p>
<p>In my situation, I needed to prevent db hits when validating codes (ie seeing if they already exist in the db). This is how easy it is to set up.</p>
<p><strong>applicationContext.xml</strong>:</p>
<pre>&lt;bean id="myDao" class="myDaoImpl" init-method="setupCache"&gt;
  &lt;property name="cacheManager" ref="cacheManager"&gt;
&lt;/bean&gt;</pre>
<pre>&lt;bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"&gt;
  &lt;property name="configLocation" value="classpath:ehcache.xml" /&gt;
&lt;/bean&gt;</pre>
<p><strong>ehcache.xml</strong>:</p>
<pre>&lt;ehcache&gt;
  &lt;diskStore path="java.io.tmpdir"/&gt;
  &lt;cache name="myCacheName"
    maxElementsInMemory="1000"
    eternal="true"
    overflowToDisk="false"/&gt;
  &lt;defaultCache
    maxElementsInMemory="300"
    maxElementsOnDisk="1000"
    eternal="false"
    timeToIdleSeconds="120"
    timeToLiveSeconds="120"
    overflowToDisk="true"/&gt;
&lt;/ehcache&gt;</pre>
<p><strong>myDaoImpl.java</strong>:</p>
<pre>import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;

public class {
  private CacheManager cacheManager;
  private Cache myCache = null;

  public void setCacheManager(CacheManager cacheManager) {
    this.cacheManager = cacheManager;
  }

  private void setupCache() {
    String cacheName = "myCacheName";
    logger.debug("Fetching cache [" + cacheName + "]");
    myCache = cacheManager.getCache(cacheName);
  }
}</pre>
<p><strong>ehcache.xml</strong> needs to be put alongside <strong>applicationContext.xml</strong> (especially in the case of jar packaging). If you&#8217;re packaging a war, you can place it anywhere on the classpath and don&#8217;t need to specify the configLocation (it&#8217;s the default config name).</p>
<p>To use the cache, do something like this:</p>
<pre>Element cachedObject = myCache.get(key);
if (cachedObject != null) {
  return cachedObject;
} else {
  <em>fetch object from db
</em>  // add to cache<em>
</em>  myCache.put(new Element(key, object))
  return object;
}

And that's it!</pre>
<p>Now you&#8217;ll only hit the db when needed. Of course, it&#8217;s worth <a href="http://ehcache.sourceforge.net/" target="_blank">reading the reference material</a> to see the many ways you can configure the cache. My example is purely for a 1000 object permanent memory cache, but TTL and overflow-to-disk (for example) is just as easy to set up.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/k3andme.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/k3andme.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/k3andme.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/k3andme.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/k3andme.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/k3andme.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/k3andme.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/k3andme.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/k3andme.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/k3andme.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=k3andme.wordpress.com&blog=5273037&post=7&subd=k3andme&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://k3andme.wordpress.com/2008/10/23/ehcache-and-spring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c0543dd2391cafdecd5c8b5a2d63b051?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">k3andme</media:title>
		</media:content>
	</item>
	</channel>
</rss>