<?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:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
  <title>Adam Bien</title>
  <link>http://www.adam-bien.com/roller</link>
      
    <description>Adam Bien's Software Engineering Weblog</description>
  <language>en-us</language>
    <copyright>Copyright 2009</copyright>
  <lastBuildDate>Mon, 6 Jul 2009 11:32:22 +0100</lastBuildDate>
  <generator>Apache Roller Weblogger 4.0 (20071120033321:dave)</generator>
      <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/AdamBien" type="application/rss+xml" /><item>
    <guid isPermaLink="true">http://www.adam-bien.com/roller/abien/entry/java_ee_6_ejb_3</guid>
    <title>Lean Java EE 6 Without Spring And Spring 3.0 In Java EE 6 World: Summary and Conclusion (eJug Session)</title>
    <dc:creator>admin</dc:creator>
    <link>http://www.adam-bien.com/roller/abien/entry/java_ee_6_ejb_3</link>
        <pubDate>Mon, 6 Jul 2009 08:55:03 +0100</pubDate>
    <category>Events</category>
    <category>spring</category>
    <category>javaee</category>
    <category>patterns</category>
    <category>bestpractices</category>
            <description>&lt;p&gt;It turned out, that both components models are surprisingly similar. You could migrate an EJB 3.1 based application, almost without any additional effort to Spring (search and replace for annotations). It is even possible to run an EJB 3.1 applications without ANY modification just tweaking Spring a bit.&amp;nbsp;&lt;/p&gt;&lt;p&gt;Although both technologies are almost identical from the programming model perspective - the philosophy is totally different. Spring &amp;quot;is not just a glue-framework&amp;quot; (Juergen clarified that), rather than complete solution - the full stack. Spring was architected as a layer above the actual application server. The idea: you can upgrade your APIs updating Spring and not touching the application server. This is especially important if you have to use the &amp;quot;heavyweights&amp;quot; application servers (=they come with at least with one DVD to install and the installation takes several hours :-)) without having any control about the version. The Dependency Injection is only a small part of the framework. Spring offers you from DI, over Spring MVC with REST support (similar to JAX-RS) and even monitoring. It actually replaces the most parts of the application servers with own services.&lt;/p&gt;&lt;p&gt; What was also interesting - Spring is exactly NOT Convention Over Configuration. The idea is to configure everything is needed explicitly, without relying on conventions. But you don't have to configure everything over and over again - you can use &amp;quot;Stereotypes&amp;quot; for that purpose. Stereotypes are &amp;quot;Meta-Annotations&amp;quot;. So you can introduce your own annotations, using &amp;quot;annotation inheritance&amp;quot;. Then you only will have to use your own shortcuts (e.g. @Service, @ServiceFacade etc.).&amp;nbsp;&lt;/p&gt;&lt;p&gt;The philosophy of EJB 3.1 is exactly the opposite. It is not a complete solution, rather than &amp;quot;only&amp;quot; a component model for transactional, serverside applications. It comes with a set of suitable conventions, so you don't have to configure anything an rely on the existing conventions. Neither annotations (except @Stateless), nor XML-configuration is needed. The EJB infrastructure has to be available at the application server - so you only have to deploy your application - without the EJB-&amp;quot;framework&amp;quot; (Glassfish EJB 3 container is about 700kB) bits. The DI are not as sophisticated as Spring's, JSR-299 or JSR-330, but actually absolutely sufficient for most projects (at least my projects :-)). &lt;/p&gt;&lt;p&gt;EJB 3.1 components are aimed to run directly on the server, without any indirections. This also means: you can only use EJB 3.1 in case your application server has support for it. But: I also saw some projects using &lt;a href="http://openejb.apache.org/" target="_blank"&gt;openEJB&lt;/a&gt; container to run EJB 3.1 on tomcat :-). Whats also true: SAP, IBM Websphere, BEA Weblogic, Oracle OC4J, JBoss 4 and 5, openEJB / Geronimo and Glassfish v2 (+&lt;a href="http://www.adam-bien.com/roller/abien/entry/the_list_of_certified_java" target="_blank"&gt;several others&lt;/a&gt;) comes already with EJB 3 support. In that case your components become vendor neutral. You can move them around, without changing any EJB 3.X setting (JPA is harder to port across different providers). You will, however, have to test them on different servers.&amp;nbsp;&lt;/p&gt;&lt;p&gt;Spring will support parts of the Java EE 6 specification - except the @Stateless annotations :-). We (Juergen Hoeller, eJug audience and me) discussed a bit longer this issue. We have different opinions on this: If I were SpringSource, I would support @Stateless and few EJB 3.1 annotation to make the transition more easy. Juergen said it would be hard to support @Stateless in completely compliant way - and he would expect some criticism then. But: the differences could be documented - so there should be no problems as well at this point.&lt;/p&gt;&lt;p&gt;In the practice, however, the support issue may be important as well. It is more and more important to provide the support for the full stack from one company. I guess in future you will see SpringSource only (e.g. &lt;a href="http://www.springsource.com/products/dmserver" target="_blank"&gt;dm server&lt;/a&gt;), and Java EE 6 only solutions. These decisions will be not driven by technical, rather than political / strategic reasons. Imagine Spring will run on a commercial application server in production and something goes wrong. Such support issues could be really &amp;quot;exciting&amp;quot;. Some of my involvements in the resolution of &amp;quot;multi-vendor J2EE-only&amp;quot; support cases were already funny enough in the past :-).&lt;/p&gt;&lt;p&gt;I hope this is a unbiased description of this event - otherwise please feel free to drop me an email or comment. The &lt;a href="http://www.ejug.at/node/26" target="_blank"&gt;eJug&lt;/a&gt; meeting was well organized at a nice venue - the upcoming sessions are interesting as well. My (English) slides are based on some contents from my&amp;nbsp;&lt;a href="http://press.adam-bien.com/" target="_blank"&gt;&amp;quot;Real World Java EE Patterns&amp;quot; book&lt;/a&gt;&amp;nbsp;-the&amp;nbsp;slides&amp;nbsp;should&amp;nbsp;be&amp;nbsp;available&amp;nbsp;for&amp;nbsp;download&amp;nbsp;from&amp;nbsp;eJug. See the&amp;nbsp;&lt;a href="http://www.ejug.at/node/26" target="_blank"&gt;German (eJug) summary&lt;/a&gt;&amp;nbsp;as well. Thanks Juergen Hoeller for the&amp;nbsp;&lt;a href="http://www.adam-bien.com/roller/abien/entry/lean_service_domain_driven_components" target="_blank"&gt;invitation&lt;/a&gt;!&amp;nbsp;&lt;/p&gt;&lt;p&gt;Btw. I will cover some &amp;quot;extreme&amp;quot; EJB 3.1 / REST with Convention Over Configuration approaches in the upcoming &lt;a href="http://www.javamagazin.de" target="_blank"&gt;Java Magazin&lt;/a&gt; (German only :-)).&amp;nbsp;&lt;/p&gt;</description>          </item>
    <item>
    <guid isPermaLink="true">http://www.adam-bien.com/roller/abien/entry/how_to_debug_unit_tests</guid>
    <title>How To Debug Unit Tests In Netbeans 6.7</title>
    <dc:creator>admin</dc:creator>
    <link>http://www.adam-bien.com/roller/abien/entry/how_to_debug_unit_tests</link>
        <pubDate>Thu, 2 Jul 2009 07:44:49 +0100</pubDate>
    <category>Netbeans</category>
    <category>netbeans</category>
    <category>6.7</category>
            <description>&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica; "&gt;In&amp;nbsp;Netbeans&amp;nbsp;6.7&amp;nbsp;you&amp;nbsp;can&amp;nbsp;invoke,&amp;nbsp;and&amp;nbsp;especially&amp;nbsp;debug unit tests in the following way:&lt;br /&gt;&lt;br /&gt;1. From test results:&lt;br /&gt;-&amp;nbsp;Invoke context menu on a given test and select 'Debug'&lt;br /&gt;&lt;br /&gt;2. From project&lt;br /&gt;- &amp;nbsp;Select test file and choose &amp;quot;Debug-&amp;gt;Debug Test File&amp;quot; from main menu or press Ctrl_Shift_F6 (on Mac Cmd_Shift_F6)&lt;br /&gt;&lt;br /&gt;The way on how test are executed is changed right after 6.5, you may get more insight from&amp;nbsp;&lt;a href="http://www.netbeans.org/issues/show_bug.cgi?id=119922"&gt;http://www.netbeans.org/issues/show_bug.cgi?id=119922&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Please also check&amp;nbsp;&lt;a href="http://www.netbeans.org/issues/show_bug.cgi?id=158812"&gt;http://www.netbeans.org/issues/show_bug.cgi?id=158812&lt;/a&gt;, to track the recent changes.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica; "&gt;Thanks to Alexei Mokeev for providing this information - I was shortly before filing a P1 bug :-). In my opinion the Netbeans 6.5 way was more intuitive. &amp;nbsp;&lt;/span&gt;&lt;/p&gt;</description>          </item>
    <item>
    <guid isPermaLink="true">http://www.adam-bien.com/roller/abien/entry/netbeans_6_7_prev_netbeans1</guid>
    <title>Netbeans 6.7 (prev. Netbeans 7.0) - For Clouds - Detailed Overview</title>
    <dc:creator>admin</dc:creator>
    <link>http://www.adam-bien.com/roller/abien/entry/netbeans_6_7_prev_netbeans1</link>
        <pubDate>Tue, 30 Jun 2009 08:28:31 +0100</pubDate>
    <category>Real World Java EE Patterns - Rethinking Best Practices</category>
    <category>netbeans</category>
    <category>kenai</category>
    <category>javaee</category>
    <category>maven</category>
            <description>&lt;p&gt;
&lt;a href="http://www.h-online.com/open/NetBeans-6-7-released-focuses-on-Maven-and-Kenai-integration--/news/113640" target="_blank"&gt;Netbeans 6.7 (7.0) features&lt;/a&gt;&amp;nbsp;- &amp;nbsp;detailed view (kenai, maven, javaee). Someone translated this article from &lt;a href="http://www.heise.de/developer/NetBeans-6-7-setzt-Fokus-auf-Maven-und-Kenai-Integration--/news/meldung/141249" target="_blank"&gt;German&lt;/a&gt;. Thanks for the translation! &lt;/p&gt;&lt;p&gt;If you want to try out kenai go to:&amp;nbsp;&lt;a href="http://kenai.com/projects/javaee-patterns/"&gt;http://kenai.com/projects/javaee-patterns/&lt;/a&gt;,&amp;nbsp;&amp;nbsp;or open &amp;quot;Kenai&amp;quot; Tab --&amp;gt; Open Project and enter:&amp;nbsp;javaee-patterns.&lt;/p&gt;</description>          </item>
    <item>
    <guid isPermaLink="true">http://www.adam-bien.com/roller/abien/entry/netbeans_6_7_prev_netbeans</guid>
    <title>Netbeans 6.7 (prev. Netbeans 7.0) Is Ready To Download</title>
    <dc:creator>admin</dc:creator>
    <link>http://www.adam-bien.com/roller/abien/entry/netbeans_6_7_prev_netbeans</link>
        <pubDate>Mon, 29 Jun 2009 16:21:36 +0100</pubDate>
    <category>General</category>
    <category>patterns</category>
    <category>javaee</category>
    <category>ejb</category>
    <category>kenai</category>
    <category>netbeans6.7</category>
            <description>You can download it from &lt;a href="http://www.netbeans.org/downloads/index.html" target="_blank"&gt;here&lt;/a&gt;. Btw. if you need some samples to test Glassfish v3 / Mercurial / EJB 3.1 / JPA / Java EE Patterns - you can check out (actually pull) some code from here:&amp;nbsp;&lt;a href="http://kenai.com/projects/javaee-patterns/" target="_blank"&gt;http://kenai.com/projects/javaee-patterns/&lt;/a&gt;. All tested with 6.7 the &amp;quot;Java&amp;quot; edition. Search for javaee-patterns in the Kenai tab.</description>          </item>
    <item>
    <guid isPermaLink="true">http://www.adam-bien.com/roller/abien/entry/ejb_3_1_and_rest</guid>
    <title>EJB 3.1 And REST - The Lightweight Hybrid</title>
    <dc:creator>admin</dc:creator>
    <link>http://www.adam-bien.com/roller/abien/entry/ejb_3_1_and_rest</link>
        <pubDate>Mon, 29 Jun 2009 08:05:07 +0100</pubDate>
    <category>Real World Java EE Patterns - Rethinking Best Practices</category>
    <category>patterns</category>
    <category>ejb</category>
    <category>rest</category>
            <description>The Local / Remote interfaces in EJB 3.1 are optional. You can still, however, expose a Session bean as a RESTFul (JSR-311) service.
&lt;pre&gt;&lt;code&gt;
package com.abien.patterns.business.rest.boundary;

import com.abien.patterns.business.rest.control.Service;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Stateless
@Path(&amp;quot;current&amp;quot;)
public class ServiceFacade {

    @EJB
    Service service;

    @GET
    public String getDate(){
        return service.getCurrentDate().toString();
    }

}

&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;The Service is just another, usual, @Local bean:
&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
@Stateless
public class Service {

    public Date getCurrentDate(){
        return new Date();
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;
A &lt;a href="http://www.adam-bien.com/roller/abien/entry/why_service_isn_t_a" target="_blank"&gt;ServiceFacade&lt;/a&gt; becomes available via REST, just denoting it with the JAR-RS annotations. Its both an EJB 3.1 and a REST-resource - it is available under &lt;a href="http://localhost:8080/EJBRestHybrid/resources/current" target="_blank"&gt;http://localhost:8080/EJBRestHybrid/resources/curren&lt;/a&gt;t (tested with Glassfish v3 preview). It will return the current time as String (Mon Jun 29 08:19:32 CEST 2009). The additional @Stateless has the following advantages:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Injection capabilities: you can easily inject other EJBs, EntityManagers, JMS-resources, DataSources or JCA connectors&lt;/li&gt;&lt;li&gt;Transactions: all changes made in a REST-call will be automatically and transparently synchronized with the database&lt;/li&gt;&lt;li&gt;Single threading programming model -&amp;gt; &lt;a href="http://www.adam-bien.com/roller/abien/entry/why_i_like_ejb_3" target="_blank"&gt;the old EJB goodness&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Monitoring: an EJB is visible in JMX&lt;/li&gt;&lt;li&gt;Throttling: its easy to restrict the concurrency of an EJB using ThreadPools or bean pools&lt;/li&gt;&lt;li&gt;Vendor-independence: EJB 3 runs on multiple containers, without any modification (and without any XML in particular :-))&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;p&gt;Exposing a protocol-neutral ServiceFacade directly via REST can make it REST-dependent. E.g. you may pass JAXB-enabled classes as parameters / return - values. It will be hard then to expose the ServiceFacade through other channels. On the other hand - if REST is all you need, it is the simplest and leanest approach. There are no additional libraries needed - everything is already included in a Java EE 6 container (in Glassfish v3 the whole EJB 3.1 container is &amp;lt; 1 MB...).&amp;nbsp;&lt;/p&gt;&lt;p&gt;The whole example project (tested with Netbeans 6.7rc3 and Glassfish v3 Preview) with source code was pushed into &lt;a href="http://kenai.com/projects/javaee-patterns"&gt;http://kenai.com/projects/javaee-patterns&lt;/a&gt;. In Netbeans 6.7 you will have to &lt;a href="http://blogs.sun.com/vkraemer/entry/experimental_features_marker"&gt;enable&lt;/a&gt; Glassfish v3 capabilities. If you are using vi or emacs :-), you will have to include the Java EE 6 API to the classpath.&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-size: x-small; "&gt;[This sample is based on the ServiceFacade pattern from the &amp;quot;&lt;/span&gt;&lt;a href="http://press.adam-bien.com" target="_blank"&gt;&lt;span class="Apple-style-span" style="font-size: x-small; "&gt;Real World Java EE Patterns&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: x-small; "&gt;&amp;quot; book]&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;</description>          </item>
  </channel>
</rss>
