<?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>samaxes</title>
	
	<link>http://www.samaxes.com</link>
	<description>Java developer, Web researcher, and an advocate for web standards and semantic technologies.</description>
	<lastBuildDate>Wed, 01 Feb 2012 02:51:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/samaxes" /><feedburner:info uri="samaxes" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Java EE 6 Testing Part I – EJB 3.1 Embeddable API</title>
		<link>http://feedproxy.google.com/~r/samaxes/~3/YS7npLMbEF8/</link>
		<comments>http://www.samaxes.com/2011/12/javaee-testing-ejb31-embeddable/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 14:32:27 +0000</pubDate>
		<dc:creator>Samuel Santos</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[EJB]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.samaxes.com/?p=267</guid>
		<description><![CDATA[One of the most common requests we hear from Enterprise JavaBeans developers is for improved unit/integration testing support. EJB 3.1 Specification introduced the EJB 3.1 Embeddable API for executing EJB components within a Java SE environment. Unlike traditional Java EE server-based execution, embeddable usage allows client code and its corresponding enterprise beans to run within [...] <a href="http://engine.influads.com/click/4f3f8803e1f1df907a000014"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8803e1f1df907a000014"/></a>]]></description>
			<content:encoded><![CDATA[<p>One of the most common requests we hear from Enterprise JavaBeans developers is for improved unit/integration testing support.<br />
<a href="http://jcp.org/en/jsr/detail?id=318">EJB 3.1 Specification</a> introduced the EJB 3.1 Embeddable API for executing EJB components within a Java SE environment.</p>
<blockquote cite="http://jcp.org/aboutJava/communityprocess/mrel/jsr318/index.html"><p>
Unlike traditional Java EE server-based execution, embeddable usage allows client code and its corresponding enterprise beans to run within the same JVM and class loader. This provides better support for testing, offline processing (e.g. batch), and the use of the EJB programming model in desktop applications.<br />
[...]<br />
The embeddable EJB container provides a managed environment with support for the same basic services that exist within a Java EE runtime: injection, access to a component environment, container-managed transactions, etc. In general, enterprise bean components are unaware of the kind of managed environment in which they are running. This allows maximum reusability of enterprise components across a wide range of testing and deployment scenarios without significant rework.
</p></blockquote>
<p><span id="more-267"></span></p>
<p>Let&#8217;s look at an example.</p>
<p>Start with creating a Maven project and add the embeddable GlassFish dependency.<br />
I&#8217;m also using <a href="http://testng.org/">TestNG</a> instead of <a href="http://www.junit.org/">JUnit</a>.</p>
<pre class="brush: xml; title: pom.xml; notranslate">
&lt;dependencies&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.glassfish.extras&lt;/groupId&gt;
        &lt;artifactId&gt;glassfish-embedded-all&lt;/artifactId&gt;
        &lt;version&gt;3.1.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&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;6.3.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;!--
        The javaee-api is stripped of any code and is just used to
        compile your application. The scope provided in Maven means
        that it is used for compiling, but is also available when
        testing. For this reason, the javaee-api needs to be below
        the embedded Glassfish dependency. The javaee-api can actually
        be omitted when the embedded Glassfish dependency is included,
        but to keep your project Java-EE 6 rather than GlassFish,
        specification is important.
    --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;javax&lt;/groupId&gt;
        &lt;artifactId&gt;javaee-api&lt;/artifactId&gt;
        &lt;version&gt;6.0&lt;/version&gt;
        &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;
</pre>
<p>Here&#8217;s a simple <code>Stateless</code> session bean:</p>
<pre class="brush: java; title: PersonService.java; notranslate">
@Stateless
public class HelloWorld {
    public String hello(String message) {
        return &quot;Hello &quot; + message;
    }
}
</pre>
<p>It exposes business methods through a <a href="http://java.sun.com/developer/technicalArticles/JavaEE/JavaEE6Overview_Part3.html#noiview">no-interface view</a>.<br />
There is no special API it must use to be capable of embeddable execution.</p>
<p>Here is some test code to execute the bean in an embeddable container:</p>
<pre class="brush: java; title: HelloWorldTest.java; notranslate">
public class HelloWorldTest {
    private static EJBContainer ejbContainer;

    private static Context ctx;

    @BeforeClass
    public static void setUpClass() throws Exception {
        // Instantiate an embeddable EJB container and search the
        // JVM class path for eligible EJB modules or directories
        ejbContainer = EJBContainer.createEJBContainer();

        // Get a naming context for session bean lookups
        ctx = ejbContainer.getContext();
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
        // Shutdown the embeddable container
        ejbContainer.close();
    }

    @Test
    public void hello() throws NamingException {
        // Retrieve a reference to the session bean using a portable
        // global JNDI name
        HelloWorld helloWorld = (HelloWorld)
                ctx.lookup(&quot;java:global/classes/HelloWorld&quot;);

        // Do your tests
        assertNotNull(helloWorld);
        String expected = &quot;World&quot;;
        String hello = helloWorld.hello(expected);
        assertNotNull(hello);
        assertTrue(hello.endsWith(expected));
    }
}
</pre>
<p>This code is available on <a href="https://github.com/samaxes/java-ee-testing">GitHub</a> under the folder <code>ejb31-embeddable</code>.<br />
For a step by step tutorial with a JPA example take a look at <a href="http://netbeans.org/kb/docs/javaee/javaee-entapp-junit.html">Using the Embedded EJB Container to Test Enterprise Applications</a> from NetBeans docs.</p>
<p>While this new API is a step forward, I still have an issue with this approach: you are bringing the container to the test. This requires a specialized container which is different from your production environment.</p>
<p>In Part II, I will introduce <a href="http://www.jboss.org/arquillian">Arquillian</a> and <a href="http://www.jboss.org/shrinkwrap">ShrinkWrap</a>.<br />
Arquillian, a powerful container-oriented testing framework layered atop TestNG and JUnit, gives you the ability to create the production environment on the container of your choice and just execute tests in that environment (using the datasources, JMS destinations, and a whole lot of other configurations you expect to see in production environment). Instead of bringing your runtime to the test, Arquillian brings your test to the runtime.</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.samaxes.com/2010/04/maven-2-cobertura-plugin-updated/" title="Maven 2 Cobertura Plugin &#8211; Updated">Maven 2 Cobertura Plugin &#8211; Updated</a></li><li><a href="http://www.samaxes.com/2009/09/test-jboss-microcontainer-services/" title="Unit Testing JBoss 5 Services">Unit Testing JBoss 5 Services</a></li><li><a href="http://www.samaxes.com/2008/01/stripes-and-ejb3/" title="Stripes framework and EJB3">Stripes framework and EJB3</a></li><li><a href="http://www.samaxes.com/2007/06/maven-2-cobertura-plugin/" title="Maven 2 Cobertura Plugin">Maven 2 Cobertura Plugin</a></li><li><a href="http://www.samaxes.com/2010/08/stripes-cross-site-scripting/" title="Stripes framework XSS Interceptor">Stripes framework XSS Interceptor</a></li></ul> <a href="http://engine.influads.com/click/4f3f8caa353b27f54c00000f"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8caa353b27f54c00000f"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/samaxes?a=YS7npLMbEF8:kCCdhfufkUE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/samaxes?i=YS7npLMbEF8:kCCdhfufkUE:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=YS7npLMbEF8:kCCdhfufkUE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/samaxes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=YS7npLMbEF8:kCCdhfufkUE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/samaxes?i=YS7npLMbEF8:kCCdhfufkUE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=YS7npLMbEF8:kCCdhfufkUE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/samaxes?i=YS7npLMbEF8:kCCdhfufkUE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=YS7npLMbEF8:kCCdhfufkUE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/samaxes?i=YS7npLMbEF8:kCCdhfufkUE:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=YS7npLMbEF8:kCCdhfufkUE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/samaxes?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/samaxes/~4/YS7npLMbEF8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.samaxes.com/2011/12/javaee-testing-ejb31-embeddable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.samaxes.com/2011/12/javaee-testing-ejb31-embeddable/</feedburner:origLink></item>
		<item>
		<title>Changing URL parameters with jQuery</title>
		<link>http://feedproxy.google.com/~r/samaxes/~3/JqdljFMNBUY/</link>
		<comments>http://www.samaxes.com/2011/09/change-url-parameters-with-jquery/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 14:32:39 +0000</pubDate>
		<dc:creator>Samuel Santos</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.samaxes.com/?p=255</guid>
		<description><![CDATA[You can find plenty of resources about this topic just by googling the web, most of which will point to jQuery plugins. But the fact is that it&#8217;s so easy to achieve this by simply using jQuery that you do not need a plugin. The code is pretty much self explanatory: You can clearly improve [...] <a href="http://engine.influads.com/click/4f3f8804e1f1df2a7b000015"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8804e1f1df2a7b000015"/></a>]]></description>
			<content:encoded><![CDATA[<p>You can find plenty of resources about this topic just by googling the web, most of which will point to jQuery plugins.<br />
But the fact is that it&#8217;s so easy to achieve this by simply using jQuery that you do not need a plugin.</p>
<p>The code is pretty much self explanatory:</p>
<pre class="brush: jscript; title: ; notranslate">
/*
 * queryParameters -&gt; handles the query string parameters
 * queryString -&gt; the query string without the fist '?' character
 * re -&gt; the regular expression
 * m -&gt; holds the string matching the regular expression
 */
var queryParameters = {}, queryString = location.search.substring(1),
    re = /([^&amp;=]+)=([^&amp;]*)/g, m;

// Creates a map with the query string parameters
while (m = re.exec(queryString)) {
    queryParameters[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}

// Add new parameters or update existing ones
queryParameters['newParameter'] = 'new parameter';
queryParameters['existingParameter'] = 'new value';

/*
 * Replace the query portion of the URL.
 * Query.param() -&gt; create a serialized representation of an array or
 *     object, suitable for use in a URL query string or Ajax request.
 */
location.search = $.param(queryParameters);
</pre>
<p>You can clearly improve the regular expression, but the one above meet my needs.</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.samaxes.com/2010/04/samaxesjs-javascript-library-updates/" title="samaxesJS JavaScript library updates">samaxesJS JavaScript library updates</a></li><li><a href="http://www.samaxes.com/2008/12/stripes-and-jquery-autocomplete/" title="Stripes framework and jQuery Autocomplete">Stripes framework and jQuery Autocomplete</a></li><li><a href="http://www.samaxes.com/2008/10/stripes-and-jquery-ajax-forms-and-http-session-validation/" title="Stripes framework and jQuery: AJAX forms and HTTP Session Validation">Stripes framework and jQuery: AJAX forms and HTTP Session Validation</a></li><li><a href="http://www.samaxes.com/2008/07/samaxesjs-javascript-controls/" title="samaxesJS JavaScript Controls">samaxesJS JavaScript Controls</a></li><li><a href="http://www.samaxes.com/2006/08/ie7-javascript-library/" title="IE7 JavaScript library">IE7 JavaScript library</a></li></ul> <a href="http://engine.influads.com/click/4f3f8caa353b27a04b000012"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8caa353b27a04b000012"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/samaxes?a=JqdljFMNBUY:pmzEmobhH6w:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/samaxes?i=JqdljFMNBUY:pmzEmobhH6w:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=JqdljFMNBUY:pmzEmobhH6w:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/samaxes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=JqdljFMNBUY:pmzEmobhH6w:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/samaxes?i=JqdljFMNBUY:pmzEmobhH6w:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=JqdljFMNBUY:pmzEmobhH6w:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/samaxes?i=JqdljFMNBUY:pmzEmobhH6w:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=JqdljFMNBUY:pmzEmobhH6w:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/samaxes?i=JqdljFMNBUY:pmzEmobhH6w:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=JqdljFMNBUY:pmzEmobhH6w:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/samaxes?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/samaxes/~4/JqdljFMNBUY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.samaxes.com/2011/09/change-url-parameters-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.samaxes.com/2011/09/change-url-parameters-with-jquery/</feedburner:origLink></item>
		<item>
		<title>Improving web performance with Apache and htaccess</title>
		<link>http://feedproxy.google.com/~r/samaxes/~3/Lz8jePcLXLQ/</link>
		<comments>http://www.samaxes.com/2011/05/improving-web-performance-with-apache-and-htaccess/#comments</comments>
		<pubDate>Mon, 23 May 2011 14:44:40 +0000</pubDate>
		<dc:creator>Samuel Santos</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[HTTP]]></category>

		<guid isPermaLink="false">http://www.samaxes.com/?p=251</guid>
		<description><![CDATA[Web performance is getting more and more attention from web developers and is one of the hottest topic in web development. Fred Wilson considered it at 10 Golden Principles of Successful Web Apps as the #1 principle for successful web apps. First and foremost, we believe that speed is more than a feature. Speed is [...] <a href="http://engine.influads.com/click/4f3f8cab353b27ab50000002"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8cab353b27ab50000002"/></a>]]></description>
			<content:encoded><![CDATA[<p>Web performance is getting more and more attention from web developers and is one of the hottest topic in web development.</p>
<dl>
<dt><a href="http://www.avc.com/">Fred Wilson</a> considered it at <a href="http://thinkvitamin.com/web-apps/fred-wilsons-10-golden-principles-of-successful-web-apps/">10 Golden Principles of Successful Web Apps</a> as the #1 principle for successful web apps.</dt>
<dd>
<blockquote><p>First and foremost, we believe that speed is more than a feature. Speed is the most important feature. If your application is slow, people won’t use it.</p></blockquote>
</dd>
<dt>Faster website means more revenue and traffic</dt>
<dd>
<ul>
<li>Amazon: 100 ms of extra load time caused a 1% drop in sales (source: Greg Linden, Amazon).</li>
<li>Google: 500 ms of extra load time caused 20% fewer searches (source: Marrissa Mayer, Google).</li>
<li>Yahoo!: 400 ms of extra load time caused a 5–9% increase in the number of people who clicked &#8220;back&#8221; before the page even loaded (source: Nicole Sullivan, Yahoo!).</li>
</ul>
<p><a href="http://googleresearch.blogspot.com/2009/06/speed-matters.html">Google experiments</a> reached similar results:</p>
<blockquote><p>Our experiments demonstrate that slowing down the search results page by 100 to 400 milliseconds has a measurable impact on the number of searches per user of -0.2% to -0.6% (averaged over four or six weeks depending on the experiment). That&#8217;s 0.2% to 0.6% fewer searches for changes under half a second!</p></blockquote>
<p>And speed is now a factor contributing to Google Page Rank:</p>
<blockquote cite="http://www.stevesouders.com/blog/2010/05/07/wpo-web-performance-optimization/"><p>
Google, in their <a href="http://code.google.com/speed/">ongoing effort to make the Web faster</a>, <a href="http://googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html">blogged</a> last month that “we’ve decided to take site speed into account in our search rankings.” This is yet another way in which improving web performance will have a positive impact on the bottom line.
</p></blockquote>
</dd>
</dl>
<p>The good news is that some of the most important speed optimizations can be easily done with simple <code><a href="http://httpd.apache.org/docs/current/howto/htaccess.html" title=".htaccess tutorial">.htaccess</a></code> rules.<br />
These rules can make any website faster by compressing content and enabling browser cache, and follow the <a href="http://developer.yahoo.com/performance/rules.html" title="Best Practices for Speeding Up Your Web Site">Best Practices for Speeding Up Your Web Site</a> from Yahoo!&#8217;s Exceptional Performance team.</p>
<p><span id="more-251"></span></p>
<h2>Compress content</h2>
<p>Compression reduces response times by reducing the size of the HTTP response.<br />
It&#8217;s worthwhile to gzip your HTML documents, scripts and stylesheets. In fact, it&#8217;s worthwhile to compress any text response including XML and JSON.<br />
Image and PDF files should not be gzipped because they are already compressed. Trying to gzip them not only wastes CPU but can potentially increase file sizes.</p>
<p>To compress your content, Apache 2 comes bundled with the <a href="http://httpd.apache.org/docs/current/mod/mod_deflate.html">mod_deflate</a> module.</p>
<blockquote cite="http://httpd.apache.org/docs/current/mod/mod_deflate.html"><p>The <code>mod_deflate</code> module provides the <code>DEFLATE</code> output filter that allows output from your server to be compressed before being sent to the client over the network.</p></blockquote>
<p>The following rule will gzip all your <code>*.css</code>, <code>*.js</code>, <code>*.html</code>, <code>*.html</code>, <code>*.xhtml</code>, and <code>*.php</code> files:</p>
<pre class="brush: plain; title: ; notranslate">
&lt;ifModule mod_deflate.c&gt;
  AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
&lt;/ifModule&gt;
</pre>
<p>In previous versions of Apache, you can use <a href="http://schroepl.net/projekte/mod_gzip/">mod_gzip</a>.</p>
<h2>Enable browser cache</h2>
<p>Web page designs are getting richer and richer over time, which means more scripts, stylesheets and images in the page. A first-time visitor to your page will make several HTTP requests to download all your sites files, but by using the <code>Expires</code> and <code>Cache-Control</code> headers you make those files cacheable. This avoids unnecessary HTTP requests on subsequent page views.</p>
<p>Apache enables those headers thanks to <a href="http://httpd.apache.org/docs/current/mod/mod_expires.html">mod_expires</a> and <a href="http://httpd.apache.org/docs/current/mod/mod_headers.html">mod_headers</a> modules.</p>
<blockquote cite="http://httpd.apache.org/docs/current/mod/mod_expires.html"><p>
The <code>mod_expires</code> module controls the setting of the <code>Expires</code> HTTP header and the <code>max-age</code> directive of the <code>Cache-Control</code> HTTP header in server responses.<br />
To modify <code>Cache-Control</code> directives other than <code>max-age</code>, you can use the <code>mod_headers</code> module.
</p></blockquote>
<blockquote cite="http://httpd.apache.org/docs/current/mod/mod_headers.html"><p>
The <code>mod_headers</code> module provides directives to control and modify HTTP request and response headers. Headers can be merged, replaced or removed.
</p></blockquote>
<p>Rule for setting <code>Expires</code> headers:</p>
<pre class="brush: plain; title: ; notranslate">
# BEGIN Expire headers
&lt;ifModule mod_expires.c&gt;
  ExpiresActive On
  ExpiresDefault &quot;access plus 5 seconds&quot;
  ExpiresByType image/x-icon &quot;access plus 2592000 seconds&quot;
  ExpiresByType image/jpeg &quot;access plus 2592000 seconds&quot;
  ExpiresByType image/png &quot;access plus 2592000 seconds&quot;
  ExpiresByType image/gif &quot;access plus 2592000 seconds&quot;
  ExpiresByType application/x-shockwave-flash &quot;access plus 2592000 seconds&quot;
  ExpiresByType text/css &quot;access plus 604800 seconds&quot;
  ExpiresByType text/javascript &quot;access plus 216000 seconds&quot;
  ExpiresByType application/javascript &quot;access plus 216000 seconds&quot;
  ExpiresByType application/x-javascript &quot;access plus 216000 seconds&quot;
  ExpiresByType text/html &quot;access plus 600 seconds&quot;
  ExpiresByType application/xhtml+xml &quot;access plus 600 seconds&quot;
&lt;/ifModule&gt;
# END Expire headers
</pre>
<p>Rule for setting <code>Cache-Control</code> headers:</p>
<pre class="brush: plain; title: ; notranslate">
# BEGIN Cache-Control Headers
&lt;ifModule mod_headers.c&gt;
  &lt;filesMatch &quot;\.(ico|jpe?g|png|gif|swf)$&quot;&gt;
    Header set Cache-Control &quot;public&quot;
  &lt;/filesMatch&gt;
  &lt;filesMatch &quot;\.(css)$&quot;&gt;
    Header set Cache-Control &quot;public&quot;
  &lt;/filesMatch&gt;
  &lt;filesMatch &quot;\.(js)$&quot;&gt;
    Header set Cache-Control &quot;private&quot;
  &lt;/filesMatch&gt;
  &lt;filesMatch &quot;\.(x?html?|php)$&quot;&gt;
    Header set Cache-Control &quot;private, must-revalidate&quot;
  &lt;/filesMatch&gt;
&lt;/ifModule&gt;
# END Cache-Control Headers
</pre>
<p><strong>Note 1:</strong> There is no need to set <code>max-age</code> directive with <code>Cache-Control</code> header since it is already set by <code>mod_expires</code> module.<br />
<strong>Note 2:</strong> <code>must-revalidate</code> means that <em>once a response becomes stale</em> it has to be revalidated; it doesn’t mean that it has to be checked every time.</p>
<h2>Disable HTTP ETag header</h2>
<p>ETags were added to provide a mechanism for validating entities that is more flexible than the last-modified date.</p>
<p>The problem with ETags is that they typically are constructed using attributes that make them unique to a specific server hosting a site.<br />
ETags won&#8217;t match when a browser gets the original component from one server and later tries to validate that component on a different server.</p>
<p>In Apache, this is done by simply adding the <code>FileETag</code> directive to your configuration file: </p>
<pre class="brush: plain; title: ; notranslate">
# BEGIN Turn ETags Off
FileETag None
# END Turn ETags Off
</pre>
<h2>Last-Modified header</h2>
<p>In my previous posts I stated that:</p>
<blockquote cite="/2008/04/htaccess-gzip-and-cache-your-site-for-faster-loading-and-bandwidth-saving/"><p>
If you remove the <code>Last-Modified</code> and <code>ETag</code> header, you will totally eliminate <code>If-Modified-Since</code> and <code>If-None-Match</code> requests and their <code>304 Not Modified</code> responses, so a file will stay cached without checking for updates until the Expires header indicates new content is available!
</p></blockquote>
<p>Well, I was wrong and this is why: we still want <code>Last-Modified</code> header for static files. If a user presses the <em>refresh</em> button, then browser will send a conditional request and server will respond a <code>304 Not Modified</code>. If you disable both <code>Last-Modified</code> and <code>ETag</code>, the browser will have to download the whole content again whenever a user presses <em>refresh</em>.</p>
<h2>Merge and minify your static files</h2>
<p>Reducing the number of components in turn reduces the number of HTTP requests required to render the page. This is the key to faster pages.<br />
Minification is the practice of removing unnecessary characters from code to reduce its size thereby improving load times.</p>
<p>See <a href="http://www.samaxes.com/2009/05/combine-and-minimize-javascript-and-css-files-for-faster-loading/">Combine and minimize JavaScript and CSS files for faster loading</a> for more information on this topic.</p>
<h2>Web performance tools</h2>
<p>Always check your changes. Use either <a href="http://developer.yahoo.com/yslow/">YSlow</a> or <a href="http://code.google.com/speed/page-speed/">Page Speed</a> browser plugins.<br />
They are super easy to use and the best tools currently available for the job.</p>
<h2>Final file</h2>
<pre class="brush: plain; title: ; notranslate">
# BEGIN Compress text files
&lt;ifModule mod_deflate.c&gt;
  AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
&lt;/ifModule&gt;
# END Compress text files

# BEGIN Expire headers
&lt;ifModule mod_expires.c&gt;
  ExpiresActive On
  ExpiresDefault &quot;access plus 5 seconds&quot;
  ExpiresByType image/x-icon &quot;access plus 2592000 seconds&quot;
  ExpiresByType image/jpeg &quot;access plus 2592000 seconds&quot;
  ExpiresByType image/png &quot;access plus 2592000 seconds&quot;
  ExpiresByType image/gif &quot;access plus 2592000 seconds&quot;
  ExpiresByType application/x-shockwave-flash &quot;access plus 2592000 seconds&quot;
  ExpiresByType text/css &quot;access plus 604800 seconds&quot;
  ExpiresByType text/javascript &quot;access plus 216000 seconds&quot;
  ExpiresByType application/javascript &quot;access plus 216000 seconds&quot;
  ExpiresByType application/x-javascript &quot;access plus 216000 seconds&quot;
  ExpiresByType text/html &quot;access plus 600 seconds&quot;
  ExpiresByType application/xhtml+xml &quot;access plus 600 seconds&quot;
&lt;/ifModule&gt;
# END Expire headers

# BEGIN Cache-Control Headers
&lt;ifModule mod_headers.c&gt;
  &lt;filesMatch &quot;\.(ico|jpe?g|png|gif|swf)$&quot;&gt;
    Header set Cache-Control &quot;public&quot;
  &lt;/filesMatch&gt;
  &lt;filesMatch &quot;\.(css)$&quot;&gt;
    Header set Cache-Control &quot;public&quot;
  &lt;/filesMatch&gt;
  &lt;filesMatch &quot;\.(js)$&quot;&gt;
    Header set Cache-Control &quot;private&quot;
  &lt;/filesMatch&gt;
  &lt;filesMatch &quot;\.(x?html?|php)$&quot;&gt;
    Header set Cache-Control &quot;private, must-revalidate&quot;
  &lt;/filesMatch&gt;
&lt;/ifModule&gt;
# END Cache-Control Headers

# BEGIN Turn ETags Off
FileETag None
# END Turn ETags Off
</pre>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.samaxes.com/2009/01/more-on-compressing-and-caching-your-site-with-htaccess/" title="Speed up your site by compressing and caching your content with .htaccess">Speed up your site by compressing and caching your content with .htaccess</a></li><li><a href="http://www.samaxes.com/2008/04/htaccess-gzip-and-cache-your-site-for-faster-loading-and-bandwidth-saving/" title=".htaccess &#8211; gzip and cache your site for faster loading and bandwidth saving">.htaccess &#8211; gzip and cache your site for faster loading and bandwidth saving</a></li><li><a href="http://www.samaxes.com/2009/05/combine-and-minimize-javascript-and-css-files-for-faster-loading/" title="Combine and minimize JavaScript and CSS files for faster loading">Combine and minimize JavaScript and CSS files for faster loading</a></li><li><a href="http://www.samaxes.com/2009/03/jboss-pojocache-configuration/" title="JBoss PojoCache configuration">JBoss PojoCache configuration</a></li><li><a href="http://www.samaxes.com/2008/01/j2ee-cache-filter/" title="J2EE cache filter">J2EE cache filter</a></li></ul> <a href="http://engine.influads.com/click/4f3f8cab353b27dd4e000008"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8cab353b27dd4e000008"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/samaxes?a=Lz8jePcLXLQ:MHky3KSEL84:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/samaxes?i=Lz8jePcLXLQ:MHky3KSEL84:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=Lz8jePcLXLQ:MHky3KSEL84:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/samaxes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=Lz8jePcLXLQ:MHky3KSEL84:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/samaxes?i=Lz8jePcLXLQ:MHky3KSEL84:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=Lz8jePcLXLQ:MHky3KSEL84:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/samaxes?i=Lz8jePcLXLQ:MHky3KSEL84:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=Lz8jePcLXLQ:MHky3KSEL84:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/samaxes?i=Lz8jePcLXLQ:MHky3KSEL84:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=Lz8jePcLXLQ:MHky3KSEL84:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/samaxes?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/samaxes/~4/Lz8jePcLXLQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.samaxes.com/2011/05/improving-web-performance-with-apache-and-htaccess/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://www.samaxes.com/2011/05/improving-web-performance-with-apache-and-htaccess/</feedburner:origLink></item>
		<item>
		<title>Stripes framework XSS Interceptor</title>
		<link>http://feedproxy.google.com/~r/samaxes/~3/T86MVe_2znM/</link>
		<comments>http://www.samaxes.com/2010/08/stripes-cross-site-scripting/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 14:08:54 +0000</pubDate>
		<dc:creator>Samuel Santos</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Stripes]]></category>
		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://www.samaxes.com/?p=227</guid>
		<description><![CDATA[I have created a new project at Google Code named Stripes XSS Interceptor. This project escapes all the parameters that Stripes binds during its Validation &#038; Binding phase using a wrapped request object (a convenient implementation of the HttpServletRequest interface). The code follows the XSS (Cross Site Scripting) security guidance posted at OWASP (Open Web [...] <a href="http://engine.influads.com/click/4f3f8cab353b272c4e000007"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8cab353b272c4e000007"/></a>]]></description>
			<content:encoded><![CDATA[<p>I have created a new project at Google Code named <a href="http://code.google.com/p/stripes-xss/">Stripes XSS Interceptor</a>.</p>
<p>This project escapes all the parameters that Stripes binds during its Validation &#038; Binding phase using a wrapped request object (a convenient implementation of the HttpServletRequest interface).</p>
<p>The code follows the XSS (Cross Site Scripting) security guidance posted at OWASP (Open Web Application Security Project).</p>
<p>Please feel free to report any bug you find in the project <a href="http://code.google.com/p/stripes-xss/issues/list">Issue Tracking</a>.</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.samaxes.com/2009/09/java-web-development-with-stripes/" title="Java Web Development with Stripes framework">Java Web Development with Stripes framework</a></li><li><a href="http://www.samaxes.com/2008/12/stripes-and-jquery-autocomplete/" title="Stripes framework and jQuery Autocomplete">Stripes framework and jQuery Autocomplete</a></li><li><a href="http://www.samaxes.com/2008/10/stripes-and-jquery-ajax-forms-and-http-session-validation/" title="Stripes framework and jQuery: AJAX forms and HTTP Session Validation">Stripes framework and jQuery: AJAX forms and HTTP Session Validation</a></li><li><a href="http://www.samaxes.com/2008/06/birt-stripes-example/" title="BIRT/Stripes framework example">BIRT/Stripes framework example</a></li><li><a href="http://www.samaxes.com/2008/01/stripes-and-ejb3/" title="Stripes framework and EJB3">Stripes framework and EJB3</a></li></ul> <a href="http://engine.influads.com/click/4f3f8cac353b27734f000008"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8cac353b27734f000008"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/samaxes?a=T86MVe_2znM:pU8Y0Eoih6M:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/samaxes?i=T86MVe_2znM:pU8Y0Eoih6M:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=T86MVe_2znM:pU8Y0Eoih6M:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/samaxes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=T86MVe_2znM:pU8Y0Eoih6M:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/samaxes?i=T86MVe_2znM:pU8Y0Eoih6M:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=T86MVe_2znM:pU8Y0Eoih6M:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/samaxes?i=T86MVe_2znM:pU8Y0Eoih6M:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=T86MVe_2znM:pU8Y0Eoih6M:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/samaxes?i=T86MVe_2znM:pU8Y0Eoih6M:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=T86MVe_2znM:pU8Y0Eoih6M:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/samaxes?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/samaxes/~4/T86MVe_2znM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.samaxes.com/2010/08/stripes-cross-site-scripting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.samaxes.com/2010/08/stripes-cross-site-scripting/</feedburner:origLink></item>
		<item>
		<title>Maven 2 Cobertura Plugin – Updated</title>
		<link>http://feedproxy.google.com/~r/samaxes/~3/RSonF1cVlww/</link>
		<comments>http://www.samaxes.com/2010/04/maven-2-cobertura-plugin-updated/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 16:10:12 +0000</pubDate>
		<dc:creator>Samuel Santos</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.samaxes.com/?p=222</guid>
		<description><![CDATA[My previous Maven 2 Cobertura Plugin article gives a workaround for the very buggy version 2.1 of the Cobertura Maven Plugin. This bug is fixed on versions 2.2 or higher, and consequently, that workaround does not work anymore. For those reading my previous article and having difficulties configuring the plugin, this is my actual configuration. [...] <a href="http://engine.influads.com/click/4f3f8cac353b27264e00000c"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8cac353b27264e00000c"/></a>]]></description>
			<content:encoded><![CDATA[<p>My previous <a href="http://www.samaxes.com/2007/06/maven-2-cobertura-plugin/">Maven 2 Cobertura Plugin</a> article gives a workaround for the very buggy version 2.1 of the <a href="http://mojo.codehaus.org/cobertura-maven-plugin/">Cobertura Maven Plugin</a>.</p>
<p>This bug is fixed on versions 2.2 or higher, and consequently, that workaround does not work anymore.<br />
For those <a href="http://www.samaxes.com/2007/06/maven-2-cobertura-plugin/#comments">reading my previous article and having difficulties</a> configuring the plugin, this is my actual configuration.</p>
<p><span id="more-222"></span></p>
<pre class="brush: xml; title: ; notranslate">
&lt;build&gt;
    &lt;plugins&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.5&lt;/version&gt;
            &lt;configuration&gt;
                &lt;systemPropertyVariables&gt;
                    &lt;net.sourceforge.cobertura.datafile&gt;target/cobertura/cobertura.ser&lt;/net.sourceforge.cobertura.datafile&gt;
                &lt;/systemPropertyVariables&gt;
                &lt;!-- for JDK6 Support --&gt;
                &lt;argLine&gt;-Dsun.lang.ClassLoader.allowArraySyntax=true&lt;/argLine&gt;
            &lt;/configuration&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
            &lt;artifactId&gt;cobertura-maven-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.3&lt;/version&gt;
            &lt;configuration&gt;
                &lt;check&gt;
                    &lt;haltOnFailure&gt;false&lt;/haltOnFailure&gt;
                    &lt;regexes&gt;
                        &lt;regex&gt;
                            &lt;pattern&gt;com.samaxes.business.*&lt;/pattern&gt;
                            &lt;branchRate&gt;80&lt;/branchRate&gt;
                            &lt;lineRate&gt;80&lt;/lineRate&gt;
                        &lt;/regex&gt;
                        &lt;regex&gt;
                            &lt;pattern&gt;com.samaxes.persistence.*&lt;/pattern&gt;
                            &lt;branchRate&gt;80&lt;/branchRate&gt;
                            &lt;lineRate&gt;80&lt;/lineRate&gt;
                        &lt;/regex&gt;
                    &lt;/regexes&gt;
                &lt;/check&gt;
                &lt;instrumentation&gt;
                    &lt;includes&gt;
                        &lt;include&gt;com/samaxes/business/**/*.class&lt;/include&gt;
                        &lt;include&gt;com/samaxes/persistence/**/*.class&lt;/include&gt;
                    &lt;/includes&gt;
                &lt;/instrumentation&gt;
            &lt;/configuration&gt;
        &lt;/plugin&gt;
    &lt;/plugins&gt;
&lt;/build&gt;
&lt;reporting&gt;
    &lt;plugins&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-surefire-report-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.5&lt;/version&gt;
            &lt;reportSets&gt;
                &lt;reportSet&gt;
                    &lt;reports&gt;
                        &lt;report&gt;report-only&lt;/report&gt;
                    &lt;/reports&gt;
                &lt;/reportSet&gt;
            &lt;/reportSets&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
            &lt;artifactId&gt;cobertura-maven-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.3&lt;/version&gt;
        &lt;/plugin&gt;
    &lt;/plugins&gt;
&lt;/reporting&gt;
</pre>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.samaxes.com/2007/06/maven-2-cobertura-plugin/" title="Maven 2 Cobertura Plugin">Maven 2 Cobertura Plugin</a></li><li><a href="http://www.samaxes.com/2009/06/maven-minify-plugin-using-yuicompressor/" title="Maven Minify Plugin using YUI Compressor">Maven Minify Plugin using YUI Compressor</a></li><li><a href="http://www.samaxes.com/2006/07/using-maven-2-xdoclet-2-and-hibernate-3/" title="Using Maven 2, XDoclet 2, and Hibernate 3">Using Maven 2, XDoclet 2, and Hibernate 3</a></li><li><a href="http://www.samaxes.com/2011/12/javaee-testing-ejb31-embeddable/" title="Java EE 6 Testing Part I &#8211; EJB 3.1 Embeddable API">Java EE 6 Testing Part I &#8211; EJB 3.1 Embeddable API</a></li><li><a href="http://www.samaxes.com/2009/09/test-jboss-microcontainer-services/" title="Unit Testing JBoss 5 Services">Unit Testing JBoss 5 Services</a></li></ul> <a href="http://engine.influads.com/click/4f3f8806e1f1df127d00000f"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8806e1f1df127d00000f"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/samaxes?a=RSonF1cVlww:J64Vji8Zc6E:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/samaxes?i=RSonF1cVlww:J64Vji8Zc6E:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=RSonF1cVlww:J64Vji8Zc6E:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/samaxes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=RSonF1cVlww:J64Vji8Zc6E:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/samaxes?i=RSonF1cVlww:J64Vji8Zc6E:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=RSonF1cVlww:J64Vji8Zc6E:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/samaxes?i=RSonF1cVlww:J64Vji8Zc6E:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=RSonF1cVlww:J64Vji8Zc6E:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/samaxes?i=RSonF1cVlww:J64Vji8Zc6E:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=RSonF1cVlww:J64Vji8Zc6E:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/samaxes?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/samaxes/~4/RSonF1cVlww" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.samaxes.com/2010/04/maven-2-cobertura-plugin-updated/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.samaxes.com/2010/04/maven-2-cobertura-plugin-updated/</feedburner:origLink></item>
		<item>
		<title>samaxesJS JavaScript library updates</title>
		<link>http://feedproxy.google.com/~r/samaxes/~3/Y_b-q8VbjcI/</link>
		<comments>http://www.samaxes.com/2010/04/samaxesjs-javascript-library-updates/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 14:26:18 +0000</pubDate>
		<dc:creator>Samuel Santos</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.samaxes.com/?p=219</guid>
		<description><![CDATA[Both the TOC (Table of Contents) components from samaxesJS JavaScript library have been updated. Changes include: Reduced file size by removing duplicated code using a for loop when defining and processing indexes (1.8KB for the minified jQuery TOC plugin). Added a new option: context, allowing the TOC to list headings from only a portion of [...] <a href="http://engine.influads.com/click/4f3f8cac353b279b4b000015"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8cac353b279b4b000015"/></a>]]></description>
			<content:encoded><![CDATA[<p>Both the TOC (Table of Contents) components from <a href="http://code.google.com/p/samaxesjs/">samaxesJS JavaScript library</a> have been updated.</p>
<p>Changes include:</p>
<ul>
<li>Reduced file size by removing duplicated code using a for loop when defining and processing indexes (1.8KB for the minified jQuery TOC plugin).</li>
<li>Added a new option: <code>context</code>, allowing the TOC to list headings from only a portion of the page.</li>
</ul>
<p>Please report any bug you may find in the project <a href="http://code.google.com/p/samaxesjs/issues/list">Issue Tracking</a>.</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.samaxes.com/2011/09/change-url-parameters-with-jquery/" title="Changing URL parameters with jQuery">Changing URL parameters with jQuery</a></li><li><a href="http://www.samaxes.com/2008/12/stripes-and-jquery-autocomplete/" title="Stripes framework and jQuery Autocomplete">Stripes framework and jQuery Autocomplete</a></li><li><a href="http://www.samaxes.com/2008/10/stripes-and-jquery-ajax-forms-and-http-session-validation/" title="Stripes framework and jQuery: AJAX forms and HTTP Session Validation">Stripes framework and jQuery: AJAX forms and HTTP Session Validation</a></li><li><a href="http://www.samaxes.com/2008/07/samaxesjs-javascript-controls/" title="samaxesJS JavaScript Controls">samaxesJS JavaScript Controls</a></li><li><a href="http://www.samaxes.com/2006/08/ie7-javascript-library/" title="IE7 JavaScript library">IE7 JavaScript library</a></li></ul> <a href="http://engine.influads.com/click/4f3f8cad353b27f550000002"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8cad353b27f550000002"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/samaxes?a=Y_b-q8VbjcI:gHj-e_daYgk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/samaxes?i=Y_b-q8VbjcI:gHj-e_daYgk:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=Y_b-q8VbjcI:gHj-e_daYgk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/samaxes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=Y_b-q8VbjcI:gHj-e_daYgk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/samaxes?i=Y_b-q8VbjcI:gHj-e_daYgk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=Y_b-q8VbjcI:gHj-e_daYgk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/samaxes?i=Y_b-q8VbjcI:gHj-e_daYgk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=Y_b-q8VbjcI:gHj-e_daYgk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/samaxes?i=Y_b-q8VbjcI:gHj-e_daYgk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=Y_b-q8VbjcI:gHj-e_daYgk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/samaxes?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/samaxes/~4/Y_b-q8VbjcI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.samaxes.com/2010/04/samaxesjs-javascript-library-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.samaxes.com/2010/04/samaxesjs-javascript-library-updates/</feedburner:origLink></item>
		<item>
		<title>Run PHP on Google App Engine</title>
		<link>http://feedproxy.google.com/~r/samaxes/~3/EaVugmPtYQ8/</link>
		<comments>http://www.samaxes.com/2009/12/php-on-google-app-engine/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 15:24:44 +0000</pubDate>
		<dc:creator>Samuel Santos</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[App Engine]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Quercus]]></category>

		<guid isPermaLink="false">http://www.samaxes.com/?p=209</guid>
		<description><![CDATA[By adding Java to their App Engine, Google has opened the door for a whole slew of languages that have been implemented on the JVM, now including PHP via Quercus. This weekend I decided to give it a try and deploy an old tutorial of mine &#8211; PHP Tutorials &#8211; on GAE. I must admit [...] <a href="http://engine.influads.com/click/4f3f8cad353b272d4e00000b"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8cad353b272d4e00000b"/></a>]]></description>
			<content:encoded><![CDATA[<blockquote cite="http://blog.caucho.com/?p=187"><p>By adding Java to their App Engine, Google has opened the door for a whole slew of languages that have been implemented on the JVM, now including PHP via Quercus.</p></blockquote>
<p>This weekend I decided to give it a try and deploy an old tutorial of mine &#8211; <a href="http://www.php-tutorials.info/">PHP Tutorials</a> &#8211; on <abbr title="Google App Engine">GAE</abbr>.</p>
<p>I must admit that I was pleasantly surprised by how effortless it was. OK, it&#8217;s a very rudimentary PHP application, the only PHP code used was to run the examples described on the code blocks and do some includes; nevertheless I didn&#8217;t feel the need to change a single line of code.</p>
<p>Also, deploying a Java application to GAE is simpler than a Python one. Not only because you have a very handy Eclipse plugin, but you will also find configuring the file <code>appengine-web.xml</code> a lot easier when compared to <code>app.yaml</code>.</p>
<p>All you need to do in order to deploy a PHP application, at least as simple as the one I&#8217;ve tried, is to follow these steps:<br />
<span id="more-209"></span></p>
<ol>
<li>Install <a href="http://code.google.com/appengine/docs/java/tools/eclipse.html">Google Plugin for Eclipse</a>.</li>
<li>Create a Web Application Project in eclipse. The complete project directory looks like this:
<pre>
Guestbook/
  src/
    <em>...Java source code...</em>
    META-INF/
      <em>...other configuration...</em>
  war/
    <em>...JSPs, images, data files...</em>
    WEB-INF/
      <em>...app configuration...</em>
      lib/
        <em>...JARs for libraries...</em>
      classes/
        <em>...compiled classes...</em>
</pre>
</li>
<li>Copy all your PHP and static files to <code>your-project/war</code>.</li>
<li>Download <a href="http://quercus.caucho.com/">Quercus binary</a> (WAR file).</li>
<li>Unzip it and copy all files inside <code>quercus.war/WEB-INF/lib</code> to <code>your-project/war/WEB-INF/lib</code>.</li>
<li>Edit your deployment descriptor file <code>web.xml</code>. Mine looks like this:
<pre class="brush: xml; title: web.xml; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:web=&quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;
    xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;
    version=&quot;2.5&quot;&gt;
    &lt;description&gt;PHP Tutorial&lt;/description&gt;

    &lt;servlet&gt;
        &lt;servlet-name&gt;Quercus Servlet&lt;/servlet-name&gt;
        &lt;servlet-class&gt;com.caucho.quercus.servlet.GoogleQuercusServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;

    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;Quercus Servlet&lt;/servlet-name&gt;
        &lt;url-pattern&gt;*.php&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;

    &lt;welcome-file-list&gt;
        &lt;welcome-file&gt;index.php&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
&lt;/web-app&gt;
</pre>
</li>
<li>Edit your configuration file <code>appengine-web.xml</code>. Mine looks like this:
<pre class="brush: xml; title: appengine-web.xml; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;appengine-web-app xmlns=&quot;http://appengine.google.com/ns/1.0&quot;&gt;
	&lt;application&gt;php-tutorials&lt;/application&gt;
	&lt;version&gt;1&lt;/version&gt;

    &lt;!-- Configure java.util.logging --&gt;
    &lt;system-properties&gt;
        &lt;property name=&quot;java.util.logging.config.file&quot; value=&quot;WEB-INF/logging.properties&quot; /&gt;
    &lt;/system-properties&gt;

    &lt;static-files&gt;
        &lt;include path=&quot;/**&quot; expiration=&quot;600s&quot; /&gt;
        &lt;include path=&quot;/**.png&quot; expiration=&quot;30d&quot; /&gt;
        &lt;include path=&quot;/**.jpg&quot; expiration=&quot;30d&quot; /&gt;
        &lt;include path=&quot;/**.gif&quot; expiration=&quot;30d&quot; /&gt;
        &lt;include path=&quot;/**.ico&quot; expiration=&quot;30d&quot; /&gt;
        &lt;include path=&quot;/**.swf&quot; expiration=&quot;30d&quot; /&gt;
        &lt;include path=&quot;/**.css&quot; expiration=&quot;7d&quot; /&gt;
        &lt;include path=&quot;/**.js&quot; expiration=&quot;2d 12h&quot; /&gt;
        &lt;exclude path=&quot;/**.php&quot; /&gt;
        &lt;exclude path=&quot;/**.inc&quot; /&gt;
    &lt;/static-files&gt;
    &lt;resource-files&gt;
        &lt;include path=&quot;/**.php&quot; /&gt;
        &lt;include path=&quot;/**.inc&quot; /&gt;
    &lt;/resource-files&gt;
&lt;/appengine-web-app&gt;
</pre>
<p>The <code>application</code> element must match the application identifier of your application on Google App Engine.</li>
</ol>
<p>Et voilà, you are done!</p>
<p>Now, run your application using the <code>Run As >> Web Application</code> command.<br />
And finally, press the &#8220;Deploy App Engine Project&#8221; button to deploy to GAE.</p>
<p><ins datetime="2010-11-01T17:09:19+00:00"><strong>Update:</strong> This article has been ported to the Miscellaneous section of my PHP Tutorial. Check <a href="http://www.php-tutorials.info/phpOnAppEngine.php">Run PHP on Google App Engine</a> page for updates.</ins></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.samaxes.com/2007/07/jboss-web-and-php-install-tutorial/" title="JBoss Web and PHP Install Tutorial">JBoss Web and PHP Install Tutorial</a></li><li><a href="http://www.samaxes.com/2007/07/creating-offline-web-applications-with-dojo-offline-tutorial/" title="Creating Offline Web Applications with Dojo Offline Tutorial">Creating Offline Web Applications with Dojo Offline Tutorial</a></li><li><a href="http://www.samaxes.com/2007/05/more-on-offline-web-applications-google-gears/" title="More on offline web applications &#8211; Google Gears">More on offline web applications &#8211; Google Gears</a></li><li><a href="http://www.samaxes.com/2007/05/web-php-framework-symfony/" title="Web PHP framework &#8211; symfony">Web PHP framework &#8211; symfony</a></li><li><a href="http://www.samaxes.com/2006/12/birt-and-php-reporting/" title="BIRT and PHP Reporting">BIRT and PHP Reporting</a></li></ul> <a href="http://engine.influads.com/click/4f3f8cad353b278c50000003"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8cad353b278c50000003"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/samaxes?a=EaVugmPtYQ8:xxtWeoxK5kM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/samaxes?i=EaVugmPtYQ8:xxtWeoxK5kM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=EaVugmPtYQ8:xxtWeoxK5kM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/samaxes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=EaVugmPtYQ8:xxtWeoxK5kM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/samaxes?i=EaVugmPtYQ8:xxtWeoxK5kM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=EaVugmPtYQ8:xxtWeoxK5kM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/samaxes?i=EaVugmPtYQ8:xxtWeoxK5kM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=EaVugmPtYQ8:xxtWeoxK5kM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/samaxes?i=EaVugmPtYQ8:xxtWeoxK5kM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=EaVugmPtYQ8:xxtWeoxK5kM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/samaxes?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/samaxes/~4/EaVugmPtYQ8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.samaxes.com/2009/12/php-on-google-app-engine/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.samaxes.com/2009/12/php-on-google-app-engine/</feedburner:origLink></item>
		<item>
		<title>W3C Widgets Compatibility Matrix for Packaging and Configuration</title>
		<link>http://feedproxy.google.com/~r/samaxes/~3/_Rjycu8vVY4/</link>
		<comments>http://www.samaxes.com/2009/11/w3c-widgets-compatibility-matrix/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 00:17:40 +0000</pubDate>
		<dc:creator>Samuel Santos</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[W3C]]></category>
		<category><![CDATA[Widgets]]></category>

		<guid isPermaLink="false">http://www.samaxes.com/?p=207</guid>
		<description><![CDATA[Daniel Silva, Marcos Caceres and myself have completed Phase 1 of Widget Packaging and Configuration compatibility testing. We have also detailed the results as part of the conformance matrix. We would like to publish the results as a working group note. Phase 2 will begin in about 3 weeks, in which we are hoping to [...] <a href="http://engine.influads.com/click/4f3f8cae353b276c4e00000b"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8cae353b276c4e00000b"/></a>]]></description>
			<content:encoded><![CDATA[<p>Daniel Silva, <a href="http://datadriven.com.au/">Marcos Caceres</a> and myself have completed Phase 1 of <a href="http://www.w3.org/TR/widgets/">Widget Packaging and Configuration</a> compatibility testing. We have also detailed the results as part of the conformance matrix.<br />
We would like to publish the results as a working group note. Phase 2 will begin in about 3 weeks, in which we are hoping to start working with vendors to improve overall conformance.</p>
<p>We need help with Phase 2: if you know a team contact for any of the targeted products that are claiming conformance to W3C Widgets, then would appreciate your help in making them aware of the results of the testing &#8211; <a href="http://dev.w3.org/2006/waf/widgets/imp-report/">Implementation Report: Widgets Packaging and Configuration</a>.</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>No Related Posts</li></ul> <a href="http://engine.influads.com/click/4f3f8808e1f1df317c000010"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8808e1f1df317c000010"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/samaxes?a=_Rjycu8vVY4:Cbw7LQxXulw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/samaxes?i=_Rjycu8vVY4:Cbw7LQxXulw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=_Rjycu8vVY4:Cbw7LQxXulw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/samaxes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=_Rjycu8vVY4:Cbw7LQxXulw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/samaxes?i=_Rjycu8vVY4:Cbw7LQxXulw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=_Rjycu8vVY4:Cbw7LQxXulw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/samaxes?i=_Rjycu8vVY4:Cbw7LQxXulw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=_Rjycu8vVY4:Cbw7LQxXulw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/samaxes?i=_Rjycu8vVY4:Cbw7LQxXulw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=_Rjycu8vVY4:Cbw7LQxXulw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/samaxes?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/samaxes/~4/_Rjycu8vVY4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.samaxes.com/2009/11/w3c-widgets-compatibility-matrix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.samaxes.com/2009/11/w3c-widgets-compatibility-matrix/</feedburner:origLink></item>
		<item>
		<title>Java Web Development with Stripes framework</title>
		<link>http://feedproxy.google.com/~r/samaxes/~3/O4wvqo0EMbQ/</link>
		<comments>http://www.samaxes.com/2009/09/java-web-development-with-stripes/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 23:41:33 +0000</pubDate>
		<dc:creator>Samuel Santos</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Stripes]]></category>

		<guid isPermaLink="false">http://www.samaxes.com/?p=197</guid>
		<description><![CDATA[Stripes Framework presentation for the Portuguese Java User Group session on the JavaPT09 event. The used source code is also available. Related PostsStripes framework XSS InterceptorStripes framework and jQuery AutocompleteStripes framework and jQuery: AJAX forms and HTTP Session ValidationBIRT/Stripes framework exampleStripes framework and EJB3 <a href="http://engine.influads.com/click/4f3f8cae353b270451000002"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8cae353b270451000002"/></a>]]></description>
			<content:encoded><![CDATA[<p>Stripes Framework presentation for the Portuguese Java User Group session on the JavaPT09 event.</p>
<p>The used <a href="http://samaxes.appspot.com/zip/javapt09-stripes-code-example.zip">source code</a> is also available.</p>
<p><script src="http://speakerdeck.com/embed/4f2888eefbac0e001f004ff9.js"></script></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.samaxes.com/2010/08/stripes-cross-site-scripting/" title="Stripes framework XSS Interceptor">Stripes framework XSS Interceptor</a></li><li><a href="http://www.samaxes.com/2008/12/stripes-and-jquery-autocomplete/" title="Stripes framework and jQuery Autocomplete">Stripes framework and jQuery Autocomplete</a></li><li><a href="http://www.samaxes.com/2008/10/stripes-and-jquery-ajax-forms-and-http-session-validation/" title="Stripes framework and jQuery: AJAX forms and HTTP Session Validation">Stripes framework and jQuery: AJAX forms and HTTP Session Validation</a></li><li><a href="http://www.samaxes.com/2008/06/birt-stripes-example/" title="BIRT/Stripes framework example">BIRT/Stripes framework example</a></li><li><a href="http://www.samaxes.com/2008/01/stripes-and-ejb3/" title="Stripes framework and EJB3">Stripes framework and EJB3</a></li></ul> <a href="http://engine.influads.com/click/4f3f8cae353b27c250000003"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8cae353b27c250000003"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/samaxes?a=O4wvqo0EMbQ:y4zoil-KsS0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/samaxes?i=O4wvqo0EMbQ:y4zoil-KsS0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=O4wvqo0EMbQ:y4zoil-KsS0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/samaxes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=O4wvqo0EMbQ:y4zoil-KsS0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/samaxes?i=O4wvqo0EMbQ:y4zoil-KsS0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=O4wvqo0EMbQ:y4zoil-KsS0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/samaxes?i=O4wvqo0EMbQ:y4zoil-KsS0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=O4wvqo0EMbQ:y4zoil-KsS0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/samaxes?i=O4wvqo0EMbQ:y4zoil-KsS0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=O4wvqo0EMbQ:y4zoil-KsS0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/samaxes?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/samaxes/~4/O4wvqo0EMbQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.samaxes.com/2009/09/java-web-development-with-stripes/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.samaxes.com/2009/09/java-web-development-with-stripes/</feedburner:origLink></item>
		<item>
		<title>Unit Testing JBoss 5 Services</title>
		<link>http://feedproxy.google.com/~r/samaxes/~3/D7aViOk9_7s/</link>
		<comments>http://www.samaxes.com/2009/09/test-jboss-microcontainer-services/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 13:02:45 +0000</pubDate>
		<dc:creator>Samuel Santos</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.samaxes.com/?p=196</guid>
		<description><![CDATA[The JBoss Microcontainer is a refactoring of JBoss&#8217;s JMX Microkernel to support direct POJO deployment and standalone use outside the JBoss application server. It allows the creation of services using simple Plain Old Java Objects (POJOs) to be deployed into a standard Java SE runtime environment. JBoss Microcontainer uses dependency injection to wire individual POJOs [...] <a href="http://engine.influads.com/click/4f3f8caf353b27354e00000a"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8caf353b27354e00000a"/></a>]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://jboss.org/jbossmc/">JBoss Microcontainer</a> is a refactoring of JBoss&#8217;s JMX Microkernel to support direct POJO deployment and standalone use outside the JBoss application server.<br />
It allows the creation of services using simple Plain Old Java Objects (POJOs) to be deployed into a standard Java SE runtime environment.</p>
<blockquote cite="http://docs.jboss.org/jbossmc/docs/2.0.x/userGuide/overview.html"><p>JBoss Microcontainer uses dependency injection to wire individual POJOs together to create services. Configuration is performed using either annotations or XML depending on where the information is best located.</p></blockquote>
<p>The goal of this article is to show how easy it is to test these services using <a href="http://testng.org/">TestNG</a> testing framework.<br />
<span id="more-196"></span></p>
<h3>Configuring a service</h3>
<p><code>PersonService</code> is a simple POJO that doesn&#8217;t implement any special interfaces.<br />
It has two properties, <code>firstName</code> and <code>lastName</code>, that are inject through a XML deployment descriptor.<br />
The public method that clients will call is <code>getName()</code> and returns the person full name.</p>
<pre class="brush: java; title: PersonService.java; notranslate">
public class PersonService {
    private String firstName;
    private String lastName;

    public void setFirstName(String firstName) { this.firstName = firstName; }
    public void setLastName(String lastName) { this.lastName = lastName; }

    public String getName() {
        return firstName + &quot; &quot; + lastName;
    }
}
</pre>
<p>Instances of this service are created by creating an XML deployment descriptor that contains a list of beans representing individual instances.</p>
<pre class="brush: xml; title: jboss-beans.xml; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;deployment xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xsi:schemaLocation=&quot;urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd&quot;
    xmlns=&quot;urn:jboss:bean-deployer:2.0&quot;&gt;

    &lt;bean name=&quot;PersonService&quot; class=&quot;com.samaxes.jboss.service.plain.PersonService&quot;&gt;
        &lt;property name=&quot;firstName&quot;&gt;Samuel&lt;/property&gt;
        &lt;property name=&quot;lastName&quot;&gt;Santos&lt;/property&gt;
    &lt;/bean&gt;

&lt;/deployment&gt;
</pre>
<p>We have just declared that we want to create an instance of the PersonService class and register it with the name <code>PersonService</code>. This file is passed to an XML deployer associated with the microcontainer at runtime to perform the actual deployment and instantiate the beans.</p>
<h3>Testing a service</h3>
<p>JBoss Microcontainer makes it extremely easy to unit test services.<br />
First, you need to create an <code>EmbeddedBootstrap</code> class and override the protected <code>bootstrap()</code> method.<br />
This allows you to created an instance of JBoss Microcontainer together with an XML deployer.</p>
<pre class="brush: java; title: EmbeddedBootstrap.java; notranslate">
public class EmbeddedBootstrap extends BasicBootstrap {
    protected BasicXMLDeployer deployer;

    public EmbeddedBootstrap() throws Exception {
        super();
    }

    public void bootstrap() throws Throwable {
        super.bootstrap();
        deployer = new BasicXMLDeployer(getKernel());
        Runtime.getRuntime().addShutdownHook(new Shutdown());
    }

    public void deploy(URL url) {
        try {
            // Workaround the fact that the BasicXMLDeployer does not handle redeployment correctly
            if (deployer.getDeploymentNames().contains(url.toString())) {
                log.info(&quot;Service is already deployed.&quot;);
                return;
            }
            deployer.deploy(url);
        } catch (Throwable t) {
            log.warn(&quot;Error during deployment: &quot; + url, t);
        }
    }

    public void undeploy(URL url) {
        if (!deployer.getDeploymentNames().contains(url.toString())) {
            log.info(&quot;Service is already undeployed.&quot;);
            return;
        }
        try {
            deployer.undeploy(url);
        } catch (Throwable t) {
            log.warn(&quot;Error during undeployment: &quot; + url, t);
        }
    }

    protected class Shutdown extends Thread {
        public void run() {
            log.info(&quot;Shutting down&quot;);
            deployer.shutdown();
        }
    }
}
</pre>
<p>Next, you need to bootstrap the microcontainer. This is done in <code>BaseTest</code> class.</p>
<pre class="brush: java; title: BaseTest.java; notranslate">
public class BaseTest&lt;T&gt; {
    private URL url;
    private EmbeddedBootstrap bootstrap;
    private Kernel kernel;
    private KernelController controller;

    @BeforeSuite
    public void setUpSuite() throws Exception {
        // Start JBoss Microcontainer
        bootstrap = new EmbeddedBootstrap();
        bootstrap.run();

        kernel = bootstrap.getKernel();
        controller = kernel.getController();
    }

    @AfterSuite
    public void tearDownSuite() {
    }

    protected void deploy(String url) {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        this.url = cl.getResource(url);

        bootstrap.deploy(cl.getResource(url));
    }

    protected void undeploy() {
        bootstrap.undeploy(url);
    }

    @SuppressWarnings( { &quot;unchecked&quot; })
    protected T getService(String name) {
        ControllerContext context = controller.getInstalledContext(name);

        return (context == null) ? null : (T) context.getTarget();
    }
}
</pre>
<p>All the test classes extend this one, this allows you to run the microcontainer only once before the test suite.<br />
Another benefit is to have all the utility methods used in every test class in a central place.</p>
<p>Now we can proceed to the last part, and that is to deploy the Person service.</p>
<pre class="brush: java; title: PersonServiceTest.java; notranslate">
public class PersonServiceTest extends BaseTest&lt;PersonService&gt; {
    private static final Logger LOGGER = LoggerFactory.getLogger(PersonServiceTest.class);
    private PersonService service;

    @BeforeClass
    public void setUp() {
        deploy(&quot;jboss-beans.xml&quot;);
        service = getService(&quot;PersonService&quot;);
    }

    @AfterClass
    public void tearDown() {
        undeploy();
    }

    @Test
    public void getName() {
        String name = service.getName();
        LOGGER.info(&quot;Name: {}&quot;, name);
        assertEquals(&quot;Samuel Santos&quot;, name);
    }
}
</pre>
<p>To see it in action, get this <a href="http://samaxes.appspot.com/zip/pojo-service-1.0.zip">example source code</a> and run the <a href="http://maven.apache.org/">Maven</a> command <kbd>mvn test</kbd>.</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.samaxes.com/2011/12/javaee-testing-ejb31-embeddable/" title="Java EE 6 Testing Part I &#8211; EJB 3.1 Embeddable API">Java EE 6 Testing Part I &#8211; EJB 3.1 Embeddable API</a></li><li><a href="http://www.samaxes.com/2010/04/maven-2-cobertura-plugin-updated/" title="Maven 2 Cobertura Plugin &#8211; Updated">Maven 2 Cobertura Plugin &#8211; Updated</a></li><li><a href="http://www.samaxes.com/2009/03/jboss-pojocache-configuration/" title="JBoss PojoCache configuration">JBoss PojoCache configuration</a></li><li><a href="http://www.samaxes.com/2008/12/jboss-as-50-is-out/" title="JBoss AS 5.0 is out!">JBoss AS 5.0 is out!</a></li><li><a href="http://www.samaxes.com/2007/06/maven-2-cobertura-plugin/" title="Maven 2 Cobertura Plugin">Maven 2 Cobertura Plugin</a></li></ul> <a href="http://engine.influads.com/click/4f3f8caf353b27c950000001"><img hspace="8" vspace="8" align="right" src="http://engine.influads.com/image/4f3f8caf353b27c950000001"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/samaxes?a=D7aViOk9_7s:WVN8t_tK-SM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/samaxes?i=D7aViOk9_7s:WVN8t_tK-SM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=D7aViOk9_7s:WVN8t_tK-SM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/samaxes?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=D7aViOk9_7s:WVN8t_tK-SM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/samaxes?i=D7aViOk9_7s:WVN8t_tK-SM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=D7aViOk9_7s:WVN8t_tK-SM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/samaxes?i=D7aViOk9_7s:WVN8t_tK-SM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=D7aViOk9_7s:WVN8t_tK-SM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/samaxes?i=D7aViOk9_7s:WVN8t_tK-SM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/samaxes?a=D7aViOk9_7s:WVN8t_tK-SM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/samaxes?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/samaxes/~4/D7aViOk9_7s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.samaxes.com/2009/09/test-jboss-microcontainer-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.samaxes.com/2009/09/test-jboss-microcontainer-services/</feedburner:origLink></item>
	</channel>
</rss>

