<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Tejus's Blog</title>
	
	<link>http://www.vijedi.net</link>
	<description>Living the startup life in Atlanta, GA.</description>
	<lastBuildDate>Wed, 25 Aug 2010 11:55:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/vijedinet" /><feedburner:info uri="vijedinet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Evaluating Vaadin: A Java Web Application Framework</title>
		<link>http://feedproxy.google.com/~r/vijedinet/~3/tJHN0X4jFz8/</link>
		<comments>http://www.vijedi.net/2010/evaluating-vaadin-a-java-web-application-framework/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 19:54:53 +0000</pubDate>
		<dc:creator>Tejus Parikh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[ria]]></category>
		<category><![CDATA[Vaadin]]></category>

		<guid isPermaLink="false">http://www.vijedi.net/?p=531</guid>
		<description><![CDATA[Vaadin is an interesting RIA platform built by Vaadin, LTD. Vaadin differs from your standard RIA by existing almost exclusively on the server. All application state remains on the server and all events are handled through communication with the server. The display layer is written as a layer above GWT and the whole project is ]]></description>
			<content:encoded><![CDATA[<p><a href="http://vaadin.com">Vaadin</a> is an interesting RIA platform built by Vaadin, LTD. Vaadin differs from your standard RIA by existing almost exclusively on the server. All application state remains on the server and all events are handled through communication with the server. The display layer is written as a layer above GWT and the whole project is open source and free. This evaluation post is the first in a series of my lessons learned while evaluating this framework.</p>
<p>Vaadin is a good fit for all the web-applications that fit in the general bucket of &#8220;enterprise support tools.&#8221; The reasons why are covered after the jump.</p>
<p><span id="more-531"></span></p>
<h3>What&#8217;s special about it?</h3>
<p>I think the biggest departure from the frameworks that I&#8217;ve been using for web programming is that Vaadin is stateful. The client state is tied in the session with a state on the server. This has some major implications for deployment, such as requiring sticky-sessions in load-balancing and shared caches for failover. </p>
<p>The developers of Vaadin made the framework stateful to facilitate building all the interaction code on server. The browser is only used for display. This means that you can use your ordinary Java toolset to walk through your event handling. You don&#8217;t need firebug or any javascript knowledge, unless you are creating a custom widget. The <a href="http://vaadin.com/book/-/page/preface.html">Book of Vaadin</a> provides lots of detail on this model in their <a href="http://vaadin.com/book/-/page/architecture.html">chapter on Architecture</a>.</p>
<p>I have no desire to repeat the documentation here, but just provide enough of a glimpse in case you are more interested.</p>
<h3>Would I use it?</h3>
<p>I think Vaadin fits in nicely within a specific niche. I would not use it for a normal website (nor do they recommend it), nor would I use it for a consumer-facing or heavily trafficked web application. The stateful model just doesn&#8217;t scale like that. </p>
<p>However, there&#8217;s a whole other class of applications, management consoles, intranet web-apps and other systems that could just live on one server that are a perfect fit for Vaadin. Even more so if you can control which browsers the users run (IE javascript is really slow). These are the things that I really liked about the product:</p>
<ul>
<li>Complete documentation. You don&#8217;t have to dig through a user-generated wiki. They have the whole book up on the website.</li>
<li>Friendly forums. A search shows multiple people that had the same problem. Instead of the usual, &#8220;use the search function,&#8221; that you see on a lot of other forums, there were real replies.</li>
<li>All java. A developer can build an entire web-application with just Java. That&#8217;s really important if web-application programming isn&#8217;t a core competency.</li>
<li>Doing things the Vaadin way is really easy. For instance, the <a href="http://vaadin.com/addon/hbncontainer">hbncontainer</a> makes building an app around hibernate trivial.</li>
<li>The widgets really work like their desktop equivalents. The table responds to keystrokes and the split panels work.</li>
<li>Vaadin hides the complexities of layouts on the web. You just specify your container strategy.</li>
</ul>
<h3>Were there problems?</h3>
<p>While Vaadin is pretty easy and built on a language I&#8217;m familiar with, there was still a learning curve. Most of my issues came from doing things outside of the Vaadin way.</p>
<ul>
<li>Vaadin and Maven don&#8217;t seem to get along too well. Trying to install the <a href="http://vaadin.com/addon/visualizationsforvaadin">Visualizations</a> plugin was a nightmare. Eventually I had to install it and its dependent sources into my test project to build the widget set.</li>
<li>Documentation and examples on how to leverage your existing DAO layers was sparse and incomplete.</li>
<li>The same goes for Spring integration, esp Spring Security.</li>
</ul>
<h3>Conclusion</h3>
<p>If had to build a web app and didn&#8217;t have a web team, Vaadin is good way to go. You can build apps that have more than the basic &#8220;developer&#8221; look and feel without a whole lot of effort. The documentation lapses will surely disappear as the framework gains steam. </p>
<p>The next post I&#8217;m going to write is about how to use your existing DAO structure with Vaadin.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.vijedi.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.vijedi.net/2010/evaluating-vaadin-a-java-web-application-framework/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.vijedi.net/2010/evaluating-vaadin-a-java-web-application-framework/</feedburner:origLink></item>
		<item>
		<title>Creating a Custom XSLT Function in Saxon HE</title>
		<link>http://feedproxy.google.com/~r/vijedinet/~3/JJJFXIhPGhI/</link>
		<comments>http://www.vijedi.net/2010/creating-a-custom-xslt-function-in-saxon-he/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 13:31:13 +0000</pubDate>
		<dc:creator>Tejus Parikh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[saxon]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.vijedi.net/?p=511</guid>
		<description><![CDATA[One of the missing features of Saxon HE is the seamless, reflection based integration of plugins. However, one can use the Extension Function API to achieve the same results. This post describes how it's done]]></description>
			<content:encoded><![CDATA[<p>In our XSTL workflow we make use of a lot of XPATH 2.0 features, such as it&#8217;s built-in regex support. Unfortunately, the default Java6 XML parsers only support XPATH 1.0.  The library we settled on is <a href="http://saxon.sourceforge.net/#F9.2HE">Saxon HE</a>, since it was free, supported the features we needed, and could be extended with Java functions.</p>
<p>One of my tasks was to convert all relative paths in an XHTML document to absolute paths. The server prefix was set as variable in the stylesheet. The transformer would have to determine if the selected path is a relative url, then work to resolve what the absolute path is based on the root passed into the page. It could be done with an advanced XSTL template, but since we already had the resolution function written in Java, it made more sense to write a Java plugin to Saxon. One of the missing features of Saxon HE is the seamless, reflection based integration of plugins. However, one can use the Extension Function API to achieve the same results.<br />
<span id="more-511"></span><br />
First on the agenda is creating an extension point:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">net.vijedi.saxon.extensions</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.saxon.expr.StaticProperty</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.saxon.expr.XPathContext</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.saxon.functions.ExtensionFunctionCall</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.saxon.functions.ExtensionFunctionDefinition</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.saxon.om.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.saxon.trans.XPathException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.saxon.value.SequenceType</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.saxon.value.StringValue</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AbsolutizeUrl <span style="color: #000000; font-weight: bold;">extends</span> ExtensionFunctionDefinition <span style="color: #009900;">&#123;</span>
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * The function will need a name you can call
     */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> StructuredQName qName <span style="color: #339933;">=</span>
            <span style="color: #000000; font-weight: bold;">new</span> StructuredQName<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span>, 
                    <span style="color: #0000ff;">&quot;http://vijedi.net/&quot;</span>, 
                    <span style="color: #0000ff;">&quot;absolutizeUrl&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> StructuredQName getFunctionQName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> qName<span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The extension point extends <code>ExtensionFunctionDefinition</code>. I went ahead and created a constant that will store the name of the class and the function to return it. You will use this to access the function from inside of your XSLT.</p>
<p>Now it&#8217;s time to think about the interface of this function. The function can take up to two string parameters, the absolute url base, and an optional url to process. The url to process is optional since it is not a requirement that an <code>&lt;a&gt;</code> will have an <code>href</code> attribute. The function will return either a string or null if the second parameter does not exist. This is how you define this interface in the code.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> SequenceType<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> argumentTypes <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SequenceType<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>
        SequenceType.<span style="color: #006633;">SINGLE_STRING</span>,
        SequenceType.<span style="color: #006633;">OPTIONAL_STRING</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
@Override
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getMinimumNumberOfArguments<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
@Override
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getMaximumNumberOfArguments<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
@Override
<span style="color: #000000; font-weight: bold;">public</span> SequenceType<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getArgumentTypes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> argumentTypes<span style="color: #339933;">;</span>  
<span style="color: #009900;">&#125;</span>
&nbsp;
@Override
<span style="color: #000000; font-weight: bold;">public</span> SequenceType getResultType<span style="color: #009900;">&#40;</span>SequenceType<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> suppliedArgumentTypes<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> SequenceType.<span style="color: #006633;">makeSequenceType</span><span style="color: #009900;">&#40;</span>
            suppliedArgumentTypes<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getPrimaryType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, StaticProperty.<span style="color: #006633;">ALLOWS_ZERO_OR_ONE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Once the interface is defined, it&#8217;s time to define the actual work. The actual call is handled by a class that extends <code>ExtensionFunctionCall</code>. I like to define these as inner classes of the <code>ExtensionFunctionDefinition</code>.  The pattern for this class is pretty simple. You need to process the arguments to the function. Saxon will give you wrapped arguments that you will need to unwrap. Then you need to call the actual logic (which should be in a separate class for re-usability) and finally wrap and return the value.  Just as crucially, you need to override the function that tells the Saxon parser to use your implementation of <code>ExtensionFunctionCall</code> for this definition.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @Override
    <span style="color: #000000; font-weight: bold;">public</span> ExtensionFunctionCall makeCallExpression<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> AbsolutizeUrlCall<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> AbsolutizeUrlCall <span style="color: #000000; font-weight: bold;">extends</span> ExtensionFunctionCall <span style="color: #009900;">&#123;</span>
&nbsp;
        @Override
        <span style="color: #000000; font-weight: bold;">public</span> SequenceIterator call<span style="color: #009900;">&#40;</span>SequenceIterator<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> arguments, XPathContext xPathContext<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> XPathException <span style="color: #009900;">&#123;</span>
&nbsp;
            StringValue pageUrlSV <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>StringValue<span style="color: #009900;">&#41;</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">==</span> pageUrlSV<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> EmptyIterator.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            StringValue hrefUrlSV <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arguments.<span style="color: #006633;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                hrefUrlSV <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>StringValue<span style="color: #009900;">&#41;</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">==</span> hrefUrlSV<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">return</span> EmptyIterator.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #003399;">String</span> pageUrl <span style="color: #339933;">=</span> pageUrlSV.<span style="color: #006633;">getStringValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">String</span> hrefUrl <span style="color: #339933;">=</span> hrefUrlSV.<span style="color: #006633;">getStringValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// Url transformation magic goes here</span>
&nbsp;
            Item item <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StringValue<span style="color: #009900;">&#40;</span>fullUrl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">return</span> SingletonIterator.<span style="color: #006633;">makeIterator</span><span style="color: #009900;">&#40;</span>item<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>That completes the definition of the function. You can find the full example code on <a href="http://gist.github.com/487428">GitHub</a>.</p>
<p>Now that you&#8217;ve written an extension, you need to tell Saxon that this function exists. For this, you will need to add the following to wherever you are currently accessing the <code>TransformerFactory</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> TransformerFactory getTransformerFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> net.<span style="color: #006633;">sf</span>.<span style="color: #006633;">saxon</span>.<span style="color: #006633;">trans</span>.<span style="color: #006633;">XPathException</span> <span style="color: #009900;">&#123;</span>
    TransformerFactory tFactory <span style="color: #339933;">=</span> TransformerFactory.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>tFactory <span style="color: #000000; font-weight: bold;">instanceof</span> TransformerFactoryImpl<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        TransformerFactoryImpl tFactoryImpl <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TransformerFactoryImpl<span style="color: #009900;">&#41;</span> tFactory<span style="color: #339933;">;</span>
        net.<span style="color: #006633;">sf</span>.<span style="color: #006633;">saxon</span>.<span style="color: #006633;">Configuration</span> saxonConfig <span style="color: #339933;">=</span> tFactoryImpl.<span style="color: #006633;">getConfiguration</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        saxonConfig.<span style="color: #006633;">registerExtensionFunction</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> AbsolutizeUrl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">return</span> tFactory<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This code checks to see whether or not you&#8217;re using a Saxon processor, and if so, registers your new function within it.</p>
<p>Finally, it&#8217;s time to update the stylesheet to use the new function. You&#8217;ll need to add the function to the namespace, using the same parameter found in the second argument of the <code>StructuredQName</code> constructor.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:stylesheet</span> <span style="color: #000066;">xmlns:xsl</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/XSL/Transform&quot;</span> <span style="color: #000066;">xmlns:vn</span>=<span style="color: #ff0000;">&quot;http://vijedi.net/&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Now you can use it like any other function:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;href&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value</span> -of <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;vn:absolutizeUrl('http://www.example.com/absolutepath', @href)&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:attribute<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.vijedi.net/2010/creating-a-custom-xslt-function-in-saxon-he/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijedi.net/2010/creating-a-custom-xslt-function-in-saxon-he/</feedburner:origLink></item>
		<item>
		<title>Keeping Test Emails out of the Wild In Rails</title>
		<link>http://feedproxy.google.com/~r/vijedinet/~3/BfL63N5-LeY/</link>
		<comments>http://www.vijedi.net/2010/keeping-test-emails-out-of-the-wild-in-rails/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 03:24:47 +0000</pubDate>
		<dc:creator>Tejus Parikh</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[actionmailer]]></category>
		<category><![CDATA[mail_safe]]></category>
		<category><![CDATA[sanitize_mail]]></category>

		<guid isPermaLink="false">http://www.vijedi.net/?p=504</guid>
		<description><![CDATA[There are a few cardinal sins for a developer: deleting the production database, deploying code to the wrong machine, and sending out emails to all the mock users. These situations happen because the terminal window on production looks an awful lot like the terminal window on dev. I don&#8217;t have solutions to the first two ]]></description>
			<content:encoded><![CDATA[<p>There are a few cardinal sins for a developer: deleting the production database, deploying code to the wrong machine, and sending out emails to all the mock users. These situations happen because the terminal window on production looks an awful lot like the terminal window on dev.  I don&#8217;t have solutions to the first two problems, but preventing emails to the test user database is pretty easy in Ruyb on Rails.<br />
<span id="more-504"></span><br />
Two solutions I&#8217;ve found are <a href="http://github.com/pboling/sanitize_email">santize_email</a> and <a href="http://github.com/myronmarston/mail_safe">mail_safe</a>.  These are both ActiveRecord extensions that allow the user to set an override address that will be the recipient of the email.</p>
<p><code>Sanitize_email</code> is the first solution I tried.  It&#8217;s configuration is straight forward and it can either be installed as a plugin or gem. Personally, I like gems because they can be shared across multiple projects. Once you&#8217;ve installed the gem, you need to configure an initializer with the following (from their README):</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    <span style="color:#008000; font-style:italic;"># Settings for sanitize_email gem.  These can be overridden in individual config/%env%/environment.rb files.</span>
&nbsp;
    <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'sanitize_email'</span>
    <span style="color:#6666ff; font-weight:bold;">ActionMailer::Base</span>.<span style="color:#9900CC;">sanitized_recipients</span> = <span style="color:#996600;">&quot;jtrupiano@gmail.com&quot;</span>
    <span style="color:#6666ff; font-weight:bold;">ActionMailer::Base</span>.<span style="color:#9900CC;">sanitized_bcc</span> = <span style="color:#0000FF; font-weight:bold;">nil</span>
    <span style="color:#6666ff; font-weight:bold;">ActionMailer::Base</span>.<span style="color:#9900CC;">sanitized_cc</span> = <span style="color:#0000FF; font-weight:bold;">nil</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># optionally, you can configure sanitize_email to to include the &quot;real&quot; email address as the 'user name' of the</span>
    <span style="color:#008000; font-style:italic;"># &quot;sanitized&quot; email (e.g. &quot;real@address.com &lt;sanitized @email.com&gt;&quot;)</span>
    <span style="color:#6666ff; font-weight:bold;">ActionMailer::Base</span>.<span style="color:#9900CC;">use_actual_email_as_sanitized_user_name</span> = <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#008000; font-style:italic;"># defaults to false</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># These are the environments whose outgoing email BCC, CC and recipients fields will be overridden!</span>
    <span style="color:#008000; font-style:italic;"># All environments not listed will be treated as normal.</span>
    <span style="color:#6666ff; font-weight:bold;">ActionMailer::Base</span>.<span style="color:#9900CC;">local_environments</span> = <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span> development test staging <span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006600; font-weight:bold;">&lt;/</span>sanitized<span style="color:#006600; font-weight:bold;">&gt;</span></pre></div></div>

<p>You can set the configuration to override the recipients, the cc, and the bcc.  One could use <code>sanitize_email</code> to automatically set a bcc for all production emails, along with setting all three to prevent emails from going into the wild.  Another neat feature is that it provides all Mailers with the <code>force_sanitize</code> method, which programmatically traps emails through a specific path.</p>
<p><code>Mail_safe</code> is available strictly as a gem.  It&#8217;s configuration is a little simpler.  The following is the basic config from their README:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#9966CC; font-weight:bold;">defined</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#6666ff; font-weight:bold;">MailSafe::Config</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#6666ff; font-weight:bold;">MailSafe::Config</span>.<span style="color:#9900CC;">internal_address_definition</span> = <span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#006600; font-weight:bold;">*</span>@my<span style="color:#006600; font-weight:bold;">-</span>domain\.<span style="color:#9900CC;">com</span><span style="color:#006600; font-weight:bold;">/</span>i
    <span style="color:#6666ff; font-weight:bold;">MailSafe::Config</span>.<span style="color:#9900CC;">replacement_address</span> = <span style="color:#996600;">'me@my-domain.com'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>It doesn&#8217;t allow distinct addresses for bcc, cc, and recipients, preventing it&#8217;s use for automatic override addresses.  While it lacks that feature, it does allow addresses for white-listed domains to be delivered, as well as allowing users to provide a proc for the options settings.  For example:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    <span style="color:#6666ff; font-weight:bold;">MailSafe::Config</span>.<span style="color:#9900CC;">internal_address_definition</span> = <span style="color:#CC0066; font-weight:bold;">lambda</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>address<span style="color:#006600; font-weight:bold;">|</span>
      address =~ <span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#006600; font-weight:bold;">*</span>@domain1\.<span style="color:#9900CC;">com</span><span style="color:#006600; font-weight:bold;">/</span>i <span style="color:#006600; font-weight:bold;">||</span>
      address =~ <span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#006600; font-weight:bold;">*</span>@domain2\.<span style="color:#9900CC;">com</span><span style="color:#006600; font-weight:bold;">/</span>i <span style="color:#006600; font-weight:bold;">||</span>
      address == <span style="color:#996600;">'full-address@domain.com'</span>
    <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># Useful if your mail server allows + dynamic email addresses like gmail.</span>
    <span style="color:#6666ff; font-weight:bold;">MailSafe::Config</span>.<span style="color:#9900CC;">replacement_address</span> = <span style="color:#CC0066; font-weight:bold;">lambda</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>address<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#996600;">&quot;my-address+#{address.gsub(/[<span style="color:#000099;">\w</span><span style="color:#000099;">\-</span>.]/, '_')}@gmail.com&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>Our choice was to use <code>mail_safe</code> since it did allow white-listed domains to be delivered normally. This fit the feature set of giving us a safety net incase our mock data got pushed to a system with a live mail-server, while still enabling our test users to use the application.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.vijedi.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.vijedi.net/2010/keeping-test-emails-out-of-the-wild-in-rails/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.vijedi.net/2010/keeping-test-emails-out-of-the-wild-in-rails/</feedburner:origLink></item>
		<item>
		<title>Manually Set the Terminal Title in OSX</title>
		<link>http://feedproxy.google.com/~r/vijedinet/~3/LybWiCuMGNs/</link>
		<comments>http://www.vijedi.net/2010/manually-set-the-terminal-title-in-osx/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 14:42:02 +0000</pubDate>
		<dc:creator>Tejus Parikh</dc:creator>
				<category><![CDATA[OSX/Apple]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://www.vijedi.net/?p=506</guid>
		<description><![CDATA[Having the process automatically set the name of the terminal in OSX almost never works for me. A little googling turned up the bash sequence for setting the process name in the terminal. echo -n -e &#34;\033]0;TerminalName\007&#34; This command will set the name of the terminal to &#8220;TerminalName.&#8221; Instead of trying to remember this string, ]]></description>
			<content:encoded><![CDATA[<p>Having the process automatically set the name of the terminal in OSX almost never works for me. A little googling turned up the bash sequence for setting the process name in the terminal.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">echo -n -e &quot;\033]0;TerminalName\007&quot;</pre></div></div>

<p>This command will set the name of the terminal to &#8220;TerminalName.&#8221;</p>
<p>Instead of trying to remember this string, I created a little shellscript:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">#!/bin/bash
&nbsp;
echo -n -e &quot;\033]0;$1\007&quot;</pre></div></div>

<p>I called this script <code>setname</code> and put it in <code>/usr/local/bin</code>.  Then you can call it with:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">setname TerminalName</pre></div></div>

<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.vijedi.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.vijedi.net/2010/manually-set-the-terminal-title-in-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijedi.net/2010/manually-set-the-terminal-title-in-osx/</feedburner:origLink></item>
		<item>
		<title>Using Java Enums to Return Collections of Other Enums</title>
		<link>http://feedproxy.google.com/~r/vijedinet/~3/UrinGklqb5Y/</link>
		<comments>http://www.vijedi.net/2010/using-java-enums-to-return-collections-of-other-enums/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 15:20:41 +0000</pubDate>
		<dc:creator>Tejus Parikh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[enum]]></category>
		<category><![CDATA[hierarchy]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[settings]]></category>

		<guid isPermaLink="false">http://www.vijedi.net/?p=501</guid>
		<description><![CDATA[I really like Java enums as a way to organize and consolidate all the string constants that come with building systems with a lot of settings files. In our case in particular, we have an ETL process that moves data between sources that have no knowledge of each other. All checks to ensure that there ]]></description>
			<content:encoded><![CDATA[<p>I really like Java <code>enums</code> as a way to organize and consolidate all the string constants that come with building systems with a lot of settings files. In our case in particular, we have an ETL process that moves data between sources that have no knowledge of each other.  All checks to ensure that there are only valid values in each system need to happen in the Java code.  <code>Enums</code> are perfect for this, but some of our settings are hierarchical and it&#8217;s a little unclear how this would work in code.<br />
<span id="more-501"></span></p>
<p>Our lexicon looks a little like this: </p>
<pre>
music
 \
    jazz
    pop
    funk
    blues
    rock
|
article
 \
    blog
    feature
    review
|
video
 \
    music
    interview
    comedy
</pre>
<p>Creating an <code>enum</code> for the top level is straight-forward:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">enum</span> Scheme <span style="color: #009900;">&#123;</span>
	music, article, video<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>So now how do we get <code>Scheme.music</code> to return the valid values for it&#8217;s subtypes?  First we need to create a marker interface:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> SchemeClass <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>You can add abstract methods on an <code>enum</code>, so we can create a method that will return an array of SchemeClasses:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">enum</span> Scheme <span style="color: #009900;">&#123;</span>
	music, article, video<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #000000; font-weight: bold;">public</span> SchemeClass<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getClasses<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And while we&#8217;re at it, lets create the enums for the sub-categories (consolidated here, but in practice I put them in different files):</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">enum</span> MusicClasses implments SchemeClasses <span style="color: #009900;">&#123;</span>
    jazz, pop, funk, blues, rock<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">enum</span> ArticlesClasses <span style="color: #000000; font-weight: bold;">implements</span> SchemeClasses <span style="color: #009900;">&#123;</span>
    blog, feature, review<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">enum</span> VideoClasses <span style="color: #000000; font-weight: bold;">implements</span> SchemeClasses <span style="color: #009900;">&#123;</span>
    music, interview, comedy<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The important thing is that all of these enums implement the <code>SchemeClass</code> interface. Now to get the <code>Scheme</code> enums to return the list of valid subtypes.</p>
<p>Now all that&#8217;s left is implementing the abstract method for each of the possible values in <code>Scheme</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">enum</span> Scheme <span style="color: #009900;">&#123;</span>
    music <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">public</span> SchemeClass<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getClasses<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> MusicClasses.<span style="color: #006633;">values</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>,
    article <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">public</span> SchemeClass<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getClasses<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> ArticleClasses.<span style="color: #006633;">values</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>,
    video <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">public</span> SchemeClass<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getClasses<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> VideoClasses.<span style="color: #006633;">values</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #000000; font-weight: bold;">public</span> SchemeClass<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getClasses<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.vijedi.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.vijedi.net/2010/using-java-enums-to-return-collections-of-other-enums/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.vijedi.net/2010/using-java-enums-to-return-collections-of-other-enums/</feedburner:origLink></item>
		<item>
		<title>JBoss Hot-Deploy With Maven</title>
		<link>http://feedproxy.google.com/~r/vijedinet/~3/NwYEEvBOxps/</link>
		<comments>http://www.vijedi.net/2010/jboss-hot-deploy-with-maven/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 15:06:27 +0000</pubDate>
		<dc:creator>Tejus Parikh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[hotdeploy]]></category>
		<category><![CDATA[intellij]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[webapps]]></category>

		<guid isPermaLink="false">http://www.vijedi.net/?p=496</guid>
		<description><![CDATA[If you&#8217;re a web-developer, one of the best features of Eclipse is the JBoss IDE plugin. The mere fact that you don&#8217;t have to re-compile/re-deploy the war for every change saves countless hours per build. If you don&#8217;t want to use Eclipse, you can replicate this behavior with Maven and run the app out of ]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re a web-developer, one of the best features of <a href="http://www.eclipse.org/">Eclipse</a> is the <a href="http://www.jboss.org/tools">JBoss IDE plugin</a>.    The mere fact that you don&#8217;t have to re-compile/re-deploy the war for every change saves countless hours per build.</p>
<p>If you don&#8217;t want to use Eclipse, you can replicate this behavior with Maven and run the app out of your working directory.<br />
<span id="more-496"></span><br />
The first step is to navigate to the location of your code (hereon referred to as <code>$CODE_DIR</code>) and execute the maven task:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$ mvn war:inplace</pre></div></div>

<p>This will create the entire <code>war</code> structure in <code>$CODE_DIR/src/main/webapp</code>.  Take a look.  You&#8217;ll see a <code>classes</code> and <code>lib</code> directory under <code>WEB-INF</code>.</p>
<p>This is probably a good time to exclude these directories from version control.  I use Git, so I added the following lines to <code>.gitignore</code> at the top level of the project:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">src/main/resources/webapp/WEB-INF/classes
src/main/resources/webapp/WEB-INF/lib</pre></div></div>

<p>Now that you have a complete <code>war</code> you can have it deployed in jboss by creating a symlink.  Assuming that <code>$JBOSS_HOME</code> is set, you need the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">ln -s $CODE_DIR/src/main/webapp $JBOSS_HOME/server/default/deploy/web.war</pre></div></div>

<p>Startup JBoss and you can now edit your non-compiled resources, like Javascript, JSPs and CSS at will, without a compile/deploy cycle.  </p>
<p>If you want similar behavior for changes to code or libraries, there&#8217;s just one more step.  Running:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">mvn compile war:inplace</pre></div></div>

<p>on its own won&#8217;t redeploy the classes.  For that, you&#8217;ll need to touch the <code>web.xml</code> file.  You can do this with the maven exec plugin.  This part is Linux/Mac OSX only.  If you&#8217;re on Windows, well you have bigger problems beyond hot-deploy.</p>
<p>Open up <code>$CODE_DIR/pom.xml</code> and add the following lines:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.codehaus.mojo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>exec-maven-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>exec<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executable<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>touch<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executable<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arguments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;argument<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>src/main/webapp/WEB-INF/web.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/argument<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/arguments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Now running <code>mvn compile war:inplace exec:exec</code> will redeploy the project right from your working directory.  I have this configuration mapped to a keystroke in Intellij to make the process seamless.</p>
<p>The benefits of this approach is that it will work with any IDE or development environment.  It also works with JBoss 4.2 and 5.0 (JBoss tools has had some issues with 5.0 because of the VFS changes).  It also works every time.  JBoss tools would occasionally not update static files.</p>
<p>The downside is that it&#8217;s not as seamless nor as fast.  It will redeploy the webapp, just as if you had pushed a new war. </p>
<p>The time savings are still substantial and I would give this approach a try if you use an environment other than eclipse for your java development.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.vijedi.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.vijedi.net/2010/jboss-hot-deploy-with-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijedi.net/2010/jboss-hot-deploy-with-maven/</feedburner:origLink></item>
		<item>
		<title>Splitting Personalities</title>
		<link>http://feedproxy.google.com/~r/vijedinet/~3/bzaytOWUkF0/</link>
		<comments>http://www.vijedi.net/2010/splitting-personalities/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 04:43:51 +0000</pubDate>
		<dc:creator>Tejus Parikh</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[personal]]></category>

		<guid isPermaLink="false">http://www.vijedi.net/?p=494</guid>
		<description><![CDATA[Iâ€™m not a software developer, entrepreneur, or engineer. Thatâ€™s just what I do. Thereâ€™s a lot that Iâ€™m interested in beyond my work. For the longest time, my online presence has been at ViJedi.net. However, in the era of micro-blogging and increased social interaction on the web, Iâ€™ve found myself holding back from posting things ]]></description>
			<content:encoded><![CDATA[<p>Iâ€™m not a software developer, entrepreneur, or engineer.  Thatâ€™s just what I do.  Thereâ€™s a lot that Iâ€™m interested in beyond my work.  For the longest time, my online presence has been at <a href="http://www.vijedi.net">ViJedi.net</a>.  However, in the era of micro-blogging and increased social interaction on the web, Iâ€™ve found myself holding back from posting things that I find interesting.  Iâ€™m always faced with the fact that half my audience doesnâ€™t really care that I went to park and took some pictures.  The other half doesnâ€™t care that Slicehost rocks or are interested in a new Spring MVC trick.</p>
<p>So from today on, ViJedi.net will be about software, technology, the software development process and other startup-y topics.  All my personal posts, like pictures, random thoughts and the rest will be at a new blog <a href="http://tejus.tumblr.com">tejus.tumblr.com</a>.  Thanks for reading.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.vijedi.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.vijedi.net/2010/splitting-personalities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijedi.net/2010/splitting-personalities/</feedburner:origLink></item>
		<item>
		<title>Dear Eclipse</title>
		<link>http://feedproxy.google.com/~r/vijedinet/~3/bJEjf28YQX0/</link>
		<comments>http://www.vijedi.net/2010/dear-eclipse/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 19:44:07 +0000</pubDate>
		<dc:creator>Tejus Parikh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[intellij]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://www.vijedi.net/?p=489</guid>
		<description><![CDATA[It&#8217;s over, we&#8217;re done. No need to come by and collect your stuff. Your workspace is already in the trash. There&#8217;s no trace you were even here. I still remember when I first gave you a shot. I had tried other IDE&#8217;s, but all they seemed to offer where headaches. Vim and Ant simply worked ]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s over, we&#8217;re done. No need to come by and collect your stuff.  Your workspace is already in the trash.  There&#8217;s no trace you were even here. </p>
<p>I still remember when I first gave you a shot.  I had tried other IDE&#8217;s, but all they seemed to offer where headaches.  Vim and Ant simply worked better.  </p>
<p>But then you came along, with compile as you type and amazing CVS integration.  Suddenly, my collection of a half dozen command line utilities were reduced to one.  I was so taken with SWT and it&#8217;s ability to look native on each platform, that I even wrote an entire application in it.</p>
<p>My love only grew when I took a professional development job.  I had to use Windows, you made it possible to get something done.  But looking back, that&#8217;s also when our relationship started to crack.  We switched from CVS to SVN, negating one of the greatest advantages you had.</p>
<p>I switched jobs again and this time I was introduced to Intellij IDEA.  Sure it was nice, but it didn&#8217;t compare to you.  It&#8217;s version control integration was confusing.  It didn&#8217;t support all features and languages you did, and it&#8217;s auto-compile just didn&#8217;t work as nicely.  I stuck with you.</p>
<p>But the cracks that appeared earlier started growing.  Each new feature you supported and every new plugin written for you never seemed to work right.  Everything had rough edges, caveats, and felt distinct from everything else in the system.  </p>
<p>You just didn&#8217;t take care of yourself.  As computers got faster, you got slower.  Every editor seems slow to respond to keyboard input.  The XML editor is the single worst editor I have ever used.  Typing in your IDE shouldn&#8217;t feel like telneting over a dial-up connection. You started bloating up to the size of a beached whale in a sad attempt to be everything to everyone.  While you allowed everyone to attach to you, you forgot about what made you great in the first place, Java development.</p>
<p>You didn&#8217;t keep up with the best practices.  You don&#8217;t work well with maven projects.  Refactoring doesn&#8217;t work across the entire workspace. You should never ask me for the location of the source for a class when it is in your workspace.  It&#8217;s 2010, these are things you should do right by now.</p>
<p>One of your great features was the ability to use external editors for resources managed by the IDE.  Unfortunately, whether or not that file was refreshed in the workspace seemed like a decision that rested in God&#8217;s hands.</p>
<p>Lets not even talk about version control.  The subclipse/subversive split was a disaster and your git support is a joke.  You once replaced my entire stack of tools.  Now to get anything done, I now have to open a bunch of terminals, <a href="http://gitx.frim.nl/">gitx</a>, <a href="http://macromates.com/">textmate</a>, and you.</p>
<p>Remember that <a href="http://www.jetbrains.com/idea/">other IDE</a> I played around with? It&#8217;s kept itself in shape.  It looks better than it ever has.  It never promised to do everything, and that&#8217;s left it with few wrinkles and sharp edges.  It works with a Maven project structure, has real support for Git, and does a fantastic job of editing Java.  And now it&#8217;s open source too, just like you.</p>
<p>That&#8217;s why it&#8217;s over. It&#8217;s always sad to see something with so much promise ruined by neglect and bloat.  But it is what it is and it&#8217;s time to move on.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.vijedi.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.vijedi.net/2010/dear-eclipse/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.vijedi.net/2010/dear-eclipse/</feedburner:origLink></item>
		<item>
		<title>Sizzle: A Standalone CSS3 Selector Library</title>
		<link>http://feedproxy.google.com/~r/vijedinet/~3/ZqPbtyIzimc/</link>
		<comments>http://www.vijedi.net/2010/sizzle-a-standalone-css3-selector-library/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 04:52:52 +0000</pubDate>
		<dc:creator>Tejus Parikh</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[sizzle]]></category>

		<guid isPermaLink="false">http://www.vijedi.net/?p=482</guid>
		<description><![CDATA[Sometimes a full blown javascript library like JQuery, MooTools, or Dojo is impractical. I just had such a project, but the one feature I could not live without was CSS3 selectors. Walking the DOM manually would have taken hours to implement correctly, especially since each page needed to be treated differently. My first thought was ]]></description>
			<content:encoded><![CDATA[<p>Sometimes a full blown javascript library like <a href="http://www.jquery.com">JQuery</a>, <a href="http://www.mootools.com">MooTools</a>, or <a href="http://www.dojotoolkit.org/">Dojo</a> is impractical.  </p>
<p>I just had such a project, but the one feature I could not live without was CSS3 selectors.  Walking the DOM manually would have taken hours to implement correctly, especially since each page needed to be treated differently.  My first thought was to rip out the JQuery selector functions.  That&#8217;s when I discovered <a href="http://sizzlejs.com/">Sizzle</a>.  </p>
<p>Sizzle is the CSS3 selector engine written by John Resig that was originally written for JQuery and is now also used in Dojo.  Since it&#8217;s a standalone library, you can also use it directly for your projects.  </p>
<p>The first step is simple, you need to include the <a href="http://github.com/jeresig/sizzle/blob/master/sizzle.js">Sizzle js</a> file in your page.  Once you do that, you can call Sizzle just as you would call <code>$</code> in normal JQuery.</p>
<p>Examples:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// get all divs</span>
Sizzle<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div&quot;</span><span style="color: #009900;">&#41;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Get all links in the paragraphs in the sidebar</span>
Sizzle<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#sidebar p a&quot;</span><span style="color: #009900;">&#41;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Get all li elements under a ul</span>
Sizzle<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul &gt; li&quot;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Just like JQuery, right?  Well no.  Unlike JQuery, which returns a JQuery object that can be accessed with JQuery&#8217;s easy and cross browser API&#8217;s.  Sizzle returns a list of elements.  </p>
<p>If you wanted to set the text of the first link element to &#8220;Go To This Page,&#8221; then what you&#8217;d have to do is the following:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> elements <span style="color: #339933;">=</span> Sizzle<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#sidebar p a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
a<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Go To This Page&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If the necessary manipulations are simple, using Sizzle standalone is the way to go.  It&#8217;s much smaller than a full blown JS library and it gives you what&#8217;s normally the most painful part.  </p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.vijedi.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.vijedi.net/2010/sizzle-a-standalone-css3-selector-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijedi.net/2010/sizzle-a-standalone-css3-selector-library/</feedburner:origLink></item>
		<item>
		<title>2009 In Review</title>
		<link>http://feedproxy.google.com/~r/vijedinet/~3/pYiZjlG_0Nw/</link>
		<comments>http://www.vijedi.net/2010/2009-in-review/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 04:20:05 +0000</pubDate>
		<dc:creator>Tejus Parikh</dc:creator>
				<category><![CDATA[Career]]></category>
		<category><![CDATA[2009]]></category>
		<category><![CDATA[journalistics]]></category>
		<category><![CDATA[scoutmob]]></category>
		<category><![CDATA[vertical acuity]]></category>

		<guid isPermaLink="false">http://www.vijedi.net/?p=478</guid>
		<description><![CDATA[It&#8217;s the first work day of the new year and in order to delay heading out into the frigid cold (it&#8217;s about 15 right now), I figure it&#8217;s a good time for a 2009 recap. It was definitely one of the busiest years of my life. The year started normally enough, with both Sonali and ]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s the first work day of the new year and in order to delay heading out into the frigid cold (it&#8217;s about 15 right now), I figure it&#8217;s a good time for a 2009 recap.</p>
<p>It was definitely one of the busiest years of my life.  The year started normally enough, with both Sonali and I working for a large public company.  Unfortunately, it didn&#8217;t take long before the economic meltdown affected them as well and the downsizing started in our division.  This overarching storyline probably made the year seem more stressful than it really was, due to the multiple rounds and the general sense that something wasn&#8217;t quite right as far back as March.  That all ended in September 30th, coincidentally my birthday, when both Sonali and I were let go.  On the upside, I had an interview scheduled for later that afternoon.  On the downside there was a going away lunch, complete with tequila.  More on that later.</p>
<p>While this was all going on, I still needed something to do while building my rails chops and started putting some hours in <a href="http://www.journalistics.com">Journalistics</a> on the nights and weekends.  We&#8217;ve launched <a href="http://www.experttweet.com">one product</a>, and are coming really close to launching the first preview of our main offering.  </p>
<p>Perhaps the biggest work difference in 2009 was some first hand experience on the management and organizational side of product development.  The challenges and solutions are significantly different than development.  The biggest lesson learned is to not come up with a product plan without also coming up with a sales plan.  It doesn&#8217;t matter what you build if you can&#8217;t convince people to use it.</p>
<p>While much of this post focuses on the negative, it was overall a very positive year.  We did some very good work in my time at Premiere and it&#8217;s unfortunate we never got our product out the door.  While the economic conditions resulted in a lay-off on my birthday, it had a happy ending.  The interview was at <a href="http://www.verticalacuity.com">Vertical Acuity</a>, an Atlanta startup building a new syndication model for publishers.  It was a great fit for both parties and I accepted their offer.</p>
<p>2010 finds me back where I want to be, in an small startup working on interesting problems.  Being part of a small team with a lot on the line is very appealing to me.  Also, since I apparently don&#8217;t like to sleep much there&#8217;s aforementioned Journalistics beta and the launch of <a href="http://scoutmob.com">Scoutmob</a>.  It&#8217;s going to be another busy year, but one that should be as enjoyable as 2009.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.vijedi.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.vijedi.net/2010/2009-in-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijedi.net/2010/2009-in-review/</feedburner:origLink></item>
	</channel>
</rss>
