<?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>Technotrance, Illusions and Perspectives</title>
	<atom:link href="http://schakrap.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://schakrap.wordpress.com</link>
	<description>Derivatives of technical expressions</description>
	<lastBuildDate>Wed, 11 Nov 2009 13:12:46 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='schakrap.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/4cae4a756dd954eb47730826b8a495a4?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Technotrance, Illusions and Perspectives</title>
		<link>http://schakrap.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://schakrap.wordpress.com/osd.xml" title="Technotrance, Illusions and Perspectives" />
		<item>
		<title>Shifted! http://myblog.shriharisc.com/</title>
		<link>http://schakrap.wordpress.com/2009/11/11/shifted-httpmyblog-shriharisc-com/</link>
		<comments>http://schakrap.wordpress.com/2009/11/11/shifted-httpmyblog-shriharisc-com/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 13:12:46 +0000</pubDate>
		<dc:creator>Shrihari Chakrapani</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=136</guid>
		<description><![CDATA[I recently migrated to my newly hosted domain at http://myblog.shriharisc.com/ Please update your bookmarks  
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=136&subd=schakrap&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I recently migrated to my newly hosted domain at http://myblog.shriharisc.com/ Please update your bookmarks <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/schakrap.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/schakrap.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/schakrap.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/schakrap.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/schakrap.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/schakrap.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/schakrap.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/schakrap.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/schakrap.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/schakrap.wordpress.com/136/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=136&subd=schakrap&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://schakrap.wordpress.com/2009/11/11/shifted-httpmyblog-shriharisc-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e526c33330ecec972667ecd95501d513?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shrihari</media:title>
		</media:content>
	</item>
		<item>
		<title>Forking navigations based on user roles in JBoss Seam using Seam-Security</title>
		<link>http://schakrap.wordpress.com/2009/10/14/forking-navigations-based-on-user-roles-in-jboss-seam-using-seam-security/</link>
		<comments>http://schakrap.wordpress.com/2009/10/14/forking-navigations-based-on-user-roles-in-jboss-seam-using-seam-security/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 10:19:27 +0000</pubDate>
		<dc:creator>Shrihari Chakrapani</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[jboss-seam]]></category>
		<category><![CDATA[seam-security]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=130</guid>
		<description><![CDATA[This particular tip on loading different homepages for the role associated for a specific logged in user for a JSF web application written using JBoss Seam and identity management using Seam-Security. This tip assumes that a single user will be associated with a single role.
Assume we need to develop a course management JSF application which [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=130&subd=schakrap&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This particular tip on loading different homepages for the role associated for a specific logged in user for a JSF web application written using JBoss Seam and identity management using Seam-Security. This tip assumes that a single user will be associated with a single role.</p>
<p>Assume we need to develop a course management JSF application which supports users of 2 different roles : teacher and student. This means if a user with teacher role logs in teacher specific homepage should come  and student logging in should display student homepage. The following are steps to achieve this requirement.</p>
<p>1) Change WEB-INF/components.xml to include the seam-security authentication patterns</p>
<pre><span style="color:#0000ff;">&lt;components xmlns="http://jboss.com/products/seam/components"
          ....
          xmlns:security="http://jboss.com/products/seam/security"
          xsi:schemaLocation="http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
                ....
          "&gt;
 ...
 &lt;security:identity authenticate-method="#{authenticator.authenticate}"/&gt;
&lt;/components&gt;</span>
</pre>
<p>2) Define an Authenticator action class with JBoss Seam component name &#8220;authenticator&#8221; and define an authenticate method inside</p>
<pre><span style="color:#0000ff;">@Name("authenticator")
public class AuthenticatorAction
{   @In
    private Identity identity;
    @In(create=true)
    private AuthService service;

    ...
    @SuppressWarnings("deprecated")
    public boolean authenticate()
    {   String username = identity.getUsername();
        String password = identity.getPassword();
        if(username==null || password==null)
           return false;
        //authenticate the user from database
        User user = service.authenticate(username,password);
        // check user validity.
        identity.addRole(user.getRole());
        return true;
    }
}
</span></pre>
<p>3) Define the login portal widget in the login-page (say login.xhtml)</p>
<pre><span style="color:#0000ff;">&lt;ui:composition xmlns="http://www.w3.org/1999/xhtml"&gt;
 .....
   &lt;h:panelGrid columns="2" style="width:27px"&gt;
      &lt;h:outputText value="Username: "/&gt;
      &lt;h:inputText id="username" value="#{identity.username}" rows="1" cols="12"&gt;
         &lt;f:validateLength minimum="8"  /&gt;
      &lt;/h:inputText&gt;
      &lt;h:outputText value="Password:" rows="1" cols="12"/&gt;
      &lt;h:inputSecret id="password" value="#{identity.password}" /&gt;
   &lt;/h:panelGrid&gt;
   &lt;h:commandButton id="login" action="#{identity.login}" value="Login"/&gt;
    ...
 &lt;/ui:composition&gt;</span>
</pre>
<p>4) Wire the action outcomes to set up the navigation paths in WEB-INF/pages.xml</p>
<pre><span style="color:#888888;">
<span style="color:#0000ff;">&lt;pages xmlns="http://jboss.com/products/seam/pages"
       ....
       no-conversation-view-id="/index.html"&gt; 

     &lt;page view-id="/login.xhtml"&gt;
        &lt;navigation from-action="#{authenticator.checkLogin}"&gt;
           &lt;rule if="#{identity.loggedIn and identity.role=='Teacher'}"&gt;
               &lt;redirect view-id="/teacher/homepage.xhtml" /&gt;
          &lt;/rule&gt;
       &lt;/navigation&gt;
       &lt;navigation from-action="#{identity.login}"&gt;
           &lt;rule if="#{identity.loggedIn and identity.hasRole('Teacher')}"&gt;
              &lt;redirect view-id="/teacher/homepage.xhtml" /&gt;
          &lt;/rule&gt;
       &lt;/navigation&gt;
       &lt;navigation from-action="#{authenticator.checkLogin}"&gt;
          &lt;rule if="#{identity.loggedIn and identity.role=='Student'}"&gt;
               &lt;redirect view-id="/student/homepage.xhtml" /&gt;
          &lt;/rule&gt;
       &lt;/navigation&gt;
       &lt;navigation from-action="#{identity.login}"&gt;
           &lt;rule if="#{identity.loggedIn and identity.hasRole('Student')}"&gt;
              &lt;redirect view-id="/student/homepage.xhtml" /&gt;
          &lt;/rule&gt;
       &lt;/navigation&gt;
    &lt;/page&gt;
    ....
   &lt;exception&gt;
        &lt;redirect view-id="/index.xhtml"&gt;
           &lt;message&gt;Please log in first&lt;/message&gt;
        &lt;/redirect&gt;
   &lt;/exception&gt;
&lt;/pages&gt;</span></span><span style="color:#0000ff;">
</span>
</pre>
<p>You can extend this tip to come out of different other user-role combinations.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/schakrap.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/schakrap.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/schakrap.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/schakrap.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/schakrap.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/schakrap.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/schakrap.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/schakrap.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/schakrap.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/schakrap.wordpress.com/130/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=130&subd=schakrap&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://schakrap.wordpress.com/2009/10/14/forking-navigations-based-on-user-roles-in-jboss-seam-using-seam-security/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e526c33330ecec972667ecd95501d513?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shrihari</media:title>
		</media:content>
	</item>
		<item>
		<title>Unit testing CXF webservice endpoints using Spring-Test and TestNG</title>
		<link>http://schakrap.wordpress.com/2009/10/09/unit-testing-cxf-webservice-endpoints-using-spring-test-and-testng/</link>
		<comments>http://schakrap.wordpress.com/2009/10/09/unit-testing-cxf-webservice-endpoints-using-spring-test-and-testng/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 16:05:44 +0000</pubDate>
		<dc:creator>Shrihari Chakrapani</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache-cxf]]></category>
		<category><![CDATA[spring-test]]></category>
		<category><![CDATA[testng]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=127</guid>
		<description><![CDATA[The Spring IOC feature of configurational wiring of POJOs to control and achieve network of business logic frees developers of writing any boilerplate code and eventually of bugs. I would like to explain one such facility with regard to establishing an unit testing infrastructure for writing unit test cases for JAXWS specific web service endpoints [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=127&subd=schakrap&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The Spring IOC feature of configurational wiring of POJOs to control and achieve network of business logic frees developers of writing any boilerplate code and eventually of bugs. I would like to explain one such facility with regard to establishing an unit testing infrastructure for writing unit test cases for JAXWS specific web service endpoints (CXF) using Spring-test module and TestNG unit testing framework.</p>
<p>Lets take a simple example of a web service endpoint exposing a functionality to query a book price, given the ISBN number, given a maven project. This write-up just concentrates on establishing a web service unit testing framework. Following are sequence of steps one could follow to achieve the required infrastructure setup.</p>
<p>1) Change ${basedir}/pom.xml include adding spring-test dependency, and TestNG dependency, with maven-surefire-plugin configuration (assuming CXF dependencies are already present)</p>
<pre><span style="color:#0000ff;">&lt;dependency&gt;
 &lt;groupId&gt;org.springframework&lt;/groupId&gt;
 &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
 &lt;version&gt;2.5.6&lt;/version&gt;
 &lt;/dependency&gt;
&lt;dependency&gt;
 &lt;groupId&gt;org.testng&lt;/groupId&gt;
 &lt;artifactId&gt;testng&lt;/artifactId&gt;
 &lt;version&gt;5.9&lt;/version&gt;
 &lt;classfier&gt;jdk15&lt;/classifier&gt;
 &lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;</span></pre>
<p>2) Add a Spring configuration file (service-test.xml) under ${basedir}/src/test/resources. The CXF&#8217;s JaxWSProxyFactoryBean can be wired to to create a service proxy. Below is the snippet of the configuration file.</p>
<pre><span style="color:#0000ff;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                    http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"&gt;</span></pre>
<pre><span style="color:#0000ff;">     &lt;import resource="classpath:META-INF/cxf/cxf.xml" /&gt;
     &lt;import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /&gt;
     &lt;import resource="classpath:META-INF/cxf/cxf-extension-http.xml" /&gt;

     &lt;!-- Required to load the service endpoint uris --&gt;
     &lt;bean id="propConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
         &lt;property name="locations"&gt;
            &lt;list&gt;
               &lt;value&gt;classpath:service-test.properties&lt;/value&gt;
             &lt;/list&gt;
         &lt;/property&gt;
     &lt;/bean&gt;

     &lt;bean id="proxyFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean"&gt;
         &lt;property name="serviceClass" value="com.schtech.service.endpoint.store.BookPriceService"/&gt;
         &lt;property name="address" value="${bookstore.service.endpoint.url}"/&gt;
         &lt;property name="bus" ref="cxf" /&gt;
    &lt;/bean&gt;

     &lt;bean id="serviceClient" class="com.schtech.service.endpoint.store.BookPriceService" factory-bean="proxyFactory"
        factory-method="create"/&gt;
&lt;/beans&gt;</span>
</pre>
<p>3) Implement the TestNG test case to test web service. Here three things have to be noted: (1) ContextConfiguration annotation helps us load<br />
the configuration file. (2) The test case extends AbstractTestNGSpringContextTests to load the context configuration and autowire the service<br />
bean. (3) Autowire annotation on the service endpoint interface initializes with proxy factory created service proxy instance.</p>
<pre><span style="color:#0000ff;">@ContextConfiguration(locations = {"classpath:service-context.xml"})
public class BookCatalogTest extends AbstractTestNGSpringContextTests
 { @Autowired
   private BookPriceService serviceClient;

   @Test
   public void testBookPrice()
   { String isbn = "978-3-16-148410-0,";
     Double price  = serviceClient.findBookPrice(isbn);
     assertNotNull(price);
   }
}</span>
</pre>
<p>The infrastructure is ready to be used to test other service endpoints hosted elsewhere. Running mvn test at the ${basedir} prompt would unit test the service endpoints.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/schakrap.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/schakrap.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/schakrap.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/schakrap.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/schakrap.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/schakrap.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/schakrap.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/schakrap.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/schakrap.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/schakrap.wordpress.com/127/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=127&subd=schakrap&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://schakrap.wordpress.com/2009/10/09/unit-testing-cxf-webservice-endpoints-using-spring-test-and-testng/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e526c33330ecec972667ecd95501d513?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shrihari</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating asynchronous service using Spring JMS (ServiceExporter) and ActiveMQ</title>
		<link>http://schakrap.wordpress.com/2009/10/02/creating-asynchronous-service-using-spring-jms-serviceexporter-and-activemq/</link>
		<comments>http://schakrap.wordpress.com/2009/10/02/creating-asynchronous-service-using-spring-jms-serviceexporter-and-activemq/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 18:57:07 +0000</pubDate>
		<dc:creator>Shrihari Chakrapani</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[activemq]]></category>
		<category><![CDATA[spring-jms]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=123</guid>
		<description><![CDATA[Spring MDPs (Message-Driven-Pojos) provide excellent alternatives to MDBs (EJB specification), as we can enable asynchronous request handling capabilities to any tested business logic without defining container constraints or dependency hooks. There are three ways we could implement a Spring MDP:
(1) implementing javax.jms.MessageListener
(2) implementing org.springframework.jms.listener.SessionAwareMessageListener (which is a wrapper around javax.jms.MessageListener with javax.jms.Session) or
(3) any interface [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=123&subd=schakrap&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Spring MDPs (Message-Driven-Pojos) provide excellent alternatives to MDBs (EJB specification), as we can enable asynchronous request handling capabilities to any tested business logic without defining container constraints or dependency hooks. There are <a href="http://www.infoq.com/articles/richards-jms2">three ways</a> we could implement a Spring MDP:</p>
<p>(1) implementing javax.jms.MessageListener<br />
(2) implementing org.springframework.jms.listener.SessionAwareMessageListener (which is a wrapper around javax.jms.MessageListener with javax.jms.Session) or<br />
(3) any interface with implementation logic which accepts a string argument containing message data</p>
<p>This particular post tries to explore the third option of converting a tested business entity to handle asynchronous requests using <a href="http://static.springsource.org/spring/docs/2.5.x/reference/remoting.html">Spring JMS (ServiceExporter bean)</a> with ActiveMQ embedded broke, using a JMS Queuer.</p>
<p>1) Let us assume that our business entity interface and implementation are defined as below:</p>
<pre><span style="color:#0000ff;">public interface MyBusinessEntity
{      public void doBusinessLogic(String logicParameters) throws MyBusinessException;
}</span></pre>
<pre><span style="color:#0000ff;">public class MyBusinessEntityImpl implements MyBusinessEntity
{      public void doBusinessLogic(String logicParameters) throws MyBusinessException
       {       //using logicParameters, perform the business logic
       }
}</span></pre>
<p>2) The Spring application context should be defined to wire the embedded ActiveMQ broker with Spring JMS Service Exporter bean and the business entities as below:</p>
<pre><span style="color:#0000ff;">&lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:amq="http://activemq.apache.org/schema/core"
        xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                                  http://activemq.apache.org/schema/core  http://activemq.apache.org/schema/core/activemq-core-5.2.0.xsd"&gt;

     &lt;!-- Defines the ActiveMQ embedded  broker --&gt;
    &lt;amq:broker useJmx="false" persistent="false"&gt;
        &lt;amq:transportConnectors&gt;
                 &lt;amq:transportConnector uri="tcp://localhost:0" /&gt;
        &lt;/amq:transportConnectors&gt;
      &lt;/amq:broker&gt;

     &lt;amq:queue id="qDestination" physicalName="embedded" /&gt;

    &lt;amq:connectionFactory id="connectionFactory" brokerURL="vm://localhost" /&gt;

   &lt;bean id="mybusinessService" class="org.springframework.jms.remoting.JmsInvokerServiceExporter"&gt;
     &lt;property name="serviceInterface" value="mypackage.MyBusinessEntity"/&gt;
     &lt;property name="service"&gt;
            &lt;bean class="mypackage.MyBusinessEntityImpl"/&gt;
     &lt;/property&gt;
   &lt;/bean&gt;

   &lt;bean class="org.springframework.jms.listener.SimpleMessageListenerContainer"&gt;
       &lt;property name="connectionFactory" ref="connectionFactory"/&gt;
       &lt;property name="destination" ref="qDestination"/&gt;
       &lt;property name="messageListener" ref="placeBidService"/&gt;
   &lt;/bean&gt;

&lt;/beans&gt;</span></pre>
<p>3) If the application is a web-archive (war), add the Spring ContextLoader Listener to load the spring Context to your WEB-INF/web.xml.</p>
<pre>  <span style="color:#0000ff;">&lt;listener&gt;
     &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
   &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
         &lt;param-value&gt;classpath:jms-context.xml&lt;/param-value&gt;
   &lt;/context-param&gt;</span></pre>
<p>4) In order to asynchronously place a request, from the client, you need to define another client Spring context configuration mapping containing the reference to MyBusinessEntrity interface as given below, which could be used directly to place a request.</p>
<pre><span style="color:#0000ff;">&lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:amq="http://activemq.apache.org/schema/core"
      xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                       http://activemq.apache.org/schema/core  http://activemq.apache.org/schema/core/activemq-core-5.2.0.xsd"&gt;

 &lt;bean id="mybusinessService" class="org.springframework.jms.remoting.JmsInvokerProxyFactoryBean"&gt;
      &lt;property name="serviceInterface" value="mypackage.MyBusinessEntity"/&gt;
      &lt;property name="connectionFactory" ref="connectionFactory"/&gt;
      &lt;property name="queue" ref="qDestination"/&gt;
 &lt;/bean&gt;

 &lt;amq:queue id="qDestination" physicalName="embedded" /&gt;
 &lt;amq:connectionFactory id="connectionFactory" brokerURL="vm://localhost" /&gt;
&lt;/beans&gt;</span>
</pre>
<p>Having setup the server and client logics, the client can asynchronously lodge a request on server for the specific business logic.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/schakrap.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/schakrap.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/schakrap.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/schakrap.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/schakrap.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/schakrap.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/schakrap.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/schakrap.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/schakrap.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/schakrap.wordpress.com/123/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=123&subd=schakrap&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://schakrap.wordpress.com/2009/10/02/creating-asynchronous-service-using-spring-jms-serviceexporter-and-activemq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e526c33330ecec972667ecd95501d513?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shrihari</media:title>
		</media:content>
	</item>
		<item>
		<title>Loading Spring Context from Google Guice</title>
		<link>http://schakrap.wordpress.com/2009/09/15/loading-spring-context-from-google-guice/</link>
		<comments>http://schakrap.wordpress.com/2009/09/15/loading-spring-context-from-google-guice/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 15:26:21 +0000</pubDate>
		<dc:creator>Shrihari Chakrapani</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[google-guice]]></category>
		<category><![CDATA[guiceyfruit]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=114</guid>
		<description><![CDATA[Using Spring framework in any application opens a plethora of opportunities with regard to resolving complex requirement needs in lieu of the number of extensible components available based on the Spring framework. Some of the most preferred specification based stacks (such as Apache CXF)  are coupled with Spring Framework, and it would call for a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=114&subd=schakrap&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Using Spring framework in any application opens a plethora of opportunities with regard to resolving complex requirement needs in lieu of the number of extensible components available based on the Spring framework. Some of the most preferred specification based stacks (such as Apache CXF)  are coupled with Spring Framework, and it would call for a need to figure out options of getting the best of breed application stacks.</p>
<p>This particular entry looks at loading Spring Framework from Google Guice container. There are two approaches I have across till now, which I will try covering in breif:</p>
<p><span style="text-decoration:underline;"><strong>1) Using Guice&#8217;s SpringIntegration</strong></span></p>
<p>In this approach you need to download guice-spring.jar (version 1.0) or if your project is maven based, add the following dependency.</p>
<pre><span style="color:#0000ff;">&lt;dependency&gt;
     &lt;groupId&gt;com.google.inject.integration&lt;/groupId&gt;
     &lt;artifactId&gt;guice-spring&lt;/artifactId&gt;
     &lt;version&gt;1.0&lt;/version&gt;
&lt;/dependency&gt;</span></pre>
<p>You need to generalize an AbstractModule and use the com.google.inject.spring.SpringIntegration to load the Spring context into the Guice&#8217;s container.</p>
<pre><span style="color:#0000ff;">import com.google.inject.spring.SpringIntegration;
import com.google.inject.AbstractModule;
//other imports...
public class SpringContextModule extends AbstractModule
{ @Override
   protected void configure()
   { ApplicationContext applicationContext = new ClassPathXmlApplicationContext("appcontext-config.xml");
     SpringIntegration.bindAll(binder(), applicationContext);
    }
}</span></pre>
<p><strong><span style="text-decoration:underline;">2) Using GuiceyFruit&#8217;s SpringModule</span></strong></p>
<p>In this approach,  the dependency injection is based on JSR-250 common annotations specification and is resolved using the Spring annotation @Autowired (i.e.) all the beans have to be modified, introducing the annotation wherever the injection is required. This approach is suitable for all the beans for which we have control on the source code, and may not be a viable option for integration proven Spring modular components. In case if you have maven project, you need to include the below dependency:</p>
<pre>   <span style="color:#0000ff;"> &lt;dependency&gt;
      &lt;groupId&gt;org.guiceyfruit&lt;/groupId&gt;
      &lt;artifactId&gt;guiceyfruit-spring&lt;/artifactId&gt;
      &lt;version&gt;2.0-beta-6&lt;/version&gt;
    &lt;/dependency&gt;</span></pre>
<p>and create a Guice injector using</p>
<pre><span style="color:#0000ff;">Injector injector = Guice.createInjector(new SpringModule());</span></pre>
<p>More details can be looked at <a href="http://code.google.com/p/guiceyfruit/wiki/Spring">Guicey-Spring integration wiki page.</a></p>
<p>Approach 1 is prefered for integration of various most commonly used module component common both between Guice and Spring, as the configuration context can be reused, while the other approach is good enough for custom modules in Spring to be injected in Google Guice.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/schakrap.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/schakrap.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/schakrap.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/schakrap.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/schakrap.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/schakrap.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/schakrap.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/schakrap.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/schakrap.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/schakrap.wordpress.com/114/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=114&subd=schakrap&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://schakrap.wordpress.com/2009/09/15/loading-spring-context-from-google-guice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e526c33330ecec972667ecd95501d513?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shrihari</media:title>
		</media:content>
	</item>
		<item>
		<title>A Quick note about Hibernate Caching</title>
		<link>http://schakrap.wordpress.com/2009/09/14/a-quick-note-about-hibernate-caching/</link>
		<comments>http://schakrap.wordpress.com/2009/09/14/a-quick-note-about-hibernate-caching/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 16:32:43 +0000</pubDate>
		<dc:creator>Shrihari Chakrapani</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[query-cache]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=111</guid>
		<description><![CDATA[1)    First Level Cache (Transaction Layer)
a) Associated with a Hibernate Session (transaction scoped) and this cache is used by Hibernate transparently. Hibernate requires a key to load object from the session cache. Hence its better to call a load() or get(), when the key(EntityKey) is known, rather than using a HQL query.
b) All queries (state [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=111&subd=schakrap&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="margin-right:0;text-align:left;" dir="ltr"><span style="text-decoration:underline;"><strong><em>1)    First Level Cache (Transaction Layer)</em></strong></span></p>
<p style="margin-right:0;text-align:left;" dir="ltr">a) Associated with a Hibernate Session (transaction scoped) and this cache is used by Hibernate transparently. Hibernate requires a key to load object from the session cache. Hence its better to call a load() or get(), when the key(EntityKey) is known, rather than using a HQL query.<br />
b) All queries (state of an entity, updates) in the cache gets flushed / committed to the database only when  Transaction context ends (i.e.) <strong>getTransaction().commit</strong> is called.<br />
c) Always used and cannot be turned off.</p>
<p style="margin-right:0;text-align:left;" dir="ltr"><span style="text-decoration:underline;"><strong><em>2)    Second Level Cache (Application Layer)</em></strong></span></p>
<p style="margin-right:0;text-align:left;" dir="ltr">a) Associated with a Hibernate&#8217;s SessionFactory (process scoped). Enabled by default in Hibernate 3 and uses <strong>EHCache</strong> as default cache provider.<br />
b) The cache entries are dehydrated states of entity objects. A dehydrated state of entity refers to a key­-value  pair where key is the entity id (of the dehydrated entity) and the set of (deep copy) of attribute­values  (dehydrated entity fields) refer to the value.  Hibernate does not cache associations in a dehydrated object by default. One has to manually configured which association in a dehydratable entity to be cached.</p>
<p style="margin-right:0;text-align:left;" dir="ltr">Syntax : { id ­&gt; { atribute1, attribute2, attribute3,{attribute41, attribute42},&#8230; } }</p>
<p style="margin-right:0;text-align:left;" dir="ltr"><span style="text-decoration:underline;"><strong><em>3)   Query cache (</em></strong><strong>org.hibernate.cache.QueryCache)</strong></span></p>
<p style="margin-right:0;text-align:left;" dir="ltr">a) Defines 2 cache regions : <strong>org.hibernate.cache.StandardQueryCache</strong> (stores query with parameters as cache key) and <strong>org.hibernate.cache.UpdateTimestampsCache</strong> (keeps stale query results of last results fetch). Both the cache regions are evicted when the entity related to the cacheable query is updated.</p>
<p style="margin-right:0;text-align:left;" dir="ltr">Syntax : { query,{parameters}} &#8212;&gt; {id of cached entity}</p>
<p style="margin-right:0;text-align:left;" dir="ltr">b) A specific query results are cached, by specifying setCacheable(true) on Session&#8217;s Query handle.</p>
<div id="_mcePaste" style="overflow:hidden;position:absolute;left:-10000px;top:0;width:1px;height:1px;">
<p style="margin-right:0;text-align:left;" dir="ltr"><em>1)    First Level Cache (Transaction Layer)</em></p>
<p style="margin-right:0;text-align:left;" dir="ltr">a) Associated with a Hibernate Session (transaction scoped) and this cache is used by Hibernate transparently. Hibernate requires a key to load object from the session cache. Hence its better to call a load() or get(), when the key(EntityKey) is known, rather than using a HQL query.</p>
<p style="margin-right:0;text-align:left;" dir="ltr">b) All queries (state of an entity, updates) in the cache gets flushed / committed to the database only when  Transaction context ends (i.e.) <strong>getTransaction().commit</strong> is called.</p>
<p style="margin-right:0;text-align:left;" dir="ltr">c) Always used and cannot be turned off.</p>
<p style="margin-right:0;text-align:left;" dir="ltr">
<p style="margin-right:0;text-align:left;" dir="ltr"><em>2)    Second Level Cache (Application Layer)</em></p>
<p style="margin-right:0;text-align:left;" dir="ltr">a) Associated with a Hibernate&#8217;s SessionFactory (process scoped). Enabled by default in Hibernate 3 and uses <strong>EHCache</strong> as default cache provider.</p>
<p style="margin-right:0;text-align:left;" dir="ltr">
<p style="margin-right:0;text-align:left;" dir="ltr">b) The cache entries are dehydrated states of entity objects. A dehydrated state of entity refers to a key­-value  pair where key is the entity id (of the dehydrated entity) and the set of (deep copy) of attribute­values  (dehydrated entity fields) refer to the value.  Hibernate does not cache associations in a dehydrated object by default. One has to manually configured which association in a dehydratable entity to be cached.</p>
<p style="margin-right:0;text-align:left;" dir="ltr">
<p style="margin-right:0;text-align:left;" dir="ltr">Syntax : { id ­&gt; { atribute1, attribute2, attribute3,{attribute41, attribute42},&#8230; } }</p>
<p style="margin-right:0;text-align:left;" dir="ltr">
<p style="margin-right:0;text-align:left;" dir="ltr"><em>3)   Query cache (</em><strong>org.hibernate.cache.QueryCache</strong>)</p>
<p style="margin-right:0;text-align:left;" dir="ltr">
<p style="margin-right:0;text-align:left;" dir="ltr">a) Defines 2 cache regions : <strong>org.hibernate.cache.StandardQueryCache</strong> (stores query with parameters as cache key) and <strong>org.hibernate.cache.UpdateTimestampsCache</strong> (keeps stale query results of last results fetch). Both the cache regions are evicted when the entity related to the cacheable query is updated.</p>
<p style="margin-right:0;text-align:left;" dir="ltr">Syntax : { query,{parameters}} &#8212;&gt; {id of cached entity}</p>
<p style="margin-right:0;text-align:left;" dir="ltr">b) A specific query results are cached, by specifying setCacheable(true) on session&#8217;s Query handle.</p>
</div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/schakrap.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/schakrap.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/schakrap.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/schakrap.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/schakrap.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/schakrap.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/schakrap.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/schakrap.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/schakrap.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/schakrap.wordpress.com/111/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=111&subd=schakrap&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://schakrap.wordpress.com/2009/09/14/a-quick-note-about-hibernate-caching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e526c33330ecec972667ecd95501d513?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shrihari</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding Code Syntaxhiglighter plugin to Richfaces text editor</title>
		<link>http://schakrap.wordpress.com/2009/09/12/adding-code-syntaxhiglighter-plugin-to-richfaces-text-editor/</link>
		<comments>http://schakrap.wordpress.com/2009/09/12/adding-code-syntaxhiglighter-plugin-to-richfaces-text-editor/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 18:01:47 +0000</pubDate>
		<dc:creator>Shrihari Chakrapani</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[richfaces]]></category>
		<category><![CDATA[syntaxhighlighter]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=107</guid>
		<description><![CDATA[Exadel&#8217;s Richfaces Rich text editor integrates with TinyMCE javascript plugin to provide the rich text editor functions present in any document processing application. However often would be a need where we have to embed source code from a particular programming  language. In order to support  embedding code in the richtext editor, the code should [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=107&subd=schakrap&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Exadel&#8217;s Richfaces <a href="http://docs.jboss.org/richfaces/latest_3_3_X/en/tlddoc/rich/editor.html">Rich text editor</a> integrates with <a href="http://tinymce.moxiecode.com/">TinyMCE javascript plugin</a> to provide the rich text editor functions present in any document processing application. However often would be a need where we have to embed source code from a particular programming  language. In order to support  embedding code in the richtext editor, the code should be surrounded wuth appropriate &#8220;pre&#8221; tags with options for the selected programming language. This particular tip explores integrating a <a href="http://github.com/RichGuk/syntaxhl/tree/master">SyntaxHighlighter plugin</a> with Richfaces rich text editor, enabling the editor support for source code editing:</p>
<p>1) Download the sources from <a href="http://github.com/RichGuk/syntaxhl/tree/master">site</a>.</p>
<p>2) Create a folder under ${contextroot}/js/tinymceplugins/syntaxhighlight and extract all the contents of the downloaded zip/sources here. Remember that the folder name should be &#8216;tinymceplugin&#8217; as the TinyMCE javascript plugin looks for this folder for additional plugins if configured. Also note that ${contextroot} is your web application context root.</p>
<p>3) The different languages you need to support are present under ${contextroot}/js/tinymceplugins/syntaxhighlight/dialog.htm, where you retain only the relevant ones. For XML/XHTML support, you may need to add 2 additional lines, which would convert the XML tags to respective character equivalents in ${contextroot}/js/tinymceplugins/syntaxhighlight/js/dialog.js</p>
<pre><span style="color:#0000ff;">content_text = f.syntaxhl_code.value.replace(/&lt;/g,"&amp;lt;");
 content_text = content_text.replace(/&gt;/g,"&amp;gt;");
 textarea_output +=  content_text;</span></pre>
<p>4) Create a properties file rteplugins.properties (name with custom plugins are resolved) with a property containing full path (relative with regard to ${contextroot}) of the editor_plugin.js from the downloaded sources as given below.  Remember that property name used here (syntaxhl) is the plugin name used in the richtext editor configuration</p>
<pre><span style="color:#0000ff;">syntaxhl=/js/tinymceplugins/syntaxhighlight/editor_plugin.js</span></pre>
<p>5) The richfaces text editor configuration should be modified as below:</p>
<pre><span style="color:#0000ff;">&lt;rich:editor id="description" width="750" height="250" value="#{mybackingbean.description}"
 theme="advanced" viewMode="visual"  customPlugins="rteplugins" plugins="media,fullscreen,syntaxhl"&gt;
          &lt;f:param name="theme_advanced_buttons1"  value="code,bold,italic,underline,fullscreen,justifyleft,justifycenter,justifyright,
                                    fontselect,fontsizeselect,styleprops,tablecontrols,syntaxhl,
                                    search,replace,selectall,media,forecolor,backcolor,cut,copy,paste"/&gt;
          &lt;f:param name="theme_advanced_toolbar_location" value="top" /&gt;
          &lt;f:param name="theme_advanced_toolbar_align" value="left" /&gt;
          &lt;f:param name="extended_valid_elements" value="pre[name|class]"/&gt;
 &lt;/rich:editor&gt;</span></pre>
<p>Note: parameter &#8216;extended_valid_elements&#8217; identifies valid tags that can be present in the text in raw HTML form.</p>
<p>Well now you are ready to use the rich text editor to contain code snippets. Lets also try to look at how to view code in highlighted format in the next tip.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/schakrap.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/schakrap.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/schakrap.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/schakrap.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/schakrap.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/schakrap.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/schakrap.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/schakrap.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/schakrap.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/schakrap.wordpress.com/107/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=107&subd=schakrap&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://schakrap.wordpress.com/2009/09/12/adding-code-syntaxhiglighter-plugin-to-richfaces-text-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e526c33330ecec972667ecd95501d513?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shrihari</media:title>
		</media:content>
	</item>
		<item>
		<title>Chaining Apache CXF, JackRabbit using SpringModules</title>
		<link>http://schakrap.wordpress.com/2009/09/11/chaining-apache-cxf-jackrabbit-using-springmodules/</link>
		<comments>http://schakrap.wordpress.com/2009/09/11/chaining-apache-cxf-jackrabbit-using-springmodules/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 17:54:52 +0000</pubDate>
		<dc:creator>Shrihari Chakrapani</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=103</guid>
		<description><![CDATA[Apache CXF integration with Spring and SpringModules support for Apache JackRabbit provides a nice combination for chaining command of actions to be delegated across layers of the enterprise application tiers . Here is a quick tip as how to do this. A more detailed tutorial has been hosted at http://bit.ly/TmmJx
1) Web application configuration (/WEB-INF/web.xml) snippet [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=103&subd=schakrap&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Apache CXF integration with Spring and SpringModules support for Apache JackRabbit provides a nice combination for chaining command of actions to be delegated across layers of the enterprise application tiers . Here is a quick tip as how to do this. A more detailed tutorial has been hosted at <a rel="http://bit.ly/plugins/iframe?hashUrl=http%3A%2F%2Fbit.ly%2FTmmJx" href="http://bit.ly/TmmJx" target="_blank">http://bit.ly/TmmJx</a></p>
<p>1) Web application configuration (/WEB-INF/web.xml) snippet (as specified below) loads Apache CXF configuration (classpath:cxf.xml) and delegates to CXF container</p>
<pre> <span style="color:#0000ff;">&lt;context-param&gt;
 &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
 &lt;param-value&gt;classpath:cxf.xml&lt;/param-value&gt;
 &lt;/context-param&gt;

 &lt;servlet&gt;
 &lt;servlet-name&gt;CXFServlet&lt;/servlet-name&gt;
 &lt;servlet-class&gt;org.apache.cxf.transport.servlet.CXFServlet&lt;/servlet-class&gt;
 &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
 &lt;/servlet&gt;

 &lt;servlet-mapping&gt;
 &lt;servlet-name&gt;CXFServlet&lt;/servlet-name&gt;
 &lt;url-pattern&gt;/service/*&lt;/url-pattern&gt;
 &lt;/servlet-mapping&gt;</span></pre>
<p>2) Apache CXF&#8217;s configuration (cxf.xml) loads the Spring context configuration</p>
<pre><span style="color:#0000ff;"> &lt;import resource="classpath:META-INF/cxf/cxf.xml" /&gt;
 &lt;import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /&gt;
 &lt;import resource="classpath:META-INF/cxf/cxf-servlet.xml" /&gt;
 &lt;import resource="classpath:jcrcontext.xml"/&gt;</span></pre>
<p>where the SpringModules JCRContext configuration loads the JackRabbit&#8217;s RepositoryFactoryBean</p>
<pre><span style="color:#0000ff;"> &lt;bean id="repository" class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean"&gt;
  &lt;property name="configuration" value="classpath:repository.xml"/&gt;
  &lt;property name="homeDir" ref="./target/myrepository"/&gt;
 &lt;/bean&gt;

 &lt;bean id="sessionFactory"  class="org.springmodules.jcr.jackrabbit.JackrabbitSessionFactory"&gt;
  &lt;property name="repository" ref="repository" /&gt;
  &lt;property name="credentials" ref="simpleCredentials"/&gt;
 &lt;/bean&gt;

 &lt;bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate"&gt;
  &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  &lt;property name="allowCreate" value="true" /&gt;
 &lt;/bean&gt;

 &lt;bean id="simpleCredentials" class="javax.jcr.SimpleCredentials"&gt;
  &lt;constructor-arg index="0" value="bogus"/&gt;
  &lt;constructor-arg index="1"&gt;
   &lt;bean factory-bean="password" factory-method="toCharArray"/&gt;
  &lt;/constructor-arg&gt;
 &lt;/bean&gt;

 &lt;bean id="password"  class="java.lang.String"&gt;
  &lt;constructor-arg index="0" value="pass"/&gt;
 &lt;/bean&gt;</span></pre>
<p>This chaining can be extended to any depth and a myriad range of implementation stacks could be acheived, if a container (Spring, Seam, Guice) offer support for seamless intra-container configuration and component resolution.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/schakrap.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/schakrap.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/schakrap.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/schakrap.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/schakrap.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/schakrap.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/schakrap.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/schakrap.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/schakrap.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/schakrap.wordpress.com/103/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=103&subd=schakrap&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://schakrap.wordpress.com/2009/09/11/chaining-apache-cxf-jackrabbit-using-springmodules/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e526c33330ecec972667ecd95501d513?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shrihari</media:title>
		</media:content>
	</item>
		<item>
		<title>Using FreemarkerServlet in Google Guice to inject Configuration</title>
		<link>http://schakrap.wordpress.com/2009/09/05/using-freemarkerservlet-in-google-guice-to-inject-configuration/</link>
		<comments>http://schakrap.wordpress.com/2009/09/05/using-freemarkerservlet-in-google-guice-to-inject-configuration/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 19:01:01 +0000</pubDate>
		<dc:creator>Shrihari Chakrapani</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=95</guid>
		<description><![CDATA[Freemarker is a fantastic template parsing framework , and has its own avantages over Apache Velocity.  Google Guice is a straightforward injection framework which injects abstraction-driven ,instance-driven, or annotation driven module classes using bindings.  In order 2 get the best of both these frameworks, the following snippet would aid in doing so.
1) Modify the WEB-INF/web.xml [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=95&subd=schakrap&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Freemarker is a fantastic template parsing framework , and has its own avantages over Apache Velocity.  Google Guice is a straightforward injection framework which injects abstraction-driven ,instance-driven, or annotation driven module classes using bindings.  In order 2 get the best of both these frameworks, the following snippet would aid in doing so.</p>
<p>1) Modify the WEB-INF/web.xml to define FreemarkerServlet</p>
<pre><span style="color:#0000ff;">&lt;servlet&gt;
 &lt;servlet-name&gt;freemarker&lt;/servlet-name&gt;
 &lt;servlet-class&gt;com.ts.guicefmkr.web.TemplateServlet&lt;/servlet-class&gt;
 &lt;init-param&gt;
 &lt;param-name&gt;TemplatePath&lt;/param-name&gt;
 &lt;param-value&gt;/WEB-INF/ftl&lt;/param-value&gt;
 &lt;/init-param&gt;
 &lt;init-param&gt;
 &lt;param-name&gt;NoCache&lt;/param-name&gt;
 &lt;param-value&gt;true&lt;/param-value&gt;
 &lt;/init-param&gt;
 &lt;init-param&gt;
 &lt;param-name&gt;ContentType&lt;/param-name&gt;
 &lt;param-value&gt;text/html&lt;/param-value&gt;
 &lt;/init-param&gt;
 &lt;init-param&gt;
 &lt;param-name&gt;template_update_delay&lt;/param-name&gt;
 &lt;param-value&gt;0&lt;/param-value&gt;
 &lt;/init-param&gt;
 &lt;init-param&gt;
 &lt;param-name&gt;default_encoding&lt;/param-name&gt;
 &lt;param-value&gt;ISO-8859-1&lt;/param-value&gt;
 &lt;/init-param&gt;
 &lt;init-param&gt;
 &lt;param-name&gt;number_format&lt;/param-name&gt;
 &lt;param-value&gt;0.##########&lt;/param-value&gt;
 &lt;/init-param&gt;
 &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
 &lt;/servlet&gt;</span></pre>
<p>2) Extend the FreemarkerServlet and implement to Guice&#8217;s Module to bind the created  Configuration object</p>
<pre><span style="color:#0000ff;">import com.google.inject.Binder;
import com.google.inject.Injector;
import com.google.inject.Module;
import javax.servlet.ServletException;

import freemarker.ext.servlet.FreemarkerServlet;
import freemarker.template.Configuration;
public class TemplateServlet extends FreemarkerServlet implements Module
{   private Configuration templateConfig;
    public Configuration getTemplateConfig()
    {      return templateConfig;
    }

     public void setTemplateConfig(Configuration templateConfig) {
        this.templateConfig = templateConfig;
     }

    public void init() throws ServletException
     {   super.init();
         templateConfig = getConfiguration();
        Injector injector = com.google.inject.Guice.createInjector(this);
       }

      public void configure(Binder binder)
     {   binder.bind(Configuration.class).toInstance(templateConfig);
     }
}</span></pre>
<p>Thus you could use Configuration object anywhere in your application using @Inject from Guice.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/schakrap.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/schakrap.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/schakrap.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/schakrap.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/schakrap.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/schakrap.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/schakrap.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/schakrap.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/schakrap.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/schakrap.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=95&subd=schakrap&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://schakrap.wordpress.com/2009/09/05/using-freemarkerservlet-in-google-guice-to-inject-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e526c33330ecec972667ecd95501d513?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shrihari</media:title>
		</media:content>
	</item>
		<item>
		<title>Playing with Yahoo Maps on PrimeFaces</title>
		<link>http://schakrap.wordpress.com/2009/08/04/playing-with-yahoo-maps-on-primefaces/</link>
		<comments>http://schakrap.wordpress.com/2009/08/04/playing-with-yahoo-maps-on-primefaces/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 12:22:52 +0000</pubDate>
		<dc:creator>Shrihari Chakrapani</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[primefaces]]></category>
		<category><![CDATA[yahoo-rest]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=90</guid>
		<description><![CDATA[Yahoo Map services expose REST web-services API which aid the consumer to retreive maps given a locations based on address (street, city, state or zip) or coordinates (longitude, latitude). This cool tip explores an option to render a Yahoo hosted map for a PrimeFaces driven application.
1) Login to Yahoo Developer Network and generate an Yahoo [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=90&subd=schakrap&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Yahoo Map services expose <a href="http://developer.yahoo.com/maps/rest/V1/">REST web-services API </a>which aid the consumer to retreive maps given a locations based on address (street, city, state or zip) or coordinates (longitude, latitude). This cool tip explores an option to render a Yahoo hosted map for a <a href="http://primefaces.prime.com.tr/">PrimeFaces</a> driven application.</p>
<p>1) Login to Yahoo Developer Network and generate an <a href="http://developer.yahoo.com/wsregapp/">Yahoo Developer Application ID</a>.</p>
<p>2) Define and implement a PrimeFaces Controller which defines a MapMetadata POJO (containing address based attributes or coordinate based attributes) and defines a method to render the map accordingly.</p>
<pre><span style="color:#0000ff;">@Controller(name = "mapController", scope = REQUEST)
public class YahooMapController
{   private String mapURL = new String();
    private boolean showMap = false;
    private MapMetadata map = new MapMetadata();
    //setters and accessors</span></pre>
<pre><span style="color:#0000ff;">    public void renderMapByAddress()
    {   StringBuilder query = new StringBuilder();
        String details = map.getStreet();
        query.append((details!=null)?"street=" + details + "&amp;":"");</span></pre>
<pre><span style="color:#0000ff;">        details = map.getCity();
        query.append((details!=null)?"city=" + details + "&amp;":"");</span></pre>
<pre><span style="color:#0000ff;">        details = map.getState();
        query.append((details!=null)?"state=" + details + "&amp;":"");</span></pre>
<pre><span style="color:#0000ff;">        details = map.getZip();
        query.append((details!=null)?"zip=" + details + "&amp;":"");</span></pre>
<pre><span style="color:#0000ff;">        details = map.getLatitude();
        query.append((details1!=null)?"latitude=" + details1 + "&amp;":"");</span></pre>
<pre><span style="color:#0000ff;">        details = map.getLongitude();
        query.append((details!=null)?"longitude=" + details + "&amp;":"");</span></pre>
<pre><span style="color:#0000ff;">        renderMap(query.toString());
    }</span></pre>
<pre><span style="color:#0000ff;">    private void renderMap(String query)
    {   if (query.length() &gt; 0)
        {   try {
                query = query.replace(" ", "+");
                String requestquery = "http://local.yahooapis.com/MapsService/V1/mapImage?appid=[my-app-id]" + query;
                HttpClient client = new HttpClient();
                GetMethod method = new GetMethod(requestquery);
                int statusCode = client.executeMethod(method);
                if (statusCode != HttpStatus.SC_OK)
                {   FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERTY_ERROR, "Unable to find map based on details!", "Unable to find map based on details!"));
                    showMap = false;
                    return;
                }
                InputStream rstream = method.getResponseBodyAsStream();
                BufferedReader br = new BufferedReader(new InputStreamReader(rstream));
		String line;
		int i = 0;
		while ((line = br.readLine()) != null)
                {   if (i == 1 &amp;&amp; line.contains("Result"))
                    {   mapURL = line.substring(62, line.length() - 9);
                        showMap = true;
                    }
                    i++;
		}
            } catch (IOException ex)
            {   ex.printStackTrace();
            }
        }
    }
}</span></pre>
<p>The REST Get request is being placed using the Apache Commons <a href="http://hc.apache.org/httpclient-3.x/">HTTPClient</a> library. The response from REST Get call is striped to fetch only the URL which displays the actual image of the Map.</p>
<p>3) Define and implement a XHTML page which defines a the view for accepting the location details and a rendering panel which is displayed if the map is successfully retrieved.</p>
<pre><span style="color:#0000ff;">&lt;ui:define name="content"&gt;
    &lt;h:form&gt;
        &lt;h:messages/&gt;
        &lt;p:panel header="View Map"&gt;
          &lt;h:panelGrid columns="2"&gt;
             &lt;h:outputLabel value="Street :" for="street"&gt;&lt;/h:outputLabel&gt;
             &lt;h:inputText id="street" value="#{mapController.map.street}"/&gt;

             &lt;!-- Other input fields with labels accordingly --&gt;

            &lt;h:panelGroup&gt;
             &lt;h:commandButton action="#{mapController.renderMapByAddress}" value="Show Map" /&gt;
            &lt;/h:panelGroup&gt;
          &lt;/h:panelGrid&gt;
        &lt;/p:panel&gt;
        &lt;p:panel header="Map" rendered="#{mapController.showMap}"&gt;
           &lt;h:panelGrid columns="1"&gt;
              &lt;h:graphicImage value="#{mapController.mapURL}"/&gt;
           &lt;/h:panelGrid&gt;
        &lt;/p:panel&gt;
     &lt;/h:form&gt;
 &lt;/ui:define&gt;</span></pre>
<p>The graphicImage from JSF HTML taglib displays the URL generated image. One can also use the PrimeFaces <a href="http://97.107.138.40:8080/prime-showcase/ui/dynamicImage.jsf">dynamicImage</a> Streaming (with StreamedContent)</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/schakrap.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/schakrap.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/schakrap.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/schakrap.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/schakrap.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/schakrap.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/schakrap.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/schakrap.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/schakrap.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/schakrap.wordpress.com/90/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=schakrap.wordpress.com&blog=8134677&post=90&subd=schakrap&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://schakrap.wordpress.com/2009/08/04/playing-with-yahoo-maps-on-primefaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e526c33330ecec972667ecd95501d513?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shrihari</media:title>
		</media:content>
	</item>
	</channel>
</rss>