<?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>REVERT TO CONSOLE &#187; Priyatam</title>
	<atom:link href="http://www.reverttoconsole.com/blog/author/priyatam/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.reverttoconsole.com</link>
	<description>for f in *;do echo &#124; sed &#039;i\rtc&#039; &#62;&#62; $f;done; java programming et al</description>
	<lastBuildDate>Thu, 25 Aug 2011 15:02:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Understanding OpenJPA InvalidStateException: Detected reentrant flush</title>
		<link>http://www.reverttoconsole.com/blog/hibernate-jpa/understanding-openjpa-invalidstateexception-detected-reentrant-flush/</link>
		<comments>http://www.reverttoconsole.com/blog/hibernate-jpa/understanding-openjpa-invalidstateexception-detected-reentrant-flush/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 18:37:22 +0000</pubDate>
		<dc:creator>Priyatam</dc:creator>
				<category><![CDATA[Hibernate/JPA]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=995</guid>
		<description><![CDATA[Ran into this issue today: &#60;openjpa-1.2.2-r422266:898935 fatal user error&#62; org.apache.openjpa.persistence.InvalidStateException: Detected reentrant flush. Make sure your flush-time instance callback methods or event listeners do not invoke any operations that require the in-progress flush to complete. at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1923) at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1698) at org.apache.openjpa.kernel.QueryImpl.isInMemory(QueryImpl.java:956) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:838) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:779) at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:525) This is a tricky exception since the verbose [...]]]></description>
			<content:encoded><![CDATA[<p>Ran into this issue today:</p>
<pre>
&lt;openjpa-1.2.2-r422266:898935 fatal user error&gt; org.apache.openjpa.persistence.InvalidStateException: Detected reentrant flush.  Make sure your flush-time instance callback methods or event listeners do not invoke any operations that require the in-progress flush to complete.
	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1923)
	at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1698)
	at org.apache.openjpa.kernel.QueryImpl.isInMemory(QueryImpl.java:956)
	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:838)
	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:779)
	at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:525)
</pre>
<p>This is a tricky exception since the verbose description does not clarify the intent.</p>
<p><strong>The problem:</strong><br />
I had to write my own Auditing since we weren&#8217;t using Hibernate (and so no <a href="http://www.jboss.org/envers">Envers</a>) but openjpa 1.2.2. Don&#8217;t ask me why. It&#8217;s a big financial company and they like Websphere 7 (which &#8220;ships&#8221; openjpa 1.2). </p>
<p>A sample &#8220;Profile&#8221; entity</p>
<pre>
@Entity
@EntityListeners({ProfileAuditListener.class})
public class Profile implements Serializable {
 ...
}
</pre>
<p>The standard JPA Entity Listener:</p>
<pre>
@Named
public class ProfileAuditListener implements ApplicationContextAware {
        private ProfileAuditDao auditDao;

	@PostUpdate
	@Transactional
	public void postUpdate(Profile newProfile) {
	    ProfileAudit audit = new ProfileAudit();
	    ...
    	    ...
   	    Profile oldProfile = profileDao.read(newProfile.getEmail());
            // InvalidStateException thrown above
            ...
            // Compare field by field for editable fields
	    ...	

	    auditDao.audit(audit);
	}
}
</pre>
<p>A simple Dao</p>
<pre>
@Repository(&quot;profileDao&quot;)
public class JPAProfileDao implements ProfileDao {

	@Transactional(readOnly = true)
	public Profile read(String email) {
		List&lt;Profile&gt; profiles = em.createNamedQuery(&quot;findByEmail&quot;).setParameter(&quot;email&quot;, email);
		if (profiles.size() != 0) {
			return profiles.get(0);
		}
		return null;
	}
}
</pre>
<p>As you can see, nothing fancy here. An Audit interceptor trying to see the difference in &#8216;Profile&#8217; properties just after updated the entity in db. However an exception is thrown where I execute a read-only Transactional query.</p>
<p><strong>Explanation:</strong><br />
The exception indicates that the event listener might be executing a flush accidentally from another operation and OpenJPA doesnt allow a flush to occur during a flush. Wait, a <em>flush</em>? But I&#8217;m not <em>flushing </em>anywhere, in fact &#8212; I think it&#8217;s all <em>default </em>flushing. </p>
<p>That&#8217;s the catch. The default querying in openjpa is FlushModeType.AUTO and that causes a flush to occur even if it&#8217;s a @Transactional(readOnly=true)</p>
<p><strong>Solution:</strong><br />
set the flush mode to FlushModeType.COMMIT on that particular query.</p>
<p>You can also set a <a href="http://openjpa.apache.org/builds/1.2.2/apache-openjpa-1.2.2/docs/manual/manual.html#ref_guide_dbsetup_retain">system wide property</a> like setting false flushBeforeQueries = true in persistence.xml but I wouldn&#8217;t recommend that unless you want this behavior explicitly. For instance, my unit tests needed the auto flush to work since I persist and read in the same transaction (Spring Transactional tests).</p>
<p>In general, your use case might be different from mine but the underlying concept is same. Look for the accidental flushes from openjpa. If in doubt, always tune up the DEBUG logging.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fhibernate-jpa%2Funderstanding-openjpa-invalidstateexception-detected-reentrant-flush%2F&amp;title=Understanding+OpenJPA+InvalidStateException%3A+Detected+reentrant+flush" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fhibernate-jpa%2Funderstanding-openjpa-invalidstateexception-detected-reentrant-flush%2F&amp;title=Understanding+OpenJPA+InvalidStateException%3A+Detected+reentrant+flush" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fhibernate-jpa%2Funderstanding-openjpa-invalidstateexception-detected-reentrant-flush%2F&amp;title=Understanding+OpenJPA+InvalidStateException%3A+Detected+reentrant+flush" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fhibernate-jpa%2Funderstanding-openjpa-invalidstateexception-detected-reentrant-flush%2F&amp;title=Understanding+OpenJPA+InvalidStateException%3A+Detected+reentrant+flush" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fhibernate-jpa%2Funderstanding-openjpa-invalidstateexception-detected-reentrant-flush%2F&amp;title=Understanding+OpenJPA+InvalidStateException%3A+Detected+reentrant+flush', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fhibernate-jpa%2Funderstanding-openjpa-invalidstateexception-detected-reentrant-flush%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fhibernate-jpa%2Funderstanding-openjpa-invalidstateexception-detected-reentrant-flush%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fhibernate-jpa%2Funderstanding-openjpa-invalidstateexception-detected-reentrant-flush%2F&amp;title=Understanding+OpenJPA+InvalidStateException%3A+Detected+reentrant+flush" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fhibernate-jpa%2Funderstanding-openjpa-invalidstateexception-detected-reentrant-flush%2F&amp;title=Understanding+OpenJPA+InvalidStateException%3A+Detected+reentrant+flush" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/hibernate-jpa/understanding-openjpa-invalidstateexception-detected-reentrant-flush/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mock Unit Testing Services and Daos with Mockito and Spring 3</title>
		<link>http://www.reverttoconsole.com/blog/spring/mock-unit-testing-services-and-daos-with-mockito-and-spring-3/</link>
		<comments>http://www.reverttoconsole.com/blog/spring/mock-unit-testing-services-and-daos-with-mockito-and-spring-3/#comments</comments>
		<pubDate>Mon, 09 May 2011 14:46:02 +0000</pubDate>
		<dc:creator>Priyatam</dc:creator>
				<category><![CDATA[Spring]]></category>
		<category><![CDATA[UnitTest]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=984</guid>
		<description><![CDATA[If you haven&#8217;t been mocking yet, check this out. There are other tools in Groovy using DSLs but if you want to stick to Java, Mockito is by far the best BDD-style mock unit testing tool. Traditional examples provide a List mocking example or foo/bar example which I find it mostly annoying since it doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>If you haven&#8217;t been <em>mocking </em>yet, check <a href="http://www.mockito.org/">this </a>out. There are other tools in Groovy using DSLs but if you want to stick to Java, Mockito is by far the best BDD-style mock unit testing tool.  </p>
<p>Traditional examples provide a List mocking example or foo/bar example which I find it mostly annoying since it doesn&#8217;t teach you how to solve real problems. And the documentation is verbose and crams with unnecessary features confusing us further. In this tutorial, I&#8217;ll dive straight into a relevant example of mock testing Daos in Service layer. I&#8217;m not a big fan of Daos anymore (after the advent of JPA), however for the purposes of this tutorial, it&#8217;ll be easier to explain.</p>
<p>Consider a Profile entity (like facebook user profile) with daos/services: ProfileDao/JPAProfileDao, ProfileService/ProfileServiceImpl. To complicate things further, say you are using DTOs since it&#8217;s a client server app with a GWT front end. You might need a simple mapper class. Let&#8217;s call it ProfileMapper/ProfileMapperImpl. </p>
<pre>
@Service("profileService")
public class ProfileServiceImpl implements ProfileService {
	private final ProfileDao profileDao;
	private final ProfileMapper profileMapper;

	@Inject
	public ProfileServiceImpl(final ProfileDao profileDao, final ProfileMapper profileMapper) {
		this.profileDao = profileDao;
		this.profileMapper = profileMapper;
	}

	@Transactional
	public void create(ProfileDto profile) throws DuplicateProfileException {
		if (profile == null) {
			throw new IllegalArgumentException("profile cannot be null.");
		}

		Profile profile = profileMapper.toEntity(profile);
		// set default state as active
		profile .setIsActive(true);

		try {
			profileDao.save(profile);
		}
		catch (DuplicateKeyException e) {
			logger.warn("Unable to save profile with userId: " + profile.getUserId() + " already exists.");
			throw new DuplicateProfileException();
		}
		logger.debug("Profile saved successfully.");
	}

	@Transactional(readOnly = true)
	public ProfileDto read(String userId) throws InvalidProfileException {
		validateProfileInfo(userId);

		ProfileDto profileDto = null;
		Profile profile = profileDao.read(userId);
		if (profile != null) {
			profileDto = profileMapper.fromEntity(profile);
			logger.debug("Profile retrieved successfully.");
		}
		else {
			logger.debug("...");
		}
		return profileDto;
	}

	...
}
</pre>
<p>Now, in order to test ProfileService, you need to mock out ProfileMapper and ProfileDao, right? Let&#8217;s see how we do this in a simple JUnit 4.4+ test.</p>
<pre>
import static org.mockito.Mockito.*;

@RunWith(MockitoJUnitRunner.class)
public class ProfileServiceTest {

	@Mock
	ProfileDao profileDao;

	@Mock
	ProfileMapper profileMapper;

	// Can't use @InjectMocks because Mockito doesn't support constructor injection
	// As a workaround use @Before below to initialize service with stubs
	ProfileService profileService;

	@Before
	public void init() {
		profileService = new ProfileServiceImpl(profileDao, profileMapper);
	}

	@Test
	public void testRead() throws InvalidProfileException {
		// Simulate InvalidProfileException
		try {
			profileService.read("");
			fail(); // should never execute
		}
		catch (InvalidProfileException e) {
			e.getMessage(); // expected
		}

		// Given
		Profile profile = TestData.createTestProfile("userid"); // test utility to create a test Profile
		when(profileDao.read("userid")).thenReturn(profile);
		when(profileMapper.fromEntity(profile )).thenReturn(TestData.createTestProfileDto("userid"));

		// When
		ProfileDto dto = profileService.read("userid");

		// Then
		assertEquals(dto.getUserId(), "userid");
	}
}
</pre>
<p>Explanation:<br />
1) Wrapping your test with @RunWith(MockitoJUnitRunner.class) helps create the mock initialization through annotation scanning (@Mock, @InjectMocks)<br />
2) Add @Mock annotations for the components to mock. In this case profileDao, profileMapper<br />
3) As of 1.8.5, Mockito doesn&#8217;t provide @InjectMock with construction injection. @Before test initializer is a workaround to inject ProfileService with mocks. Note that this will not be required if ProfileService has setter/getter injection of dependencies. However, I prefer JSR330 construction injection which is a <a href="http://martinfowler.com/articles/injection.html#ConstructorVersusSetterInjection">best practice </a>.<br />
4) The actual @Test class with mockito stubs. Let&#8217;s dig deep into this.</p>
<p>As a template, it&#8217;s a good practice to view tests like a BDD style test. </p>
<pre>
// Given 

// When

// Then
</pre>
<p>The above template forces you to think on the explicit conditions during which we run our unit test.</p>
<p>Next, we need to figure out a way to stub our mock component&#8217;s methods,</p>
<pre>
when(operation).thenReturn(object)
</pre>
<p>In our example we want to mock profileDao.read(userId). So that translates to</p>
<pre>
when(profileDao.read("userid")).thenReturn(profile);
</pre>
<p>Note that we&#8217;re letting the mocked dao return a profile object that we just created in the previous step. This will be 50% of most of your mocking use cases.</p>
<p>The next common used use case is to simulate exceptions from the mocked classes. Consider a test for create(&#8230;) that simulates the DuplicateProfileException.          </p>
<pre>
@Test
	public void testCreateDuplicate() {
		// Given
		ProfileDto dto = TestData.createTestProfileDto("userid");
		Profile profile = TestData.createTestProfile("userid");
		when(profileMapper.toEntity(dto)).thenReturn(profile);
		doThrow(new DuplicateKeyException("duplicate profile")).when(profileDao).save(profile);

		// When
		try {
			profileService.create(dto);
			assertEquals(1, 2); // should never execute
		}
		// Then
		catch (DuplicateProfileException e) {
			e.getMessage();
		}
	}
</pre>
<p>Notice the line</p>
<pre>
doThrow(new DuplicateKeyException("duplicate profile")).when(profileDao).save(profile);
</pre>
<p>Quite simple, isn&#8217;t it? </p>
<p>If you&#8217;ve read so far, you can succuessfully write mock unit tests for 80% of your use cases. There are other advanced features like finding <a href="http://www.mockito.org/">redundant invocations</a>, spying on objects to simulate partial mocking, most of which I don&#8217;t see implementing for majority of my use cases. </p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Fmock-unit-testing-services-and-daos-with-mockito-and-spring-3%2F&amp;title=Mock+Unit+Testing+Services+and+Daos+with+Mockito+and+Spring+3" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Fmock-unit-testing-services-and-daos-with-mockito-and-spring-3%2F&amp;title=Mock+Unit+Testing+Services+and+Daos+with+Mockito+and+Spring+3" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Fmock-unit-testing-services-and-daos-with-mockito-and-spring-3%2F&amp;title=Mock+Unit+Testing+Services+and+Daos+with+Mockito+and+Spring+3" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Fmock-unit-testing-services-and-daos-with-mockito-and-spring-3%2F&amp;title=Mock+Unit+Testing+Services+and+Daos+with+Mockito+and+Spring+3" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Fmock-unit-testing-services-and-daos-with-mockito-and-spring-3%2F&amp;title=Mock+Unit+Testing+Services+and+Daos+with+Mockito+and+Spring+3', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Fmock-unit-testing-services-and-daos-with-mockito-and-spring-3%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Fmock-unit-testing-services-and-daos-with-mockito-and-spring-3%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Fmock-unit-testing-services-and-daos-with-mockito-and-spring-3%2F&amp;title=Mock+Unit+Testing+Services+and+Daos+with+Mockito+and+Spring+3" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Fmock-unit-testing-services-and-daos-with-mockito-and-spring-3%2F&amp;title=Mock+Unit+Testing+Services+and+Daos+with+Mockito+and+Spring+3" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/spring/mock-unit-testing-services-and-daos-with-mockito-and-spring-3/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Database Surrogate keys Vs Natural keys</title>
		<link>http://www.reverttoconsole.com/blog/database/database-surrogate-keys-vs-natural-keys/</link>
		<comments>http://www.reverttoconsole.com/blog/database/database-surrogate-keys-vs-natural-keys/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 18:06:07 +0000</pubDate>
		<dc:creator>Priyatam</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=993</guid>
		<description><![CDATA[Ran into this issue at my client recently and it was hard to convince the db admin why surrogate keys was an advantage for a developer working in an ORM solution Natural key - business requirements changes, then you have to change the natural key - not easy to index an alphanumeric or String value [...]]]></description>
			<content:encoded><![CDATA[<p>Ran into this issue at my client recently and it was hard to convince the db admin why surrogate keys was an advantage for a developer working in an ORM solution</p>
<p><strong>Natural key</strong><br />
- business requirements changes, then you have to change the natural key<br />
- not easy to index an alphanumeric or String value<br />
- can&#8217;t expose the natural key to end users who can then guess the business key and use for querying undesireable data<br />
- you can&#8217;t rename the type without changing everything<br />
- If using strings, joins are a bit slower as compared to the int data-type joins, storage is more as well.  Since storage is more, less data-values get stored per index page.  Also, reading strings is a two step process in some RDBMS: one to get the actual length of the string and second to actually perform the read operation to get the value.<br />
- Locking contentions can arise if using application driven generation mechanism for the key.<br />
- Can’t enter a record until value is known since the value has some meaning. </p>
<p><strong>Surrogate key</strong><br />
- A surrogate key is immune to changes in business. In addition, the key depends on only one field, so it’s compact. The auto-incrementing field provides a unique, stable, and compact primary key.<br />
- Business Logic is not in the keys.<br />
- Small 4-byte key (the surrogate key will most likely be an integer and SQL Server for example requires only 4 bytes to store it, if a bigint, then 8 bytes).<br />
- Joins are very fast.<br />
- No locking contentions because of unique constraint (this refers to the waits that get developed when two sessions are trying to insert the same unique business key) as the surrogates get generated by the DB and are cached. Very scalable. </p>
<p>Not to mention, for surrogate keys, a Java developer could assume and code several reusable strategies:<br />
- Have a common BaseIdEntity with an @Id attribute with a common generation strategy or named sequence generators<br />
- Have Base generic services or daos (FooServiceImpl extends BaseServiceImpl<Foo>)<br />
- Generic finder methods with named queries<br />
- And many other referential lookups that can be streamlined once a common id is used</p>
<p>References:<br />
<a href="http://www.techrepublic.com/article/the-great-primary-key-debate/1045050">The great primary key debate</a></p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fdatabase%2Fdatabase-surrogate-keys-vs-natural-keys%2F&amp;title=Database+Surrogate+keys+Vs+Natural+keys" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fdatabase%2Fdatabase-surrogate-keys-vs-natural-keys%2F&amp;title=Database+Surrogate+keys+Vs+Natural+keys" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fdatabase%2Fdatabase-surrogate-keys-vs-natural-keys%2F&amp;title=Database+Surrogate+keys+Vs+Natural+keys" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fdatabase%2Fdatabase-surrogate-keys-vs-natural-keys%2F&amp;title=Database+Surrogate+keys+Vs+Natural+keys" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fdatabase%2Fdatabase-surrogate-keys-vs-natural-keys%2F&amp;title=Database+Surrogate+keys+Vs+Natural+keys', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fdatabase%2Fdatabase-surrogate-keys-vs-natural-keys%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fdatabase%2Fdatabase-surrogate-keys-vs-natural-keys%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fdatabase%2Fdatabase-surrogate-keys-vs-natural-keys%2F&amp;title=Database+Surrogate+keys+Vs+Natural+keys" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fdatabase%2Fdatabase-surrogate-keys-vs-natural-keys%2F&amp;title=Database+Surrogate+keys+Vs+Natural+keys" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/database/database-surrogate-keys-vs-natural-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding Spring Transaction Management</title>
		<link>http://www.reverttoconsole.com/blog/spring/understanding-spring-transaction-management/</link>
		<comments>http://www.reverttoconsole.com/blog/spring/understanding-spring-transaction-management/#comments</comments>
		<pubDate>Sun, 06 Mar 2011 16:17:24 +0000</pubDate>
		<dc:creator>Priyatam</dc:creator>
				<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=990</guid>
		<description><![CDATA[This is a little wiki file I had for a long time while understanding how spring transactions worked. Time to put it in a blog. (Note: data is unprocessed) - Two types of transactions: Global and Local Transactions - PlatformTransactionManager is main interface in Spring - PROPAGATION_REQUIRED, PROPAGATION_SUPPORTS, PROPAGATION_MANDATORY, PROPAGATION_REQUIRES_NEW, PROPAGATION_NOT_SUPPORTED, PROPAGATION_NEVER, PROPAGATION_NESTED - ISOLATION_DEFAULT, [...]]]></description>
			<content:encoded><![CDATA[<p>This is a little wiki file I had for a long time while understanding how spring transactions worked. Time to put it in a blog. (Note: data is unprocessed)</p>
<p>- Two types of transactions: Global and Local Transactions<br />
- PlatformTransactionManager is main interface in Spring<br />
- <em>PROPAGATION_REQUIRED, PROPAGATION_SUPPORTS, PROPAGATION_MANDATORY, PROPAGATION_REQUIRES_NEW, PROPAGATION_NOT_SUPPORTED, PROPAGATION_NEVER, PROPAGATION_NESTED</em><br />
- ISOLATION_DEFAULT, ISOLATION_READ_UNCOMMITTED, ISOLATION_READ_COMMITTED, ISOLATION_REPEATABLE_READ, ISOLATION_SERIALIZABLE<br />
- Spring&#8217;s Declarative Transaction management. Can customize transactional behavior using AOP. Like custom behavior in case<br />
  of transaction rollback declaritvely.<br />
- How @Transactional works. The combination of AOP with transactional metadata yields an AOP proxy that uses a TransactionInterceptor in conjunction with an appropriate PlatformTransactionManager implementation to drive transactions around method invocations</p>
<p>- <strong>Steps when a method is invoked with @Transactional</strong><br />
 &#8212; Spring AOP kicks in, create proxy of the target. If nothing is configured JDDK dynamic proxy is created, but if aspectj is configured,<br />
    aspectJ proxy is created<br />
 &#8212; TransactionInterceptor kicks in the configured TransactionAdvice<br />
 &#8212; TransactionAdvice calls the underlying PlatformTransactionManager to acquire a new db connection<br />
 &#8212; Datasource is kicked in. If a connection pool is present, a conection is returned from the pool<br />
 &#8212; Method is invoked<br />
 &#8212; If no exceptions, great<br />
 &#8212; If exceptions are returned, apply rules to determine whether transaction should be rolled back. If yes, TransactionInterceptor will roll back<br />
    transaction<br />
 &#8212; Based on exceptions, PlatformTransactionManager either commits or rollsback transaction<br />
 &#8212; Release connection JDBC after transaction<br />
 &#8212; Return conenction to pool<br />
 &#8212; Return the method call</p>
<p>- Annotate @Transactional on classes and not interfaces because Java annotations are not inherited from interfaces means that if you are using class-based proxies or the weaving-based aspect then the transaction settings are not recognized by the proxying and weaving infrastructure, and the object will not be wrapped in a transactional proxy.</p>
<p>- When using proxies, you should apply the @Transactional annotation only to methods with public visibility.</p>
<p>- Spring AOP uses either JDK dynamic proxies or CGLIB to create the proxy for a given target object. If the target object to be proxied implements at least one interface then a JDK dynamic proxy will be used. If the target object does not implement any interfaces then a CGLIB proxy will be created.</p>
<p>- Using &#8216;proxy-target-class=&#8221;true&#8221;&#8216; on <tx:annotation-driven/>, <aop:aspectj-autoproxy/> or <aop:config/> elements will force the use of CGLIB proxies for all three of them.</p>
<p>- multiple transaction managers can be used and referred as @Transactional (&#8220;account&#8221;)</p>
<pre>
&lt;bean id=&quot;transactionManager1&quot; class=&quot;org.springframework.jdbc.DataSourceTransactionManager&quot;&gt;
    ...
   &lt;qualifier value=&quot;account&quot;/&gt;
&lt;/bean&gt;
</pre>
<p>- Programmatic transaction can be done by TransactionTemplate (callBack approach) or PlatformTransactionManager directly</p>
<p>JPA<br />
&#8212;</p>
<pre>
&lt;!-- Activates @PersistentContext --&gt;
&lt;bean class=&quot;org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor&quot; /&gt;
</pre>
<p>References:<br />
<a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/transaction.html">Spring Transaction Propogation</a><br />
<a href="http://stackoverflow.com/questions/tagged/transactions">Stack Overflow &#8220;transactions&#8221;</a><br />
<a href="http://www.ibm.com/developerworks/java/library/j-ts1/index.html">Transactional Pitfalls	</a>	</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Funderstanding-spring-transaction-management%2F&amp;title=Understanding+Spring+Transaction+Management" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Funderstanding-spring-transaction-management%2F&amp;title=Understanding+Spring+Transaction+Management" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Funderstanding-spring-transaction-management%2F&amp;title=Understanding+Spring+Transaction+Management" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Funderstanding-spring-transaction-management%2F&amp;title=Understanding+Spring+Transaction+Management" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Funderstanding-spring-transaction-management%2F&amp;title=Understanding+Spring+Transaction+Management', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Funderstanding-spring-transaction-management%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Funderstanding-spring-transaction-management%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Funderstanding-spring-transaction-management%2F&amp;title=Understanding+Spring+Transaction+Management" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fspring%2Funderstanding-spring-transaction-management%2F&amp;title=Understanding+Spring+Transaction+Management" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/spring/understanding-spring-transaction-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven settings.xml for corporate proxy with custom user-Agent</title>
		<link>http://www.reverttoconsole.com/blog/maven/maven-settings-xml-for-corporate-proxy-with-custom-user-agent/</link>
		<comments>http://www.reverttoconsole.com/blog/maven/maven-settings-xml-for-corporate-proxy-with-custom-user-agent/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 20:06:05 +0000</pubDate>
		<dc:creator>Priyatam</dc:creator>
				<category><![CDATA[Maven/Ivy]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=650</guid>
		<description><![CDATA[In some corporate enviroments, it&#8217;s just not enough to add a simple proxy setting in maven settings.xml. For instance, some prozy servers reject any HTTP request that&#8217;s coming from a non IE browser. Foruntately, Maven has a way to fake a user-agent and this might be a way to circumvent your corporate server settings Of [...]]]></description>
			<content:encoded><![CDATA[<p>In some corporate enviroments, it&#8217;s just not enough to add a simple proxy setting in maven settings.xml. For instance, some prozy servers reject any HTTP request that&#8217;s coming from a non IE browser. Foruntately, Maven has a way to fake a user-agent and this might be a way to circumvent your corporate server settings Of course, make sure you ask your IT if that&#8217;s ok! More often it&#8217;s easy for them to approve rather than ask them to change their proxy policies for Maven (Maven, what is that?)</p>
<p>Here&#8217;s an example settings.xml file along with standard reposities from JBoss, Spring, Codehause, Ibiblio. I have set it to a proxy named myproxy.com along with a Firefox user-agent. Note that you need to a <server> config for each repo that you need to configure for a custom user-agent proxy.</p>
<pre>
&lt;settings xmlns=&quot;http://maven.apache.org/SETTINGS/1.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
	xsi:schemaLocation=&quot;http://maven.apache.org/SETTINGS/1.0.0

http://maven.apache.org/xsd/settings-1.0.0.xsd&quot;&gt;

	&lt;localRepository/&gt;
	&lt;interactiveMode/&gt;
	&lt;usePluginRegistry/&gt;
	&lt;pluginGroups/&gt;
	&lt;servers&gt;
		&lt;server&gt;
			&lt;id&gt;ibiblio&lt;/id&gt;
			&lt;configuration&gt;
				&lt;useCache&gt;true&lt;/useCache&gt;
				&lt;timeout&gt;6000&lt;/timeout&gt;
				&lt;httpHeaders&gt;
					&lt;property&gt;
						&lt;name&gt;User-Agent&lt;/name&gt;
						&lt;value&gt;
							Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
						&lt;/value&gt;
					&lt;/property&gt;
				&lt;/httpHeaders&gt;
			&lt;/configuration&gt;
		&lt;/server&gt;
		&lt;server&gt;
			&lt;id&gt;spring-repo&lt;/id&gt;
			&lt;configuration&gt;
				&lt;useCache&gt;true&lt;/useCache&gt;
				&lt;timeout&gt;6000&lt;/timeout&gt;
				&lt;httpHeaders&gt;
					&lt;property&gt;
						&lt;name&gt;User-Agent&lt;/name&gt;
						&lt;value&gt;
							Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
						&lt;/value&gt;
					&lt;/property&gt;
				&lt;/httpHeaders&gt;
			&lt;/configuration&gt;
		&lt;/server&gt;
		&lt;server&gt;
			&lt;id&gt;jboss-repo&lt;/id&gt;
			&lt;configuration&gt;
				&lt;useCache&gt;true&lt;/useCache&gt;
				&lt;timeout&gt;6000&lt;/timeout&gt;
				&lt;httpHeaders&gt;
					&lt;property&gt;
						&lt;name&gt;User-Agent&lt;/name&gt;
						&lt;value&gt;
							Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
						&lt;/value&gt;
					&lt;/property&gt;
				&lt;/httpHeaders&gt;
			&lt;/configuration&gt;
		&lt;/server&gt;
		&lt;server&gt;
			&lt;id&gt;atlassian-repo&lt;/id&gt;
			&lt;configuration&gt;
				&lt;useCache&gt;true&lt;/useCache&gt;
				&lt;timeout&gt;6000&lt;/timeout&gt;
				&lt;httpHeaders&gt;
					&lt;property&gt;
						&lt;name&gt;User-Agent&lt;/name&gt;
						&lt;value&gt;
							Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
						&lt;/value&gt;
					&lt;/property&gt;
				&lt;/httpHeaders&gt;
			&lt;/configuration&gt;
		&lt;/server&gt;
		&lt;server&gt;
			&lt;id&gt;codehaus-repo&lt;/id&gt;
			&lt;configuration&gt;
				&lt;useCache&gt;true&lt;/useCache&gt;
				&lt;timeout&gt;6000&lt;/timeout&gt;
				&lt;httpHeaders&gt;
					&lt;property&gt;
						&lt;name&gt;User-Agent&lt;/name&gt;
						&lt;value&gt;
							Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
						&lt;/value&gt;
					&lt;/property&gt;
				&lt;/httpHeaders&gt;
			&lt;/configuration&gt;
		&lt;/server&gt;
	&lt;/servers&gt;
	&lt;mirrors&gt;
		&lt;mirror&gt;
			&lt;id&gt;ibiblio&lt;/id&gt;
			&lt;url&gt;http://mirrors.ibiblio.org/pub/mirrors/maven2/&lt;/url&gt;
			&lt;mirrorOf&gt;external:*&lt;/mirrorOf&gt;
		&lt;/mirror&gt;
		&lt;mirror&gt;
			&lt;id&gt;spring-repo&lt;/id&gt;
			&lt;url&gt;http://ebr.springsource.com/repository/&lt;/url&gt;
			&lt;mirrorOf&gt;external:*&lt;/mirrorOf&gt;
		&lt;/mirror&gt;
		&lt;mirror&gt;
			&lt;id&gt;jboss-repo&lt;/id&gt;
			&lt;url&gt;http://repository.jboss.org/maven2/&lt;/url&gt;
			&lt;mirrorOf&gt;external:*&lt;/mirrorOf&gt;
		&lt;/mirror&gt;
		&lt;mirror&gt;
			&lt;id&gt;atlassian-repo&lt;/id&gt;
			&lt;url&gt;https://maven.atlassian.com/repository/public/&lt;/url&gt;
			&lt;mirrorOf&gt;external:*&lt;/mirrorOf&gt;
		&lt;/mirror&gt;
		&lt;mirror&gt;
			&lt;id&gt;codehaus-repo&lt;/id&gt;
			&lt;url&gt;http://repository.codehaus.org/&lt;/url&gt;
			&lt;mirrorOf&gt;external:*&lt;/mirrorOf&gt;
		&lt;/mirror&gt;
	&lt;/mirrors&gt;

	&lt;proxies&gt;
		&lt;proxy&gt;
			&lt;active&gt;true&lt;/active&gt;
			&lt;protocol&gt;http&lt;/protocol&gt;
			&lt;host&gt;yourproxy.com&lt;/host&gt;
			&lt;port&gt;8080&lt;/port&gt;
			&lt;username&gt;&lt;/username&gt;
			&lt;password&gt;&lt;/password&gt;
			&lt;nonProxyHosts&gt;&lt;/nonProxyHosts&gt;
		&lt;/proxy&gt;
		&lt;proxy&gt;
			&lt;active&gt;true&lt;/active&gt;
			&lt;protocol&gt;https&lt;/protocol&gt;
			&lt;host&gt;yourproxy.com&lt;/host&gt;
			&lt;port&gt;8080&lt;/port&gt;
			&lt;username&gt;&lt;/username&gt;
			&lt;password&gt;&lt;/password&gt;
			&lt;nonProxyHosts&gt;&lt;/nonProxyHosts&gt;
		&lt;/proxy&gt;
	&lt;/proxies&gt;
	&lt;profiles/&gt;
	&lt;activeProfiles/&gt;
&lt;/settings&gt;
</pre>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fmaven-settings-xml-for-corporate-proxy-with-custom-user-agent%2F&amp;title=Maven+settings.xml+for+corporate+proxy+with+custom+user-Agent" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fmaven-settings-xml-for-corporate-proxy-with-custom-user-agent%2F&amp;title=Maven+settings.xml+for+corporate+proxy+with+custom+user-Agent" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fmaven-settings-xml-for-corporate-proxy-with-custom-user-agent%2F&amp;title=Maven+settings.xml+for+corporate+proxy+with+custom+user-Agent" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fmaven-settings-xml-for-corporate-proxy-with-custom-user-agent%2F&amp;title=Maven+settings.xml+for+corporate+proxy+with+custom+user-Agent" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fmaven-settings-xml-for-corporate-proxy-with-custom-user-agent%2F&amp;title=Maven+settings.xml+for+corporate+proxy+with+custom+user-Agent', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fmaven-settings-xml-for-corporate-proxy-with-custom-user-agent%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fmaven-settings-xml-for-corporate-proxy-with-custom-user-agent%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fmaven-settings-xml-for-corporate-proxy-with-custom-user-agent%2F&amp;title=Maven+settings.xml+for+corporate+proxy+with+custom+user-Agent" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fmaven-settings-xml-for-corporate-proxy-with-custom-user-agent%2F&amp;title=Maven+settings.xml+for+corporate+proxy+with+custom+user-Agent" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/maven/maven-settings-xml-for-corporate-proxy-with-custom-user-agent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding Events in JEE6 with examples</title>
		<link>http://www.reverttoconsole.com/blog/jee6/understanding-events-in-jee6-with-examples/</link>
		<comments>http://www.reverttoconsole.com/blog/jee6/understanding-events-in-jee6-with-examples/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 19:00:57 +0000</pubDate>
		<dc:creator>Priyatam</dc:creator>
				<category><![CDATA[JEE6]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=695</guid>
		<description><![CDATA[JEE 6 implements Event Delagation model and Observer (Publish-Subscribe) pattern out of the box much more elegantly than other api. A Publisher fires events along with a type that needs to be passed. An Observer (can have multiple observers) simply observes for the Event &#8220;type&#8221; and receives the object sent by the publisher along with [...]]]></description>
			<content:encoded><![CDATA[<p>JEE 6 implements Event Delagation model and Observer (Publish-Subscribe) pattern out of the box much more elegantly than other api.</p>
<p>A Publisher fires events along with a type that needs to be passed. An Observer (can have multiple observers) simply observes for the Event &#8220;type&#8221; and receives the object sent by the publisher along with any other injectable objects. Note that there is no restriction on what objects needs to be sent when the event is fired. As long as the publisher and subscriber are sending and receiving same object types, the event is handled.</p>
<p>Note that since the event handler executes in a separate thread, it cannot alter the original event generator and an  exception thrown here will not affect the event generator. For such cases of fine grain control of business execution, use a Decorator.</p>
<p>Event Qualifier (annotation definition)</p>
<pre>
import javax.inject.Qualifier;
import java.lang.annotation.*;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Qualifier
@Retention(RUNTIME)
@Target({TYPE, METHOD, PARAMETER, FIELD})
public @interface RegistrationEvent {
}
</pre>
<p>Event Listener</p>
<pre>
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import org.jboss.logging.Logger;

public class RegisteredEventListener {
    @Inject
    private Logger log;

    public void onRegistration(@Observes @RegistrationEvent User user) {
    	log.info("Registration Event received for user: " + user);
    }
}
</pre>
<p>Event Firing (Actual Service where event is fired)</p>
<pre>

import javax.enterprise.event.Event;
import javax.inject.Inject;

@Stateless
public class UserRegistrationImpl
	implements UserRegistration, Serializable {

	@Inject
	@RegistrationEvent
	private Event< User> event; // Note: this event fires "User" objects

	public String register() {
		em.persist( member );
		event.fire( member ); // Fires the event
		return "users
	}
}
</pre>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-events-in-jee6-with-examples%2F&amp;title=Understanding+Events+in+JEE6+with+examples" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-events-in-jee6-with-examples%2F&amp;title=Understanding+Events+in+JEE6+with+examples" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-events-in-jee6-with-examples%2F&amp;title=Understanding+Events+in+JEE6+with+examples" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-events-in-jee6-with-examples%2F&amp;title=Understanding+Events+in+JEE6+with+examples" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-events-in-jee6-with-examples%2F&amp;title=Understanding+Events+in+JEE6+with+examples', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-events-in-jee6-with-examples%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-events-in-jee6-with-examples%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-events-in-jee6-with-examples%2F&amp;title=Understanding+Events+in+JEE6+with+examples" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-events-in-jee6-with-examples%2F&amp;title=Understanding+Events+in+JEE6+with+examples" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/jee6/understanding-events-in-jee6-with-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding JSR299, Contexts and Dependency Injection explained</title>
		<link>http://www.reverttoconsole.com/blog/jee6/understanding-jsr299-contexts-and-dependency-injection-explained/</link>
		<comments>http://www.reverttoconsole.com/blog/jee6/understanding-jsr299-contexts-and-dependency-injection-explained/#comments</comments>
		<pubDate>Sat, 05 Feb 2011 17:34:07 +0000</pubDate>
		<dc:creator>Priyatam</dc:creator>
				<category><![CDATA[JEE6]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=678</guid>
		<description><![CDATA[Forget Session, Application, Request, and Coversation Scope. All these scopes, though useful, still have to be managed by hand. ie., &#8211; a reference must be created in a session or request (the context) &#8211; a utility method must be written to manage this context (&#038; cleanup eventually) &#8211; the component needs to have access to [...]]]></description>
			<content:encoded><![CDATA[<p>Forget Session, Application, Request, and Coversation Scope. All these scopes, though useful, still have to be managed by hand. ie.,<br />
  &#8211; a reference must be created in a session or request (<strong>the context</strong>)<br />
  &#8211; a utility method must be written to manage this context (&#038; cleanup eventually)<br />
  &#8211; the component needs to have access to this utlity method or the context (session, request) to retrive the reference</p>
<p>Most importantly, the &#8220;client&#8221; component and original &#8220;context holder&#8221; have direct coupling of the refereced object. With JSR299, it&#8217;s like this:</p>
<blockquote><p> a reference to any object can be injected into any object without actually referring to the object</p></blockquote>
<p>Really? <em>That&#8217;s crazy.</em></p>
<p>Exactly.</p>
<p>JSR299 container manages thereferences for you in a context (session, requestm, conversation, etc.,) and provides a type-safe way of retrieving these references by a quaifier annotation. For ex, let&#8217;s say a PersonSearch Service needs to know the currently logged in user. Normally, you would use a utility function that will return the user. In Spring that would be SecurityContextHolder.getContext().getAuthentication().getPrincipal(). In Seam, it would be something simpler. But what if you don&#8217;t want to deal with a service that takes no method parameters and all that you want is a typed object in return?</p>
<p>Think. No parameters. </p>
<p>Would it be easier if you had somethinkg like this?</p>
<pre>
@LoggedIn
Principal principal;
</pre>
<p>in your service bean?</p>
<p>By injecting this annotated field, any component in the application can get the &#8220;reference to loggedIn user object.&#8221; The container holds this reference for any component that asks for it, and it holds it in the scope that the original reference was created. In this case, maye an Authenticator bean created it to keep it in SessionScope. In other words, any &#8220;managed&#8221; bean (ie., managed by the container, so Stateless, SessionScoped, ApplicatinScoped, etc.,) can get the reference to the logged in user by simply injecting a User object with a qualifier @LoggedInUser. Forget about static methods and manual context management!</p>
<p>But how do you create a @LoggedIn user? Simple, actually.</p>
<pre>
@Produces @LoggedIn @Named
public User getCurrentUser() {
    return currentUser;
}
</pre>
<p>In this case, a sessionScoped Authenticator component has a method that returns an instance variable, currentUser.</p>
<p>The advantage of this is loose coupling and at the same time, strong typing. Further, by providing multiple qualifier like @Produces and overriding scopes, the injectable object can be custom defined both at the injectable context and the point of creation (Producer).</p>
<p>Another fine example. Let&#8217;s say in the above person search, you want to return the list of persons and tie it to the request scope so that any other component in the same underlying request cycle can retrieve it (JSF page). </p>
<pre>
@Produces @Named @RequestScoped
public List&amp;&lt;Person&gt; getPersons() {
    return em.createQuery( &quot;select p from Person p&quot; ).getResultList();
}
</pre>
<p>Even better, you&#8217;d like to have a static lookup across the session.</p>
<pre>
@Produces @Named @SessionScoped public List&lt;Person&gt; getPersons() {
    return em.createQuery( &quot;select p from Person p&quot; ).getResultList();
}
</pre>
<p>But how do you then update the search list in the session if a new person was added in the same session? Welcome to JEE 6 build in Event Model.</p>
<pre>
public void onPersonListChanged(
    @Observes( notifyObserver = Reception.IF_EXISTS )
     final Person person ) {
	getPersons();
}
</pre>
<p>See <a href="http://download.oracle.com/javaee/6/api/index.html?javax/enterprise/event/Reception.html">here </a>to understand what @Reception means.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-jsr299-contexts-and-dependency-injection-explained%2F&amp;title=Understanding+JSR299%2C+Contexts+and+Dependency+Injection+explained" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-jsr299-contexts-and-dependency-injection-explained%2F&amp;title=Understanding+JSR299%2C+Contexts+and+Dependency+Injection+explained" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-jsr299-contexts-and-dependency-injection-explained%2F&amp;title=Understanding+JSR299%2C+Contexts+and+Dependency+Injection+explained" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-jsr299-contexts-and-dependency-injection-explained%2F&amp;title=Understanding+JSR299%2C+Contexts+and+Dependency+Injection+explained" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-jsr299-contexts-and-dependency-injection-explained%2F&amp;title=Understanding+JSR299%2C+Contexts+and+Dependency+Injection+explained', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-jsr299-contexts-and-dependency-injection-explained%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-jsr299-contexts-and-dependency-injection-explained%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-jsr299-contexts-and-dependency-injection-explained%2F&amp;title=Understanding+JSR299%2C+Contexts+and+Dependency+Injection+explained" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-jsr299-contexts-and-dependency-injection-explained%2F&amp;title=Understanding+JSR299%2C+Contexts+and+Dependency+Injection+explained" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/jee6/understanding-jsr299-contexts-and-dependency-injection-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding the uses of JEE6 @Decorator vs @Interceptor with an example</title>
		<link>http://www.reverttoconsole.com/blog/jee6/understanding-the-uses-of-jee6-decorator-vs-interceptor-with-an-example/</link>
		<comments>http://www.reverttoconsole.com/blog/jee6/understanding-the-uses-of-jee6-decorator-vs-interceptor-with-an-example/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 18:30:44 +0000</pubDate>
		<dc:creator>Priyatam</dc:creator>
				<category><![CDATA[JEE6]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=688</guid>
		<description><![CDATA[Let&#8217;s look at an Interceptor first. Interceptor definition: AuditTime &#8212; wraps a simple debug around a method invocation with time stamps. import static java.lang.annotation.ElementType.*; import static java.lang.annotation.RetentionPolicy.*; import java.lang.annotation.*; import javax.interceptor.*; @Inherited @InterceptorBinding @Target({TYPE, METHOD}) @Retention(RUNTIME) public @interface AuditTime { } Interceptor implementation. import javax.inject.*; import javax.interceptor.*; import org.jboss.logging.*; @AuditTime @Interceptor public class AuditTimeInterceptor implements [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s look at an Interceptor first.</p>
<p>Interceptor definition: AuditTime &#8212; wraps a simple debug around a method invocation with time stamps.</p>
<pre>
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
import javax.interceptor.*;

@Inherited
@InterceptorBinding
@Target({TYPE, METHOD})
@Retention(RUNTIME)
public @interface AuditTime {
}
</pre>
<p>Interceptor implementation.</p>
<pre>
import javax.inject.*;
import javax.interceptor.*;
import org.jboss.logging.*;

@AuditTime
@Interceptor
public class AuditTimeInterceptor implements Serializable {

	private static final long serialVersionUID = 8205679619877467367L;

	@Inject
	Logger log;

	@AroundInvoke
	public Object computeTimestamp(InvocationContext ctx ) throws Exception {

		log.trace( String.format(
			"Starting %s.%s",
			ctx.getMethod().getDeclaringClass().getSimpleName(),
			ctx.getMethod().getName() ) );

		long start = System.currentTimeMillis();

		Object object = ctx.proceed();

		long stop = System.currentTimeMillis();

		log.trace( String.format(
			"Invocation time for %s.%s is %s",
			ctx.getMethod().getDeclaringClass().getSimpleName(),
			ctx.getMethod().getName(),
			String.valueOf( stop - start ) ) );

		return object;
	}
}
</pre>
<p>Example Usage. </p>
<pre>
@AuditTime
public void foo(String bar) {
 // do something
}
</pre>
<p>The above is pretty straight forward. Adding an @AuditTime to <em>any</em> method will provide timestamps. An interceptor as you know adds cross-cutting concerns across methods, across code infratructure, maybe design. But it may not directly influence business decision. </p>
<p>A Decorator on the other hand, is a fine grained interceptor if you want to put it that way. Lets jump straight into an example.</p>
<p>An example User Registration Service</p>
<pre>
public interface UserRegistrationService {
	String register();
	String update();
	Member getUser();
	public String selectUser(String id );
}
</pre>
<p>Now, let&#8217;s say we want to filter all registrations that has a user email ending with &#8220;.ru.&#8221;</p>
<pre>
import javax.decorator.*;
import javax.inject.Inject;
import javax.persistence.*;
import org.jboss.logging.Logger;

import xxx.Service.UserRegistrationService;

@Decorator
public abstract class RegistrationEmailDecorator implements UserRegistration, Serializable {

	private static final long serialVersionUID = 7780160635139112007L;

	@Inject
	private Logger log;

	@PersistenceContext
	EntityManager em;

        // Note: A Decorator is exactly like the decorator pattern. It "is" and "has a" UserRegistration. In JEE6, the "has a" relationship, ie., composition, is explicitly qualified as @Delegate
	@Inject
	@Delegate
	UserRegistrationService service;

	public String register() {
		User u = service.getUser();

		if ( u.getEmail().endsWith( ".ru" ) ) {
			log.info( "Someone with russian domain has registered. Probably a spam, not registering." );

			// do not proceed original call
			return "users";
		}
                          // else, proceed the call.
		return service.register();
	}
}
</pre>
<p>This is obviously a dumb example but you get the picture. A decorator is different from an interceptor because an interceptor just intercepts <em>any </em>method call (before/after) but doesn&#8217;t know the behaviour inside the call. Since a Decorator (<a href="http://en.wikipedia.org/wiki/Decorator_pattern">Decorator Pattern</a>) implements the decorating class interface and composes it, it can modify the behavior based on business rules. </p>
<p>Thus, decorators provide business rule concerns (sort of &#8220;fine grained&#8221; interceptors) whereas an interceptor provides system wide, cross-cutting concerns (not related to business). Using both smartly in your JEE6 project can improve readability, and code maintenance. </p>
<p>Of course, don&#8217;t go crazy with Decortors or Interceptors making the actual Service calls useless <img src='http://www.reverttoconsole.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Nothing should override the most important design concern &#8212; OO.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-the-uses-of-jee6-decorator-vs-interceptor-with-an-example%2F&amp;title=Understanding+the+uses+of+JEE6+%40Decorator+vs+%40Interceptor+with+an+example" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-the-uses-of-jee6-decorator-vs-interceptor-with-an-example%2F&amp;title=Understanding+the+uses+of+JEE6+%40Decorator+vs+%40Interceptor+with+an+example" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-the-uses-of-jee6-decorator-vs-interceptor-with-an-example%2F&amp;title=Understanding+the+uses+of+JEE6+%40Decorator+vs+%40Interceptor+with+an+example" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-the-uses-of-jee6-decorator-vs-interceptor-with-an-example%2F&amp;title=Understanding+the+uses+of+JEE6+%40Decorator+vs+%40Interceptor+with+an+example" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-the-uses-of-jee6-decorator-vs-interceptor-with-an-example%2F&amp;title=Understanding+the+uses+of+JEE6+%40Decorator+vs+%40Interceptor+with+an+example', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-the-uses-of-jee6-decorator-vs-interceptor-with-an-example%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-the-uses-of-jee6-decorator-vs-interceptor-with-an-example%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-the-uses-of-jee6-decorator-vs-interceptor-with-an-example%2F&amp;title=Understanding+the+uses+of+JEE6+%40Decorator+vs+%40Interceptor+with+an+example" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Funderstanding-the-uses-of-jee6-decorator-vs-interceptor-with-an-example%2F&amp;title=Understanding+the+uses+of+JEE6+%40Decorator+vs+%40Interceptor+with+an+example" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/jee6/understanding-the-uses-of-jee6-decorator-vs-interceptor-with-an-example/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ivy file for a JEE6 / Seam 3-beta / Primefaces project</title>
		<link>http://www.reverttoconsole.com/blog/maven/ivy-file-for-a-jee6-seam-3-beta-primefaces-project/</link>
		<comments>http://www.reverttoconsole.com/blog/maven/ivy-file-for-a-jee6-seam-3-beta-primefaces-project/#comments</comments>
		<pubDate>Fri, 28 Jan 2011 20:23:25 +0000</pubDate>
		<dc:creator>Priyatam</dc:creator>
				<category><![CDATA[JEE6]]></category>
		<category><![CDATA[Maven/Ivy]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=658</guid>
		<description><![CDATA[Most examples online use Maven for build files. I&#8217;m sure some of you are still on ant or Ivy. Here&#8217;s an ivy file for a starter JEE6 project with Seam-3-beta (at this time of writing), Primefaces, Prettyfaces and other misc jars (testng) that you might need. &#60;?xml version=&#34;1.0&#34; encoding=&#34;ISO-8859-1&#34;?&#62; &#60;ivy-module version=&#34;2.0&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; xsi:noNamespaceSchemaLocation=&#34;http://ant.apache.org/ivy/schemas/ivy.xsd&#34;&#62; &#60;configurations&#62; &#60;conf [...]]]></description>
			<content:encoded><![CDATA[<p>Most examples online use Maven for build files. I&#8217;m sure some of you are still on ant or Ivy. Here&#8217;s an ivy file for a starter JEE6 project with Seam-3-beta (at this time of writing), Primefaces, Prettyfaces and other misc jars  (testng) that you might need.</p>
<pre>

&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
&lt;ivy-module version=&quot;2.0&quot;
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xsi:noNamespaceSchemaLocation=&quot;http://ant.apache.org/ivy/schemas/ivy.xsd&quot;&gt;  

    &lt;configurations&gt;
        &lt;conf name=&quot;provided&quot; visibility=&quot;public&quot;
            description=&quot;this is much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive.&quot; /&gt;
        &lt;conf name=&quot;compile&quot; visibility=&quot;public&quot;
            description=&quot;this is the compile scope. Compile dependencies are available in all classpaths.&quot; /&gt;
        &lt;conf name=&quot;test&quot; visibility=&quot;public&quot;
            description=&quot;this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.&quot; /&gt;
        &lt;conf name=&quot;tools&quot; visibility=&quot;public&quot;
            description=&quot;this scope indicates that the dependency is not required for normal use of the application, and is only available for the build phases (ant builds).&quot; /&gt;
    &lt;/configurations&gt; 

    &lt;dependencies&gt;

        &lt;!-- PROVIDED              --&gt;

        &lt;!-- JEE 6 --&gt;
        &lt;dependency org=&quot;javax&quot; name=&quot;javaee-api&quot;
            rev=&quot;6.0&quot; conf=&quot;provided-&gt;default&quot; /&gt;
        &lt;dependency org=&quot;org.jboss.spec&quot; name=&quot;jboss-javaee6-specs-bom&quot;
            rev=&quot;1.0.1.Final&quot; conf=&quot;provided-&gt;default&quot; /&gt;

        &lt;!-- Hibernate --&gt;
        &lt;dependency org=&quot;org.hibernate&quot; name=&quot;hibernate-core&quot; rev=&quot;3.5.6-Final&quot;
            conf=&quot;provided-&gt;default&quot; /&gt;
        &lt;dependency org=&quot;org.hibernate&quot; name=&quot;hibernate-annotations&quot;
            rev=&quot;3.5.6-Final&quot; conf=&quot;provided-&gt;default&quot; /&gt;
        &lt;dependency org=&quot;org.hibernate&quot; name=&quot;hibernate-entitymanager&quot;
            rev=&quot;3.5.6-Final&quot; conf=&quot;provided-&gt;default&quot; /&gt;
        &lt;dependency org=&quot;org.hibernate&quot; name=&quot;hibernate-validator&quot;
            rev=&quot;4.0.0.GA&quot; conf=&quot;provided-&gt;default&quot; /&gt;

        &lt;!-- Misc --&gt;
        &lt;dependency org=&quot;log4j&quot; name=&quot;log4j&quot; rev=&quot;1.2.14&quot;
            conf=&quot;provided-&gt;default&quot; /&gt;

        &lt;!-- COMPILE      --&gt;

       &lt;!-- Seam --&gt;
        &lt;dependency org=&quot;org.jboss.seam.persistence&quot; name=&quot;seam-persistence&quot;
            rev=&quot;3.0.0.Beta3&quot; conf=&quot;compile-&gt;default&quot; transitive=&quot;false&quot; /&gt;
        &lt;dependency org=&quot;org.jboss.seam.faces&quot; name=&quot;seam-faces&quot;
            rev=&quot;3.0.0.Beta2&quot; conf=&quot;compile-&gt;default&quot; transitive=&quot;false&quot; /&gt;
        &lt;dependency org=&quot;org.jboss.seam.solder&quot; name=&quot;seam-solder&quot;
            rev=&quot;3.0.0.Beta3&quot; conf=&quot;compile-&gt;default&quot; transitive=&quot;false&quot; /&gt;
        &lt;!--
          Don&#039;t use it unless this issue is resolved: https://issues.jboss.org/browse/SEAMCATCH-42
        &lt;dependency org=&quot;org.jboss.seam.servlet&quot; name=&quot;seam-servlet&quot;
            rev=&quot;3.0.0.Beta1&quot; conf=&quot;compile-&gt;default&quot; transitive=&quot;false&quot; /&gt;
        &lt;dependency org=&quot;org.jboss.seam.catch&quot; name=&quot;seam-catch&quot;
            rev=&quot;3.0.0.Beta1&quot; conf=&quot;compile-&gt;default&quot; transitive=&quot;false&quot; /&gt;
        --&gt;

        &lt;!-- Primefaces  --&gt;
        &lt;dependency org=&quot;org.primefaces&quot; name=&quot;primefaces&quot; rev=&quot;2.2&quot;
            conf=&quot;compile-&gt;default&quot; transitive=&quot;false&quot;/&gt;

        &lt;!-- Prettyfaces  (URL Rewriter)--&gt;
        &lt;dependency org=&quot;com.ocpsoft&quot; name=&quot;prettyfaces-jsf2&quot; rev=&quot;3.2.0&quot;
            conf=&quot;compile-&gt;default&quot; /&gt;

        &lt;!--Envers/Ehcache--&gt;
        &lt;dependency org=&quot;org.hibernate&quot; name=&quot;hibernate-envers&quot;
            rev=&quot;3.5.6-Final&quot; conf=&quot;compile-&gt;default&quot; transitive=&quot;false&quot;/&gt;
        &lt;dependency org=&quot;net.sf.ehcache&quot; name=&quot;ehcache&quot; rev=&quot;1.5.0&quot;
            conf=&quot;compile-&gt;default&quot; transitive=&quot;false&quot;/&gt;

        &lt;!-- Misc --&gt;
        &lt;dependency org=&quot;joda-time&quot; name=&quot;joda-time&quot; rev=&quot;1.6&quot;
            conf=&quot;compile-&gt;default&quot; transitive=&quot;false&quot;/&gt;
        &lt;dependency org=&quot;backport-util-concurrent&quot; name=&quot;backport-util-concurrent&quot; rev=&quot;3.1&quot;
            conf=&quot;compile-&gt;default&quot; transitive=&quot;false&quot; /&gt;
        &lt;dependency org=&quot;org.apache.poi&quot; name=&quot;poi&quot; rev=&quot;3.2-FINAL&quot;
            conf=&quot;compile-&gt;default&quot; transitive=&quot;false&quot; /&gt;
        &lt;dependency org=&quot;com.lowagie&quot; name=&quot;itext&quot; rev=&quot;2.1.7&quot;
            conf=&quot;compile-&gt;default&quot; transitive=&quot;false&quot; /&gt;
        &lt;dependency org=&quot;org.slf4j&quot; name=&quot;slf4j-api&quot; rev=&quot;1.5.10&quot;
            conf=&quot;tools-&gt;default&quot; /&gt;
        &lt;dependency org=&quot;org.slf4j&quot; name=&quot;slf4j-log4j12&quot; rev=&quot;1.6.0&quot;
            conf=&quot;tools-&gt;default&quot; /&gt;

        &lt;!-- TESTING --&gt;
        &lt;dependency org=&quot;junit&quot; name=&quot;junit&quot; rev=&quot;4.8.2&quot; conf=&quot;test-&gt;default&quot; /&gt;
        &lt;dependency org=&quot;org.jboss.arquillian&quot; name=&quot;arquillian-junit&quot;
            rev=&quot;1.0.0.Alpha4&quot; conf=&quot;test-&gt;default&quot; /&gt;
        &lt;dependency org=&quot;org.jboss.arquillian.container&quot; name=&quot;arquillian-glassfish-embedded-3&quot;
            rev=&quot;1.0.0.Alpha4&quot; conf=&quot;test-&gt;default&quot; /&gt;
        &lt;dependency org=&quot;org.glassfish.extras&quot; name=&quot;glassfish-embedded-all&quot;
            rev=&quot;3.0.1-b20&quot; conf=&quot;test-&gt;default&quot; /&gt;
    &lt;/dependencies&gt;
&lt;/ivy-module&gt;
</pre>
<p>And the ivy resolvers in settings file would be something like this:</p>
<pre>

&lt;resolvers&gt;
		&lt;chain name=&quot;default&quot; returnFirst=&quot;true&quot; dual=&quot;true&quot;&gt;

			&lt;!-- Local Filesystem --&gt;
			&lt;filesystem name=&quot;repos&quot;&gt;
				&lt;ivy pattern=&quot;${dest.repo.dir}/[organisation]/[module]/ivys/ivy-[revision].xml&quot;/&gt;
				&lt;artifact
						pattern=&quot;${dest.repo.dir}/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]&quot;/&gt;
			&lt;/filesystem&gt;

			&lt;ibiblio name=&quot;maven-fixes&quot; m2compatible=&quot;true&quot;
					root=&quot;file://${basedir}/maven-fixes/&quot;
					pattern=&quot;[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]&quot; /&gt;

			&lt;ibiblio name=&quot;java.net&quot; m2compatible=&quot;true&quot;
					root=&quot;http://download.java.net/maven/2/&quot; /&gt;

			&lt;!-- JBoss --&gt;
			&lt;ibiblio name=&quot;jboss-nexus&quot; m2compatible=&quot;true&quot;
					 root=&quot;https://repository.jboss.org/nexus/content/groups/developer/&quot;
					 pattern=&quot;[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]&quot;/&gt;
		&lt;/chain&gt;
</pre>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fivy-file-for-a-jee6-seam-3-beta-primefaces-project%2F&amp;title=Ivy+file+for+a+JEE6+%2F+Seam+3-beta+%2F+Primefaces+project" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fivy-file-for-a-jee6-seam-3-beta-primefaces-project%2F&amp;title=Ivy+file+for+a+JEE6+%2F+Seam+3-beta+%2F+Primefaces+project" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fivy-file-for-a-jee6-seam-3-beta-primefaces-project%2F&amp;title=Ivy+file+for+a+JEE6+%2F+Seam+3-beta+%2F+Primefaces+project" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fivy-file-for-a-jee6-seam-3-beta-primefaces-project%2F&amp;title=Ivy+file+for+a+JEE6+%2F+Seam+3-beta+%2F+Primefaces+project" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fivy-file-for-a-jee6-seam-3-beta-primefaces-project%2F&amp;title=Ivy+file+for+a+JEE6+%2F+Seam+3-beta+%2F+Primefaces+project', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fivy-file-for-a-jee6-seam-3-beta-primefaces-project%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fivy-file-for-a-jee6-seam-3-beta-primefaces-project%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fivy-file-for-a-jee6-seam-3-beta-primefaces-project%2F&amp;title=Ivy+file+for+a+JEE6+%2F+Seam+3-beta+%2F+Primefaces+project" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fmaven%2Fivy-file-for-a-jee6-seam-3-beta-primefaces-project%2F&amp;title=Ivy+file+for+a+JEE6+%2F+Seam+3-beta+%2F+Primefaces+project" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/maven/ivy-file-for-a-jee6-seam-3-beta-primefaces-project/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Example of RESTful Webservices in JEE6 with Exception mapper to route HTTP status codes</title>
		<link>http://www.reverttoconsole.com/blog/jee6/example-of-restful-webservices-in-jee6-with-exception-mapper-to-route-http-status-codes/</link>
		<comments>http://www.reverttoconsole.com/blog/jee6/example-of-restful-webservices-in-jee6-with-exception-mapper-to-route-http-status-codes/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 18:12:12 +0000</pubDate>
		<dc:creator>Priyatam</dc:creator>
				<category><![CDATA[JEE6]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=685</guid>
		<description><![CDATA[JEE6 provides a specification for Webservices (SOAP AND REST) and JAX-RS is the default Reference implementation. A lot of cookie-cutter code is eliminated for implementing webservices. Unlike Restlet which doesn&#8217;t provide much functionality for integrating restful webservices into a web application (exception mapping and custom annotations to process http params, or DI), JEE6 webservices combine [...]]]></description>
			<content:encoded><![CDATA[<p>JEE6 provides a specification for Webservices (SOAP AND REST) and JAX-RS is the default Reference implementation. A lot of cookie-cutter code is eliminated for implementing webservices. Unlike <a href="http://www.restlet.org">Restlet </a>which doesn&#8217;t provide much functionality for integrating restful webservices into a web application (exception mapping and custom annotations to process http params, or DI), JEE6 webservices combine the power of JSR299 along with several utlity methods. For example, an exception mapping provider maps an exception to a Response. If this exception is thrown, the JAX-RS implementation will catch it and invoke the corresponding exception mapping provider. An exception mapping provider is an implementation of ExceptionMapper<E extends Throwable>, annotated with @Provider.</p>
<p>In this example code, let&#8217;s walk through a simple usecase where we need to retrieve a list of users via GET using the path: /users/{email} </p>
<p>First, you need to add a JAXRs Activator class. A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6 &#8220;no XML&#8221; approach to activating JAX RS.</p>
<pre>
@ApplicationPath( "/rest" )
public class JaxRsActivator
	extends Application {
	/* class body intentionally left blank */
}
</pre>
<p>Then, add a RESTful Service class with the correct Path</p>
<pre>
@Path( "/users" )
@Produces( { "application/xml", "application/json" } )
@RequestScoped
public class UserRESTService {

	@PersistenceContext
	private EntityManager em;

	@Context
	private UriInfo uriInfo;

	@GET
	public List< User> listAllUser() {
	    return em.createNamedQuery( "UserfindAll", User.class ).getResultList();
	}

	@GET
	@Path( "/{email}" )
	public UserlookupUserByEmail(@PathParam( "email" ) String email ) {
		// Note that if NoResultException is thrown by below, NoResultMapper automactically translates to a 404
		Member member = null;
		return em.createNamedQuery( "User.findByEmail", User.class ).setParameter( "email", email ).getSingleResult();			}
}
</pre>
<p>Finally, write an Exception Translator(s)</p>
<pre>
@Provider
public class NoResultMapper implements ExceptionMapper< NoResultException > {
    public Response toResponse( NoResultException ex ) {
	return Response.status( 404 ).entity( ex.getMessage() ).type( MediaType.TEXT_PLAIN ).build();
    }
}
</pre>
<p>As you can see, there are no xml configurations. No surprises. It just works in any standard JEE6 container. Note that webservices are not a part of Web Profile, so you would need a fully certified JEE6 container (glassfish or JBoss). </p>
<p>For other features like mapping http params to method params, DI or other exception handling, watch out for Seam 3 Rest support (currently in beta) which have custom bean validation integrated into http requests, seam-catch exception handling, and other cdi extensions.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Fexample-of-restful-webservices-in-jee6-with-exception-mapper-to-route-http-status-codes%2F&amp;title=Example+of+RESTful+Webservices+in+JEE6+with+Exception+mapper+to+route+HTTP+status+codes" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Fexample-of-restful-webservices-in-jee6-with-exception-mapper-to-route-http-status-codes%2F&amp;title=Example+of+RESTful+Webservices+in+JEE6+with+Exception+mapper+to+route+HTTP+status+codes" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Fexample-of-restful-webservices-in-jee6-with-exception-mapper-to-route-http-status-codes%2F&amp;title=Example+of+RESTful+Webservices+in+JEE6+with+Exception+mapper+to+route+HTTP+status+codes" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Fexample-of-restful-webservices-in-jee6-with-exception-mapper-to-route-http-status-codes%2F&amp;title=Example+of+RESTful+Webservices+in+JEE6+with+Exception+mapper+to+route+HTTP+status+codes" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Fexample-of-restful-webservices-in-jee6-with-exception-mapper-to-route-http-status-codes%2F&amp;title=Example+of+RESTful+Webservices+in+JEE6+with+Exception+mapper+to+route+HTTP+status+codes', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Fexample-of-restful-webservices-in-jee6-with-exception-mapper-to-route-http-status-codes%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Fexample-of-restful-webservices-in-jee6-with-exception-mapper-to-route-http-status-codes%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Fexample-of-restful-webservices-in-jee6-with-exception-mapper-to-route-http-status-codes%2F&amp;title=Example+of+RESTful+Webservices+in+JEE6+with+Exception+mapper+to+route+HTTP+status+codes" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fjee6%2Fexample-of-restful-webservices-in-jee6-with-exception-mapper-to-route-http-status-codes%2F&amp;title=Example+of+RESTful+Webservices+in+JEE6+with+Exception+mapper+to+route+HTTP+status+codes" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/jee6/example-of-restful-webservices-in-jee6-with-exception-mapper-to-route-http-status-codes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

