<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Java Blog</title>
	<atom:link href="http://thejavablog.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://thejavablog.wordpress.com</link>
	<description>Thoughts, tips and tricks about the Java programming language</description>
	<lastBuildDate>Thu, 16 Apr 2009 13:43:01 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='thejavablog.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/6fd94de3e77e698916d08512c5a7e230?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>The Java Blog</title>
		<link>http://thejavablog.wordpress.com</link>
	</image>
			<item>
		<title>Axis returned (0)null &#8211; a solution</title>
		<link>http://thejavablog.wordpress.com/2009/04/15/0null/</link>
		<comments>http://thejavablog.wordpress.com/2009/04/15/0null/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 18:56:22 +0000</pubDate>
		<dc:creator>Panos</dc:creator>
				<category><![CDATA[axis]]></category>
		<category><![CDATA[web services]]></category>

		<guid isPermaLink="false">http://thejavablog.wordpress.com/?p=167</guid>
		<description><![CDATA[This is a very weird error I was getting a few days ago when I was running Apache Axis. If you output the stack trace you will get the following error

AxisFault
faultCode: {http://xml.apache.org/axis/}HTTP
faultSubcode:
faultString: (0)null
faultActor:
faultNode:
faultDetail:
{}:return code:  0

{http://xml.apache.org/axis/}HttpErrorCode:0

(0)null
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)

If you delve into the apache axis source code [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=167&subd=thejavablog&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This is a very weird error I was getting a few days ago when I was running Apache Axis. If you output the stack trace you will get the following error</p>
<pre class="brush: java;">
AxisFault
faultCode: {http://xml.apache.org/axis/}HTTP
faultSubcode:
faultString: (0)null
faultActor:
faultNode:
faultDetail:
{}:return code:  0

{http://xml.apache.org/axis/}HttpErrorCode:0

(0)null
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
</pre>
<p>If you delve into the apache axis source code you will see that this is actually a network error. There is a variable that holds the network code. This variable is assigned to zero in the beginning of the axis class. At some point the developers of axis read the HTTP responses and assign the HTTP code to this network code variable. But along the flow of the class an exception occurs and this network code remains zero. The null you get next to it is the actual error message description which is null because the exception doesn&#8217;t assign a message to it (exactly like it happens with the zero).</p>
<p>This occurred to me when I tried to use a DIME attachment with axis. It seems that axis 1 (not sure about axis 2) does not support DIME attachments properly. In order to resolve this (and the error above) you will need to use another transport handler. There is a solution described in the <a href="http://wiki.apache.org/ws/FrontPage/Axis/AttachmentProblems">Axis attachment problems</a> page. Although the solution described in the link is for a different problem, the same solution can be applied for the (0)null issue.</p>
<p>As the page explains the solution is to change the client-config.wsdd file (from within the org\apache\axis\client) and assign a different handler to the file, like the following</p>
<pre class="brush: java;">
&lt;deployment name=&quot;defaultClientConfig&quot; ...&gt;
&lt;transport name=&quot;http&quot; pivot=&quot;java:org.apache.axis.transport.http.CommonsHTTPSender&quot;/&gt;
...
&lt;/deployment&gt;
</pre>
<p>In order to do this you will need to extract all the classes in the axis.jar file, change the client-config.wsdd, and recreate the axis.jar file. You will also need to include the <a href="http://hc.apache.org/downloads.cgi">apache commons http client 3.1</a> and <a href="http://commons.apache.org/downloads/download_codec.cgi">commons-codec 1.3</a> in your classpath.</p>
<p>The second solution, if you don&#8217;t want to recreate the axis.jar file, is to use an <code>EngineConfiguration</code> and pass the new handler to it programmatically.</p>
<pre class="brush: java;">
EngineConfiguration engine = EngineConfigurationFactoryFinder.newFactory().getClientEngineConfig();
SimpleProvider provider = new SimpleProvider(engine);
provider.deployTransport(&quot;http&quot;, new CommonsHTTPSender());
</pre>
<p>Then you will need to pass this provider instance in your web service class that extends the <code>org.apache.axis.client.Service</code>. This can be done by passing it in the constructor of your service class.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thejavablog.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thejavablog.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thejavablog.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thejavablog.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thejavablog.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thejavablog.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thejavablog.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thejavablog.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thejavablog.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thejavablog.wordpress.com/167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=167&subd=thejavablog&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thejavablog.wordpress.com/2009/04/15/0null/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c619b1ddf3905d8bc061a992b4e0a0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Panos</media:title>
		</media:content>
	</item>
		<item>
		<title>Devoxx &#8211; Day 4</title>
		<link>http://thejavablog.wordpress.com/2008/12/11/devoxx-day-4/</link>
		<comments>http://thejavablog.wordpress.com/2008/12/11/devoxx-day-4/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 18:02:11 +0000</pubDate>
		<dc:creator>Panos</dc:creator>
				<category><![CDATA[devoxx]]></category>

		<guid isPermaLink="false">http://thejavablog.wordpress.com/?p=150</guid>
		<description><![CDATA[The day started with a second keynote in room 8. Stephan Janssen talked for a few minutes and asked everyone who hasn&#8217;t voted to vote on the whiteboards for Java 7 features. Then Joshua Bloch started his talk by showing some optical illusions and he said that, like optical illusions, things in Java are not what they [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=150&subd=thejavablog&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The day started with a second keynote in room 8. <a href="http://www.devoxx.com/display/JV08/Stephan+Janssen">Stephan Janssen</a> talked for a few minutes and asked everyone who hasn&#8217;t voted to vote on the whiteboards for Java 7 features. Then <a href="http://www.devoxx.com/display/JV08/Joshua+Bloch">Joshua Bloch</a> started his talk by showing some optical illusions and he said that, like optical illusions, things in Java are not what they seem to be sometimes. He then explained what i new in his <a href="http://java.sun.com/docs/books/effective/">Effective Java</a> book.</p>
<p>What new in effective java</p>
<ul>
<li>chapter 5: generics</li>
<li>chapter 6: enums and annotations</li>
<li>one or more changes on all other java 5 language features</li>
<li>threads chapter renamed concurrency</li>
</ul>
<p>Generics are invariant, this means that a List&lt;String&gt; is not a subtype of a List&lt;Object&gt;. It&#8217;s good for compile time safety, but inflexible. That&#8217;s why the added wildcards. It&#8217;s easy to use wildcards if you remember the PECS – Producer Extends Consumer Super</p>
<ul>
<li>For a T producer, use Foo&lt;? extends T&gt;</li>
<li>For a T consumer, use Foo&lt;? super T&gt;</li>
</ul>
<p>This only applies to input parameters. Don&#8217;t use wildcards for return types. Of course there are rare exceptions to this rule.</p>
<p>For the rest of his talk Joshua went through some examples from his Effective Java book and explained the gotchas o the seemingly easy to understand code.</p>
<p>Next one on was <a href="http://www.devoxx.com/display/JV08/Mark+Reinhold">Mark Reinhold</a> which talked about the modular Java platform. He started by explaining why a &#8220;Hello World&#8221; programme in python is faster than a &#8220;Hello World&#8221; programme in Java. the answer is simple, Java needs to load 332 classes (it needs to resolve all reference, do the verification etc) in order to run the &#8220;Hello World&#8221;. By modularising the JDK will force the separate components to identify themselves and reduce the number of classes that are needed to be loaded, thus reducing loading and run time.</p>
<p>Then he talked about the JSR 294 (and also mentioned that JSR 277 is not dead, it&#8217;s just on hold). The rest of the time was spent on talking about the <a href="http://blogs.sun.com/theplanetarium/entry/project_jigsaw_modularizing_jdk_7">project jigsaw</a>.</p>
<p>The requirements of a perform module system</p>
<ul>
<li>integrate with jvm</li>
<li>integrate with the language</li>
<li>integrate with native packaging</li>
<li>support multi-module packages</li>
<li>support “friend: modules</li>
</ul>
<p>In the JDK there will be added new features from Sun and other parties.</p>
<p>Big features from Sun</p>
<ul>
<li>JSR 294 + jigsaw</li>
<li>JSR 292 (VM support for dynamic languages)</li>
<li>JSR 203  (more new IO APIs)</li>
<li>JSR TBD: small language changes.</li>
<li>forward-port 6u10 features</li>
<li>java kernel, quickstarter, new plug-in, etc</li>
<li>safe re-throw</li>
<li>null-dereference expressions (this one he thinks is already in)</li>
</ul>
<p>Small featues from Sun</p>
<ul>
<li>SCTP (Stream Control Transmission Protocol)</li>
<li>Sockets Direct Protocol</li>
<li>upgrade class-loader architecture</li>
<li>method to close a UrlClassLoader</li>
<li>unicode 5.0 support</li>
<li>XRender pipeline for Java 2D</li>
<li>swing updates</li>
<li>JXLayer, DataPicker, CSS styling – maybe</li>
</ul>
<p>Fast features from sun</p>
<ul>
<li>Yet more HotSpot run-time compiler enhancements</li>
<li>G1 garbage collector</li>
<li>compressed-pointer 64-bit VM</li>
<li>MVM-lite – maybe (MVM – Multiple Virtual Machines)</li>
</ul>
<p>Features from other:</p>
<ul>
<li>JSR 308: annotations on java Types (allows you to put annotation in more places than today) (see photo for example)
<ul>
<li>Prof. Michael Ernst. Mahmood Ali</li>
</ul>
</li>
<li>concurrency and collections updates</li>
<li>Doug Lee, John Bloch et al</li>
<li>Fork/Join framework</li>
<li>Phasers – Generalized barriers</li>
<li>LinkedTransferQueue  &#8211; Generalized queue</li>
<li>ConcurrentreferencehashMap</li>
<li>Fences – Fine-grained read/write ordering</li>
</ul>
<p>Features not in 7 (at least some of them)</p>
<ul>
<li>closures</li>
<li>other language features
<ul>
<li>reified generic types</li>
<li>operator overloading</li>
<li>BigDecimal syhtax</li>
<li>First-class properties</li>
</ul>
</li>
<li>JSR 295: beans binding</li>
</ul>
<p>Jdk 7 will be released early 2010</p>
<p><a href="http://www.devoxx.com/display/JV08/Towards+a+dynamic+VM"><strong>Towards a Dynamic VM</strong></a> by <a href="http://www.devoxx.com/display/JV08/Brian+Goetz">Brian Goetz</a> and <a href="http://www.devoxx.com/display/JV08/Alex+Buckley">Alex Buckley</a></p>
<p>The talk started with Brian Goetz explaining what a virtual machine is; a software implementation of a specific computer architecture. This computer architecture could be a real hardware architecture or a fictitious one.</p>
<p>there are several system virtual amchines that emulate a complete computer system (CMWare, VirtualBox, VirtualPC, Parallels)</p>
<p>Virtual machines isolate the hosted application from the host system (a virtual machine appears as an ordinary process in the host system)</p>
<p>Virtual machines isolate the host system from the hosted application (a virtual machine acts as an intermediary between hosted application and host system)</p>
<p>Virtual macines provide a higher level of abstraction</p>
<ul>
<li>sensible layer for portability across underlying platforms</li>
<li>abstracts away low-level architctural considerations
<ul>
<li>size of register set, hardware word size</li>
</ul>
</li>
<li>1990s buzzword ANDF</li>
</ul>
<p>Nowadays virtual machines win as compilation targets</p>
<ul>
<li>Today it is silly for a compiler to target actual hardware
<ul>
<li>much more effective to target a vm</li>
<li>writing a native compiler is a lots more work</li>
</ul>
</li>
<li>languages need runtime support
<ul>
<li>C runtime is tiny and portable (and wimpy)</li>
<li>more sophisticated language runtimes need
<ul>
<li>memory management</li>
</ul>
</li>
<li>security</li>
<li>reflection</li>
<li>tools</li>
</ul>
</li>
</ul>
<p>If a virtual machine doesn&#8217;t provide the feature you need you have to either write it yourself  or do without them. If the virtual machine does provide them you will use them which is less work for you and makes your programming language better (eg gc makes the programmign easier and better).</p>
<p>Targeting existing vistual machines also reuses libraries and tools, debugegers, IDE, profilers, management tools etc.</p>
<p>Vistual machine-based facilites become common across languages (Java code can call JRuby code, Java objects and Jython objects are garbage-collected together).</p>
<p>The best reason to target a virtual machine as a compilation target is the HotSpot JIT compiler. The compiler can generate bytecode and feed it to hotspot. A lot of optimisation that the dynamic compiler can do is harder than the standard compiler since it has to go through loads more info that&#8217;s not available to standard compilers. A dynamic compiler can use adaptive and speculative techniques (compile optimistically, deoptimise when proven necessary). Targeting a VM allows compilers to generate “dumb” code and let the dynamic compiler to optimise it (the VM will optimise it better at runtime anyway).</p>
<p>There are loads of VMs out there (Java VM, .NET CLR, SmallTalk, Perl, Python, YARV, Valgrind, Lua, Dalvik, Flash, Zend etc). There are so many because each one was designed to solve specific problem.</p>
<p>You have to make loads fo choices when you design a VM, like the instruction set, where do you store data (stacks like Java does or registers), what data types do you care about, “is everything an object”, choices about the instruction format, what kinds of instruction we want to inlclude (primitives, implementation flexibility), object model (is it class based like Java or obect based like JavaScript), strongly typed or weakly typed, do you trust your compilers (there is loads of bytecode that the JVM will accept but would never be produced by the JDK), how are errors handled, can we call native code?</p>
<p>jvm architecture</p>
<ul>
<li>stack-based programmes representation and execution</li>
<li>core instructions</li>
<li>data types: objects, arrays, eight primitive types</li>
<li>object model: single inheritance with interfaces</li>
<li>dynamic linking
<ul>
<li>untrusted code from the web motivates static typechecking (at load-time)</li>
<li>symbolic resolution dynamically (base classes are not fragile in the JVM)</li>
</ul>
</li>
</ul>
<p>We see some common patterns in a JVM like objects, signed integers, single inheritance, static typechecking etc. These features can actully form a VM for many programming languages, many of them unknow to most people (phobos, Piccola, SALSA, ObjectScript, FScript, Anvil, Smalltalk etc). Early enough (1997) in the JVM specification they stated that the JVM does not know anything about the Java programming language but only about the bytecode.</p>
<p>Some features are easy to implement for a universal VM (like checked exceptions in Java) but some others are very dicfficult to implement effectively (open classes in Ruby, alternate numeric towers a la Scheme).</p>
<p>JSR 292 often called the “invokedynamic” JSR because it originally proposed a specific bytecode for method invocation but the scope has widened since then. The work curently that goes into JSR 292 includes <code>invokedynamic</code> bytecode (allows the language runtime to work hand in had with the jvm on method selection), method handles (many languages have constructs like closures, classe are too heavy as container for a single block of code), interface injection (add new methods and types to existing classes).</p>
<p>Virtual method invocation in java</p>
<ul>
<li>the only dynamism for the method invocation is for the receiver
<ul>
<li>different implementation os size() for ArrayList vs LinkedList</li>
<li>this is called single dispatch. Java;s method selection algorithm doesn&#8217;t  (and can&#8217;t) consider the runtime types of arguments given</li>
<li>invokevirtual Foo.bar: (int)int</li>
</ul>
</li>
<li>the jvm looks for bar: (int) int in the class of the receiver (the receiver is reference dform the stack)</li>
<li>if the receiver&#8217;s class doesn&#8217;t have this method, the JVM recurses up to its superclass&#8230;</li>
<li>repeated recursive method lookup makes invocation slow
<ul>
<li>fortunatelly, this can often be heavilly optimized</li>
</ul>
</li>
<li>divirtualize monomorphic methods
<ul>
<li>if vm can prove there is only one target method body, then invocation turns into a single jump</li>
<li>can then inline the mehod call avoiding invocation overhead</li>
<li>bigger basic blok enables further optimizaroins</li>
<li>inline cachng</li>
<li>figure out th emost like receiver type for a call site and cache it</li>
<li>optimizes for th emost likely case(s)</li>
</ul>
</li>
</ul>
<p> </p>
<p>But compiling dynamic languages directly to JVM is tricky. Many dynamic languages have no receiver type, no static argument type and maybe the return type isn&#8217;t even boolean (in the code below), maybe it&#8217;s the type of x or y.</p>
<p><code>function max(x, y)<br />
{<br />
   if x &gt; y then x else y;<br />
}</code></p>
<p>Dynamic typed method invocation</p>
<ul>
<li>dynamic is a magic type</li>
<li>no such type in the jvm today</li>
<li>but if the jvm had Dynamic, invokeinterface is almost flexible</li>
</ul>
<p>How can a language runtime manage dynamic invocation?</p>
<ul>
<li>creative solutions have been proposed
<ul>
<li>could define an interface for each possible method signature
<ul>
<li>complex, fragile, expensive</li>
</ul>
</li>
</ul>
</li>
<li>could use reflection for everything
<ul>
<li>use “inline caching” trick to cache method objects for specific combinations of argument types</li>
<li>but heavyweight and slow if you use it for every method call</li>
</ul>
</li>
<li>it&#8217;s easy to conclude “the jvm isn&#8217;t a match for dynamic languages”</li>
</ul>
<p>A little help goes a long way</p>
<ul>
<li>it turns out that the static type checking is closer to the surface than it first appears</li>
<li>the big need: first-class language specific method resolution
<ul>
<li>so the lanfiage can identify the call target</li>
<li><strong> <span> </span>but then get out of the VM&#8217;s way</strong></li>
</ul>
</li>
<li>this is the rationale behind invokedynamic</li>
</ul>
<p> <br />
The first time the jvm sees an <code>invokedynamic</code> instruction it calls a bootstrap method which does all the work. Bootstrap chooses the ultimate method to be called. The vm associates that method with the <code>invokedynamic</code> instruction. The next time the jvm sees the instruction it jumps oto the previously chosen method immediately.</p>
<p>Putting it all together</p>
<ul>
<li>jvm method invocatio is still sttically typed</li>
<li>the ultimate method invoked is arbitrary</li>
<li>depends on the language rules</li>
<li>could even have a different name than in the instructions</li>
</ul>
<p>method handles are composable</p>
<ul>
<li>and adapter method handle takes another method handle and executes code before and after invoking it.</li>
<li>endless applications!
<ul>
<li>coercing types of individual arguments</li>
<li>java.lang.String -&gt; org.juby.RubyString (different encodign)</li>
<li>boxing all argument sinto a boxing array</li>
<li>pre-allocating stack frames</li>
<li>prepare thread-specific context</li>
</ul>
</li>
</ul>
<p>Interface injection</p>
<ul>
<li>dynamically typed programs look like self modifying code</li>
<li>generally, self modifying code is dangerous and hard to optimize</li>
<li>idea: don&#8217;t restructure classes, just relabel themselves</li>
<li>interface injection: the ability to modify old classes just enough for them to implement new interfaces
<ul>
<li>superinterfaces are cheap for jvm object</li>
<li>invokeinterface is fast these days</li>
</ul>
</li>
<li>if an interface-dependent operation is about to fall, call a static injector method to bind an interface to the object and provide MethodHandles for the interface&#8217;s methods.
<ul>
<li>one change only for the injector to say yes!</li>
</ul>
</li>
</ul>
<p><a href="http://www.devoxx.com/display/JV08/Don%27t+do+it+-+Common+Performance+Antipatterns"><strong>Don&#8217;t do it! &#8211; Common performance Antipatterns</strong></a> by <a href="http://www.devoxx.com/display/JV08/Alois+Reitbauer">Alois Reitbaeur</a></p>
<p>In this session the room was literally full. There were people sitting on the corridor and on the floor near the speaker. Unfortunatelyl I didn&#8217;t find a place to sit and I was standing (at some point I sat down) therefore I didn&#8217;t get any notes. Things I remember from the session:</p>
<p>don&#8217;t do premature optimization, even if it&#8217;s very tempting. Never do it. Never take care of performance at an early stage, only do it at a later stage.</p>
<p>Good programmers write good performing code. They might be functional bugs, this is acceptable, but there shouldn&#8217;t be many performance problems.</p>
<p>Performance management is diffcult because it&#8217;s difficult to find performance problems. performance is a moving target, it works today but it might not work tomorrow. Even testing does not prevent you from having performance problems.</p>
<p><a href="http://www.devoxx.com/pages/viewpage.action?pageId=1377902"><strong>How do we test this stuff??</strong></a> by <a href="http://www.devoxx.com/display/JV08/Frank+Cohen">Frank Cohen</a></p>
<p>I met Frank at the jug leaders and speakers dinner on Tuesday and I really wanted to see his talk. </p>
<p>Frank talked about his <a href="http://www.pushtotest.com/">pushTotest</a> tool which is an open source tool sthat helps you test web services and web applications. With pushToTest you can surface issues quickly, you can create automated functional tests and have SLA compliance monitoring and provides an integrated environment.</p>
<p>The reasons behind having an integrated environment are simple</p>
<ul>
<li>organizations require test and operational management
<ul>
<li>Ajax commerical testing tools not keeping up</li>
<li>where is the test tool for GWT, YUI, Dojo, Appcelarator?</li>
</ul>
</li>
<li>organisations benefit from integration test and operational management
<ul>
<li>repurpose tests among developers, QA, ops</li>
</ul>
</li>
<li>makes build + test-first possible
<ul>
<li>very agile, very rapid, bvery inexpensive</li>
</ul>
</li>
</ul>
<p>Then a demo followed with some screenshots and a walkthrough some source code.</p>
<p><a href="http://www.devoxx.com/display/JV08/Preventing+bugs+with+pluggable+type-checking+for+Java"><strong>Preventing bugs with pluggable type checking for Java</strong></a> by <a href="http://www.devoxx.com/display/JV08/Mahmood+Ali">Mahmood Ali</a></p>
<p>Some otes I wrote down</p>
<p>benefits of type qualifiers</p>
<ul>
<li>improve documentation</li>
<li>find bugs in programmes</li>
<li>guarantee the absence of errors</li>
</ul>
<p>Checkers:</p>
<ul>
<li>@NonNull: null dereference</li>
<li>@Internal: incorrect equality tests</li>
<li>@ReadOnly: incorrect mutation and side-effects</li>
<li>Many other simple checkers
<ul>
<li>security, encryption, access control</li>
<li>format/encoding, SQL</li>
<li>checkers designed as compiler plugins and use familiar error messages</li>
</ul>
</li>
</ul>
<p> <br />
A nullness and mutation demo followed</p>
<p>Checkers are fearful:</p>
<ul>
<li>full type systems, assignment, overriding</li>
<li>polymorphic (Java generics)</li>
<li>flow sensitive type qualifier inference</li>
</ul>
<p>Checkers are effective</p>
<ul>
<li>scales to &gt; 200.000 LOC</li>
<li>each checker found errors in each code base it ran on</li>
</ul>
<p>Checkers are usable:</p>
<ul>
<li>tool support javac, Ant, Eclipse, NetBeans</li>
<li>not too verbose
<ul>
<li>@NonNull: 1 annotation per 75 lines</li>
<li>@Interned: 124 annotation in 220 KLOC revealed 11 errors</li>
</ul>
</li>
<li>fewer annotations in new code</li>
<li>inference tools: nullness, mutability</li>
</ul>
<p>Another demo followed at this point.</p>
<p>Summary</p>
<ul>
<li>pluggable type checkers
<ul>
<li>featureful, effective and usable</li>
</ul>
</li>
<li>programmers can
<ul>
<li>find and prevent bugs</li>
<li>obtain guarantees that program isfree of certain errors</li>
<li>create custom qualifiers and type checkers</li>
</ul>
</li>
</ul>
<p> <br />
If you want to learn more have a look here: <span><a href="http://pag.csail.mit.edu/jsr308">http://pag.csail.mit.edu/jsr308</a></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thejavablog.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thejavablog.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thejavablog.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thejavablog.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thejavablog.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thejavablog.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thejavablog.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thejavablog.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thejavablog.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thejavablog.wordpress.com/150/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=150&subd=thejavablog&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thejavablog.wordpress.com/2008/12/11/devoxx-day-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c619b1ddf3905d8bc061a992b4e0a0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Panos</media:title>
		</media:content>
	</item>
		<item>
		<title>Devoxx &#8211; Day 3</title>
		<link>http://thejavablog.wordpress.com/2008/12/10/devoxx-day-3/</link>
		<comments>http://thejavablog.wordpress.com/2008/12/10/devoxx-day-3/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 19:39:29 +0000</pubDate>
		<dc:creator>Panos</dc:creator>
				<category><![CDATA[devoxx]]></category>

		<guid isPermaLink="false">http://thejavablog.wordpress.com/?p=137</guid>
		<description><![CDATA[First day of the conference today, the keynote started at around 9.45. The whole room was packed and a guy called roxorloops did some beat boxing to entertain the attendees. Quirte impressive I&#8217;d say.
Next Stephan Janssen welcomed everyone and announced a few facts and updates about Devoxx. This is the first edition of Devoxx (after [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=137&subd=thejavablog&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>First day of the conference today, the keynote started at around 9.45. The whole room was packed and a guy called roxorloops did some <a href="http://en.wikipedia.org/wiki/Beatboxing">beat boxing</a> to entertain the attendees. Quirte impressive I&#8217;d say.</p>
<p>Next <a href="http://www.devoxx.com/display/JV08/Stephan+Janssen">Stephan Janssen</a> welcomed everyone and announced a few facts and updates about Devoxx. This is the first edition of Devoxx (after it has been renamed Devoxx from JavaPolis) which is sold out with 3.200 attendees (from 35 countries all over the world), 160 speakers, more rooms (6 rooms this times, as opposed to five in last year). There are 40 partners at the exhibition floor, 40 affiliated Java User Groups and also 400 students had the opportunity to come in for free in the first two days of the university.</p>
<p>Stephan said a BIG thank you to Devoxx programme committee and the to Devoxx administration team. As a side note he asked us to be gentle with the venue and take care of it. Do not litter it, do not abuse it, and keep the place clean and quiet. Also be gentle with the wireless network and do not download big files (to day for some reason the network is very fast, compared with the previous years and the fist two days. Well done). Stephan also announced that this afternoon they will be serving free beer (hope not as strong as the one I had in the jug leaders and speakers dinner last night, 10% alcohol!) and free fries.</p>
<p>He also said that people complain that the <a href="http://www.bejug.org">Belgian JUG</a> apart from Devoxx is not organising anything else. Stephan explained that he didn&#8217;t have enough time since the preparations for Devoxx start 8 to 9 months before December. But he has quit his current job and has more time to dedicate now. As a ersult of this BeJUG will organise bi-weekly evening session for 150 maximum throughout Belgium. This is 18 meetings in total (no meeting during December and Summer holidays). Fro more info visit the BeJUG site.</p>
<p>After Stephan stepped down <a href="http://blogs.sun.com/dannycoward">Danny Coward</a> from Sun Microsystems stepped on and talked about <a href="http://www.javafx.com/">JavaFX</a>. He also announced that Sun is dedicated to always be shipping final production software only.</p>
<p>Next he talked about the 10 things we need to know about JavaFX</p>
<p>1) JavaFX is here, it was released on the 4th of December. Sun released a preview in July this wear, a preview of the SDK. JavaFX SDK (which includes the runtime for the desktop and the emulator which allows to deploy on desktop, on browser or mobile phones). NetBeans 6.5 has support for JavaFX. He also mentioned the JavaFX production suite which is a collection of tools that lets the JavaFX developer to work with graphics to create RIA. JavaFX also ships with 75+ sample applications</p>
<p>2) JavaFX defines a cool new language. Why do we need a new language? Languages are evolving rapidly. People in Sun learn from their experience and they put the best best features of the language they have worked so far. JavaFX script was purpose built for only RIA in mind, nothing else. It&#8217;s declarative, has a Java like syntax, supports data binding and event triggers.</p>
<p>3) JavaFX supports beautiful graphics. They take advantage of the Java layer for graphics. JavaFX provides support for graphics acceleration, javaFX scene graph, animations and lighting. At this point Richard Bair presented a demo of a video puzzle. The video was playing and it became a jigsaw and they had to put the pieces together. After this small video they explained the relevant source code.</p>
<p>4) JavaFX has a rich APIs set. They have created a simple to use JavaFX script. The API also supports scene graph, media, web services (RESTFUL) and &#8230; any Java API.</p>
<p>5) Greater developer tools. The NetBeans plugin for JavaFX includes first class projects, JavaFX script editing, code completion, compile and save, debugging, graphics peeview, integrated documentation, deploy to desktop/browser/mobile.</p>
<p>6) JavaFX integrates into graphics design tools. JavaFX production suite includes tools for developer/designer workflow, export design from adobe tools, import and integrate into JavaFX. Then they showed a demo of the JavaFX production suite.</p>
<p>7) JavaFX runs on multiple devices. Then one more demo followed by a JavaFX application running on a mobile phone.</p>
<p> <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> It is built on Java. Great advantage since you can rely on 13 years of JVM implementation. You can rely on this robustness and scalability of the underlying technology.</p>
<p>9) Encode once, play anywhere media. Developers have been asking for years for better media support. They support the native media frameworks (mac native and windows native). The added a new cross platoform format (FXM) which means if they use this format the media will play in any JavaFX-enabled device. Another demo by Joshua Marinacci followed, the Fox Box which was basically amovie website with several movies playing at the same time and Joshua could play with video properties and the video could be dragged outside the browser to watch it as standalone application.</p>
<p>10) JavaFX deploys itself. Anywhere there is a JRE the JavaFX runtime will deploy. JRE is installed on 9/10 new PCs. More than 30-50 million downloads per month. Full FX mobile release will be in March.</p>
<p>At this point there was another break with the beatboxing guy again doing some amazing sounds.</p>
<p>Next was Bart Donn, Christophe De marlie, Robin Mulkers from <a href="http://www.ibm.com">IBM</a>. They talked about <a href="http://en.wikipedia.org/wiki/RFID">RFID</a> @ Devoxx 2008 (this is I think the same technology used in JavaOne last year).</p>
<p>RFID is a new project installed at Devoxx. But why do we need a project during Devoxx? Instead of giving goodies during Devoxx they decided to spend this money to start a project and benefit everyone. The partners of this project are: IBM, <a href="http://www.intermec.com/">Intermec</a> and <a href="http://www.skillteam.com/">SkillTeam</a>.</p>
<p>Then they showed the followingvideo that gives an introduction to the RFID concept. Nice ad.</p>
<p><span style="text-align:center; display: block;"><a href="http://thejavablog.wordpress.com/2008/12/10/devoxx-day-3/"><img src="http://img.youtube.com/vi/9WV3_jYB5HU/2.jpg" alt="" /></a></span></p>
<p>The rest of the talk was spent by talking about the RFID technology and how IBM has developed it.</p>
<p><a href="http://www.devoxx.com/display/JV08/From+Concurrent+to+Parallel"><strong>From Concurrent to Parallel</strong></a> (by <a href="http://www.devoxx.com/display/JV08/Brian+Goetz">Brian Goetz</a>)</p>
<p>This was actually the same talk Brian Goetz gave at JavaOne in May. I won&#8217;t go into details since I have written about that in <a href="http://thejavablog.wordpress.com/2008/05/07/javaone-day-two/">this post</a>.</p>
<p><strong><a href="http://www.devoxx.com/display/JV08/Effective+Pairing+The+Good%2C+the+Bad+and+the+Ugly">Effective pairing: the good the bad and the ugly</a> </strong>(by <a href="http://www.devoxx.com/display/JV08/Dave+Nicolette">Dave Nicolette</a>)</p>
<p>This was an interactive session again when people started pairing in front of the audience and played different pair-programming scenarios. This session talked about pair programming, its problems and how we can overcome them.</p>
<p>We started with a pair-programming scenario where one impersonated a senior developer and the other a junior developer. The problem demonstrated was that the senior developer didn&#8217;t want to let the junior do anything. The senior always had the upper hand and didn&#8217;t let the junior do anything and was always picking on the junior guy.</p>
<p>Teams are most affective when everyone can learn about the technologies and the problem. If the senior guy just holds the keyboard and does his own stuff it&#8217;s not a good thing. Junior developers learn by typing and practising. The junior should do the typing and the senior the driving. But the senior thinks that sometimes the project goes a little snow and wants to take over things. But the slowing of the project is a normal thing if you want the junior developers to learn. You loose a bit in project time but you gain later in the project. The tip is to have the less experienced person on the keyboard</p>
<p>Another scenario is the soloist. People who want to do this themselves because they think they know the problem ad thus the solution and can work better on their own. Everyone in the team has difficulty learning the problem they&#8217;re dealing with. The solution is everyone to know the problem and know how the system works and how to deal with it. This is the bus and team problem, if the lead developer is hit by a bus, how many people can take over the project?  Everyone in the team should try to have equal knowledge of the problem and the system in use.</p>
<p>Another scenario, one doesn&#8217;t follow the other while they&#8217;re discussing ideas. This can be because one has far more knowledge than the other or because one always changes his mind about ideas and software patterns. Problems arise because one might feel stupid. Another problem is that when someone changes always his mind, they might step away from the problem the customer needs solved. People need to learn how to work with different types of personalities. In pair programming one should make the other stay in touch with the original problem. And both of them can cancel each other&#8217;s problems and/or expose their abilities. Also we should need to give emphasis on the simplest design (this is agile development). Sometimes when we have many ideas and we change our mind all the time we make the solution more complex than necessary.</p>
<p>Fourth scenario, one of the persons in the pair has additional responsibilities and can make pairing difficult because he can be interrupted all the time. The team should be dedicated to the project, it should not be interrupted because one of the members of the team is assigned to other things. This usually when the testers are also the business analysts. There is another form of interruption too: when someone outside the team comes in and starts taking about nonsense that is not related to the project. This disrupts the pair when they try to work.</p>
<p>Pairing is really a kind of a discipline art. It&#8217;s not just sitting there talking with your friends. It really is work.</p>
<p>Fifth scenario. Physical working conditions in the team room. Pairing is usually done in an agile manner. The team is located in the same room, pairing wheer the team is located in different locations is not a good idea. Or the way the office is laid out. For instance desks and chairs for pairing might be laid out correctly but they there might only be one monitor. By doing this the pairt is loosing time because the second person cannot follow the code. A solution is to ask the manager to buy more monitors (monitors are less expensive than people). As a logical conclusion the working environment should be set up as to be easy for people to pair.</p>
<p>Scenario six. How to maintain the system and fix the bugs if the original application was not developed in an agile manner. If the application was developed by using agile methods there are probably test suites. The pair can check out the application and their test (the first step to fix the bug). Then they have to reproduce the bug. If the bar is green then it means that someone forgot to write the tests, or that someone put code into production without testing it. They can use the same techniques that the development team used. But if the bug refers to some kind of legacy application where there are no test cases the approach is different. In this situation you have to send someone in who knows the system and can fix the bug. This is not really a pairing scenario but good to mention in the pairing context.</p>
<p>Scenario seven, the Fearful Freddie, someone who&#8217;s afraid to change the code or can&#8217;t be bothered (too much of a hassle). This is a legacy scenario from old legacy systems where they had no tests cases and if you changed something you most certainly had broken it as well. Now things have changed. Even if you break something you can always reverse it by using the version control system. You don&#8217;t have to be afraid to change things. It&#8217;s better to change small things at once rather than do a big change. Like banks and bill payments, you don&#8217;t pay the bills at once but with small installments. Don&#8217;t let the complexity of the code build up over time, because you have problems maintaining the code and fixing it. You make the application&#8217;s life less. Because of the complexity of the code you actually need to implement a new one. And all this because people don&#8217;t want to modify the code and they are afraid to touch it.</p>
<p>Eighth scenario, the disengaged. One person that does the work and the other person is disengaged. The engaged person tries to get the other person  interested in the code they are working on. In this situation you have to remove the option from the other guy, just put the keyboard in front of him and ask him to do the job. What if the partners decide to do a major refactoring that will take 20 minutes and only one can use the keyboard? You don&#8217;t have to both use the keyboard, you just have to put your mind into work. Only one can type at the same time, but both of them can think. What if they want to do refactoring but they both have different ideas of how to refactor? A good idea is to ask the other team members about their opinions. You might disrupt them a bit but the benefits you gain are more.</p>
<p>Ninth scenario, the stubborn pair, when they both want to follow their ideas and they won&#8217;t change their mind. Another aspect of agile development is self-organisation. Every time there is a little dispute from the team you cannot run up to the manager to solve it because pretty soon the manager is going to take control. That might not be desirable, it might not be what you want. You take it to the manager and one person wins and the other looses (or both loose). The best thing to do when you have a problem like that is to take a break and clear your mind. A second solution is to change partner. Don&#8217;t let things become personal.</p>
<p>The Siamese twins scenario. Part of pair programming is that you change pairs (the original authors of pair programming called it promiscuous pair). Different pairs work differently, when one pair is finished the other pair is still working. So they have to take advantage of the spare time. There is a Pomodoro technique; a pair works together for a specific period of time and then they stop. Then take a break and start another time period with different partners.</p>
<p>The Siamese twins scenario kick in when two people are really engaged in the store they&#8217;re working on and they don&#8217;t want to separate. They work together well and they don&#8217;t want to switch. People should be able to switch, if they can&#8217;t they are probably stuck and they need a new pair of eyes to look in the problem they are looking into, a fresh pair. Sometimes people know they have problem, they know that the project falls behind but they don&#8217;t want to give up. The manager should not ask “how much longer will it take to solve the problem”, but assign new people to look into the problem.</p>
<p>The Ping pong scenario. One person writes the unit test and the other person writes the code to make the test pass. The person who writes the test leaves and lets the other guy to write the code. They are not talking about design, he just pushes the burden of design to the other person. This approach encourage single programming, but sometimes you can make it for a while in order to make the experience of programming a little bit different.</p>
<p>Q&amp;A:</p>
<p>What&#8217;s the bets way to learn pair programming? If never done it before then get mentors, outside people who have done it before</p>
<p>Should people pair all the time? No, there are some tasks that don&#8217;t really benefit from it. Sometimes the best way for the team to solve the problem is to have one person go and think about it and figure out how to do it. In an 8 hour day the pair should be around five-five and a half.</p>
<p><a href="http://www.devoxx.com/display/JV08/Behavior+driven+development+in+Java+with+easyb">Behaviour driven development in Java with easyb</a> (by <a href="http://www.devoxx.com/display/JV08/John+Ferguson+Smart">John Ferguson Smart</a>)</p>
<p>This was a talk about the <a href="http://easyb.org/">easyb</a> framework and behaviour driven development.</p>
<p>The talk started by explaining that TDD is not about tests, but about wring good software. In the same manner behaviour-driven development is not about behaviour, it&#8217;s about delivering software that helps the end-user. TDD in general tends to make better code, by the application being more flexible, more better designed and more maintainable.</p>
<p>BDD is a recent evolution of TDD. The idea is to help to determine what to test. In order to test use cases it uses words like “should” to describe the desired behaviour of the class, eg should verify that client can repay before approving loan, should transfer money from account a to account b. As with TDD you should also focus on requirements not on implementation.</p>
<p>The framework to do BDD is easyb which is an os testing framework for Java (but written in <a href="http://groovy.codehaus.org/">Groovy</a>). It makes testing clearer and easier to write. It makes tests self-documenting and it enhances communication between the development team and the end user. There is another BDD test framework for Java called <a href="http://jbehave.org/">JBehave</a> but on the speaker&#8217;s personal opinion it&#8217;s cumbersome to use. easyb is based on groovy but it has Java like syntax, it&#8217;s quick to write and you have full access to Java classes and APIs.</p>
<p>easyb in action test requirement by writing easyb stories which:</p>
<ul>
<li>use a narrative approach</li>
<li>describe a precise requirements</li>
<li>can be understood by a stakeholder</li>
<li>usually made up of a set of scenarios</li>
<li>use an easy to understand structure</li>
</ul>
<p>Lets look at an example user story: opening a bank account. “As a customer I want to open a bank account so that I can put my money into a safe place”. We come up with a list of tasks. Open account, make initial deposit etc. Lets concentrate on the initial deposit requirement:</p>
<p>Make initial deposit:</p>
<ul>
<li>given a newly create account</li>
<li>when a deposit is made</li>
<li>then the account balance should be equal to money deposited.</li>
</ul>
<p>You implement the scenario in a test test case written in Groovy which can use all Java APIs.</p>
<p>If we had to compare easyb to JUnit</p>
<ul>
<li>more boilerplate code required in JUnit</li>
<li>not very self-explanatory</li>
<li>the intention is less clear.</li>
</ul>
<p>With easyb you can have multiple post and pre conditions.</p>
<p>In easyb you have <code>shouldBe</code> syntax instead of assert. Variations of the <code>shouldBe</code> syntax include <code>shouldBeEqualTo</code>, <code>shouldNotBe</code>, <code>shouldHave</code> etc. Also there is another way to verify outcome, the <code>ensure</code> syntax, which is much like Java <code>assert</code>.</p>
<p>Fixtures in easyb; you can use <code>before</code> and <code>before_each</code> (similar to <code>@Before</code> and <code>@BeforeClass</code> in JUnit). Very useful for setting up database and test servers. You an also use <code>after</code>, <code>after_each</code> (similar to <code>@After</code> and <code>@AfterClass</code>)</p>
<p>Fixtures are good at</p>
<ul>
<li>keeping infrastructure code out of the test cases.</li>
<li>making test cases more readable and understandable.</li>
</ul>
<p>As for easydb plugins, only one is available, the dbunit. But more to come for Grails and Excel.</p>
<p>easyb produces test specifications in user-friendly format and flags pending (unimplemented) stories. Also provides readable error messages. When tests fail easyb will tell you why by a more readable manner than JUnit.</p>
<p>As for IDE support for easyb. There are three option options: IntelliJ, Eclipse, NetBeans, but only IntelliJ has a very good support for Groovy.</p>
<p>Some upcoming easyb features</p>
<ul>
<li>html reports</li>
<li>grails plugin</li>
<li>CI integration</li>
<li>Easiness – a <a href="http://fitnesse.org/">fitnesse</a> style web application (stake-holders create stories in normal text)</li>
</ul>
<p>The talk closed with an easyb demo and stepping through the source code of the test cases.</p>
<p><a href="http://www.devoxx.com/pages/viewpage.action?pageId=1704462">What&#8217;s new in Spring Framework 3.0</a> (by <a href="http://www.devoxx.com/display/JV08/Arjen+Poutsma">Arjen Poutsma</a> and <a href="http://www.devoxx.com/display/JV08/Alef+Arendsen">Alef Arendsen</a>)</p>
<p>New features in the upcoming 3.0 release and also some that already exist in 2.5 release.</p>
<p><code>@Controller</code> for Spring MVC.</p>
<p><code>@RequestMapping methods.</code></p>
<p><code>@RequestMapping(“/vets”)<br />
public List&lt;Vet&gt; vets()<br />
{<br />
return clinic.getVets();<br />
}<br />
</code><br />
Constantly simplifying, LoC for sample application PetClinic over time, it dropped significantly from Spring 2.0 to Spring 2.5.</p>
<p>Spring integration now in 1.0 version. released last week in SpringOne.</p>
<p><code>@PathVariable</code></p>
<p><code>@RequestMapping(“/pets/{petId}”)<br />
public Visit visit{<br />
@PathVariable long petId</code><br />
..</p>
<p>New Views with new MIME types:</p>
<ul>
<li>application/xml use MashallingView in 3.0M2/SWS 1.5</li>
<li>application/atom+xml use AtomFeedView 3.0M1</li>
<li>application/rss+xml use RssFeedView 3.0M1</li>
<li>application/json use JsonView Spring-JS</li>
</ul>
<p>ShallowEtagHeaderFilter</p>
<ul>
<li>introduces in Spring 3.0M1</li>
<li>creates ETag header based on MD5 of rendered view</li>
<li>saves bandwidth only</li>
<li>Deep ETag support comes in M2 (through @RequestHeader)</li>
</ul>
<p>At this point they presented a demo with URI support and ATOM feed by using Spring MVC.</p>
<p>Introducing expressions Spring 3.0 will include full support for expressions.</p>
<p>Spring 3.0 will only be available for people who use Java 5. It will support the Portlet 2.0 specification. And depending on specs finalising (if they are released on time) it will support Java EE6, the Servlet 3.0, JSF 2.0, JAX-RS and JPA 2.0. It will also support Web Beans annotations.</p>
<p>Spring 3.0 will deprecate/remove several stuff:</p>
<ul>
<li>traditional Spring MVC controller jierarchy</li>
<li>Commons Attributes support</li>
<li>Traditional TopLink support</li>
<li>Traditional JUnit 3.8 class hierarchy.</li>
</ul>
<p>but it will still be</p>
<ul>
<li>95% backwards compatible with regards to APIs</li>
<li>99% backwards compatible in the programming model.</li>
</ul>
<p>Spring 3.0M1 released last week.<br />
Spring 3.0 Milestones Janurary/February 2009<br />
Spring 3.0 Release Candidates March/April 2009</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thejavablog.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thejavablog.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thejavablog.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thejavablog.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thejavablog.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thejavablog.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thejavablog.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thejavablog.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thejavablog.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thejavablog.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=137&subd=thejavablog&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thejavablog.wordpress.com/2008/12/10/devoxx-day-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c619b1ddf3905d8bc061a992b4e0a0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Panos</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/9WV3_jYB5HU/2.jpg" medium="image" />
	</item>
		<item>
		<title>Devoxx &#8211; Day 2</title>
		<link>http://thejavablog.wordpress.com/2008/12/09/devoxx-day-2/</link>
		<comments>http://thejavablog.wordpress.com/2008/12/09/devoxx-day-2/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 18:14:52 +0000</pubDate>
		<dc:creator>Panos</dc:creator>
				<category><![CDATA[devoxx]]></category>

		<guid isPermaLink="false">http://thejavablog.wordpress.com/?p=121</guid>
		<description><![CDATA[This was a tough day for me, I got a very bad cold (the weather here is far worse than London) and it took loads of strength to go to the conference (as a side note I noticed that the sponsors&#8217; booths are already there, one day earlier than usual). Anyway, I started my day [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=121&subd=thejavablog&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This was a tough day for me, I got a very bad cold (the weather here is far worse than London) and it took loads of strength to go to the conference (as a side note I noticed that the sponsors&#8217; booths are already there, one day earlier than usual). Anyway, I started my day with three hours of Java tuning by attending the</p>
<p><a href="http://www.devoxx.com/display/JV08/Java+Performance"><strong>Java Performance</strong></a> by <a href="http://www.devoxx.com/display/JV08/Kirk+Pepperdine">Kirk Pepperdine</a> and <a href="http://www.devoxx.com/display/JV08/Holly+Cummins">Holly Cummins</a></p>
<p>I was a bit late for this talk since I arrived there ten minutes after it had started. I got there right after Kirk had explained the reasons why a Java application might be performing badly. After that he showed a demo of a web based application connecting to a server that was taking long to reply.</p>
<p>Each software system has dynamic and static aspects. Dynamic aspects include components such actors (usage patterns) and static aspects include components that do not change or manage/provide resources. Al these factors put load on our system. Each Java system can be further divided into:</p>
<ul>
<li>the application that does all the processing (it provides locks and includes external systems)</li>
<li>the virtual machine (it manages the memory and the hardware)</li>
<li>the hardware (this is not shareable and you have to have exclusive access to it). the hardware manages the CPU, the disk i/o, the memory and the network connections.</li>
</ul>
<p>In multithreaded systems loads of time is spent on waiting, every time we want to use a shared resource and someone else is using it we have to wait. So we might experience poor response times with possible reasons</p>
<ul>
<li>overflow is queued on every level</li>
<li>hardware lacks capacity</li>
<li>bad JVM implementation</li>
</ul>
<p>At the beginning we don&#8217;t really know anything about the cause of the bad performance. All we know is that the users are experiencing poor performance. This poor performance can be either at the operating system level, virtual machine level or application level (or on all simultaneously)</p>
<p>The operating system induced latency</p>
<ul>
<li> hardware management</li>
<li> symptoms include
<ul>
<li> relative high CPU utilisation</li>
</ul>
</li>
<li> high rates of context switching</li>
</ul>
<p>The virtual machine induced latency</p>
<ul>
<li>Java heap memory management
<ul>
<li>object creation</li>
<li>garbage collection</li>
</ul>
</li>
<li>symptoms include
<ul>
<li>high rates of object creation</li>
<li>low garbage collection throughput</li>
<li>likely to see high CPU utilisation</li>
</ul>
</li>
</ul>
<p>The application induced latency</p>
<ul>
<li>locks block thread from making forward progress (queuing)</li>
<li>synchronous calls to external systems park threads</li>
</ul>
<p>This latency is always expressed by inflated user response times.</p>
<p>If we have high CPU consumption the candidate consumers of CPU are the application (in this case we need to do execution profiling), the JVM (in this case we need to do memory profiling) or the os.</p>
<p>There is a wrinkle in all these:</p>
<ul>
<li>JVM and application run in the same user process.</li>
<li>Differentiate by monitoring the garbage collection.</li>
<li>The operating system needs to be reported separately</li>
<li>The operating system will prevent CPUs from being fully utilised</li>
<li>Kernel utilisation is a significant portion of overall utilisation</li>
<li>High rates of interrupt handling or context switching.</li>
</ul>
<p>The implications of the above are:</p>
<ul>
<li>applications are asking too much of the operating system</li>
<li>thread scheduling</li>
<li>system calls</li>
</ul>
<p>So how do we start our tests? We need to set up a test environment and do a benchmarking.</p>
<p>In order to expose kernel counters we can use the following command line tools: vmstat, mpstat, corestat. In order to monitor the garbage collection we can use:</p>
<ul>
<li>jvm switch -verbose gc</li>
<li>gchisto analysis tool (new)</li>
<li>hpjmeter</li>
</ul>
<p>At this point the speakers presented a demo with a tool called <a href="https://www14.software.ibm.com/iwm/web/cc/earlyprograms/ibm/ibmmdtjhc">health centre</a> by IBM.</p>
<p>As a synopsis when garbage collection throughput is very high we need to do object creation profiling. When application execution time is very high we need to do execution profiling.</p>
<p>We can diagnose CPU bound</p>
<ul>
<li>code is being invoked more than it needs to be (easy done with event-driven models)</li>
<li>an algorithm is not the most efficient (easily done without algorithms research)</li>
</ul>
<p>Fixing CPU bound application requires knowledge of what code is being run</p>
<ul>
<li>identity methods suitable for optimisation (optimise methods which the application doesn&#8217;t spend time on is a waste of time)</li>
<li>identify methods where more time is being spent than you expect</li>
<li>“why is so much of my profile in calls to this trivial little method?”</li>
</ul>
<p>There are two ways to work put what code is application is doing: trace and profiling</p>
<p>Trace</p>
<ul>
<li>does not require specialist tools (but is better with them)</li>
<li>records every invocation of a subset of methods</li>
<li>gives insight into sequence of events</li>
<li>in the simplest case System.out.println</li>
</ul>
<p>profiling</p>
<ul>
<li>samples all methods and provides statistics</li>
</ul>
<p>Method profiling</p>
<ul>
<li>validates algorithm performance
<ul>
<li>where is the application spending its time</li>
<li>am I getting benefits from that?</li>
</ul>
</li>
<li>identify methods where application is spending lots of time</li>
<li>why are they being called? can calls be reduced?</li>
<li>identify branches where time is being spent</li>
</ul>
<p>The IBM health centre it is designed to be</p>
<ul>
<li>live monitoring of applications</li>
<li>capabilities in a number of areas</li>
<li>method profiling</li>
<li>garbage collection</li>
<li>locking</li>
<li>configuration</li>
<li>visualisation and recommendations</li>
</ul>
<p>At this point the speakers did a benchmark (process by which we will measure and investigate performance) their demo application by using <a href="http://jakarta.apache.org/jmeter/">Apache JMeter</a> and <a href="http://grinder.sourceforge.net/">Grinder</a>.</p>
<p>In order to configure the benchmarking environment</p>
<ul>
<li>mirror production (box tells us, change a layer, change in the problem)</li>
<li>ensure adequate hardware for test harness (harness should not be the bottleneck)</li>
</ul>
<p>preliminary steps:</p>
<ul>
<li>review performance targets</li>
<li>plan on how to bring test to steady state</li>
<li>enable appropriate level of monitoring</li>
<li>too much will affect baseline results</li>
<li>system counters</li>
<li>gc</li>
<li>external system performance</li>
</ul>
<p>To establish a workload</p>
<ul>
<li>fixed amount of work measure the time</li>
<li>fixed amount of time measure the work</li>
</ul>
<p>Stumbling points when we set up the environment</p>
<ul>
<li>noise</li>
<li>randomisation and caching (systems are very good at caching, we cache everywhere)</li>
<li>randomisation and access patterns</li>
<li>complex usage patterns (really hard to cope with these things)</li>
<li>complex system interactions</li>
<li>stubbing out external systems</li>
<li>use mocks</li>
</ul>
<p>At this point the showed an Apache JMeter demo. JMeter is a closed system which means it</p>
<ul>
<li>supports limited number of users</li>
<li>user re-joins the line as soon as it is finished
<ul>
<li>source of artificial latency</li>
</ul>
</li>
<li>sell throttling</li>
<li>difficult to regulate request arrival rates (thread starvation)</li>
</ul>
<p>On the other hands open systems have:</p>
<ul>
<li>unlimited number of users</li>
<ul>
<li>users arrive according to some schedule</li>
</ul>
<li>possible to flood a system (this is desirable because if your systems performs poorly you want it to flood)</li>
</ul>
<p>closed harness when no of users is fixed<br />
open harness when no of users is not fixed</p>
<p>The garbage collection it&#8217;s more than collecting objects, it&#8217;s memory management. it can provide performance benefits by faster freeing of memory, by providing faster memory allocation and by providing faster memory access. Even in C freeing memory can be expensive with malloc/free.</p>
<p>Allocating memory also takes time and is particular slow when you have loads of threads and one heap (the threads will be fighting for the heap).</p>
<p>Finally not all access memory is equally fast. Garbage collection can speed up memory access by rearranging objects in memory.</p>
<p>Memory access is slow compared to instruction processing. To prevent memory access from being a bottleneck, memory caches are added since access to objects that are already in the cache is faster. On top of that most modern systems have a hierarchy of caches of increasing speed and decreasing size. When an object is loaded into the cache its neighbours are also loaded into the cache. This makes relative position of objects very important to memory access.</p>
<p>the garbage collector can hinder or help interaction with the cache</p>
<ul>
<li>cache pollution</li>
<li>depending on the algorithm gc may visit quite a memory during collection</li>
<li>the cache won&#8217;t be right for the applciation because it will be full of stuff the gc collection just visited
</li>
<li>compaction</li>
<ul>
<li>means are closer to their neighbours and morelikely to be in the cache</li>
<li>re-arrangement</li>
<li>objects are closer to their friends and more likely to be in the cache at the right time</li>
</ul>
</ul>
<p>Most JVMs provide more than one garbage collection algorithm. None of the policies are bad, but the default is not necessarily the best in every circumstance. All the different garbage collectors differ in the following</p>
<ul>
<li>when and how the work is done?</li>
<li>what happens to garbage?</li>
<li>how is the heap laid out?</li>
</ul>
<p>There are three types of garbage collectors:</p>
<ul>
<li>stop the world garbage collector</li>
<ul>
<li>all application threads stop</li>
</ul>
<li>incremental</li>
<ul>
<li>divided into smaller portions</li>
</ul>
<li>concurrent</li>
<ul>
<li>happens at the same time with the application.</li>
</ul>
</ul>
<p>Even when the garbage collector spends loads of time pausing application performance might be better. Why? because garbage collection is not just a garbage collection.</p>
<p>At this point they presented another demo of the Memory Visualizer tool that&#8217;s focused just on garbage collection. This tools works with all the VMs (the health centre works only with IBM VM).</p>
<p>And yet another demo with Eclipse Memory Analyzer tool this time.</p>
<p><a href="http://www.devoxx.com/display/JV08/Pro+Spring+2.5"><strong>Pro Spring 2.5</strong></a> (with <a href="http://www.devoxx.com/display/JV08/Joris+Kuipers">Joris Kuipers</a> and <a href="http://www.devoxx.com/display/JV08/Arjen+Poutsma">Arjen Poutsma</a>)</p>
<p>Another three-hours session, an overview of the new Spring 2.5 features.</p>
<p>Spring 2.5 is one of the first major frameworks with dedicated support for Java 6. It supports all new JDK 1.6 APIs supported (JDBC 4, JMX, JDK ServiceLoader API).  JDK1.4 and 1.5 still supported but there is no JDK 1.3 support.</p>
<p>There is improved JDBC support:</p>
<ul>
<li>JDBC 4.0</li>
<ul>
<li>native connections (java.sql.Wrapper)</li>
<li>LOB handling (setBlob/setClob)</li>
<li>new <code>SQLException</code> subclasses.</li>
</ul>
<li>other JDBC improvements</li>
<ul>
<li><code>SimpleJdbcTemplate</code></li>
<li><code>SimpleJdbcCall</code> and <code>SimpleJdbcInsert</code></li>
</ul>
</ul>
<p>They have added support for named parameters when we use the <code>JdbcTemplate</code>.</p>
<p>They have added support for JMX MX beans. MXBeans are a new addition to JMX and they provide better support for bundling related values (standard beans require custom classes). MXBeans can be registered by MBeanExporter (the JMX spec does not allow dynamic creation).</p>
<p>The new JDK ServiceLoader API (<code>java.util.ServiceLoader</code>) is use to register the service providers for services. The file <code>META-INF/services/my.service</code> defines the implementation classes for my.service. This is used by <code>Service(List)FactoryBean</code></p>
<p>Spring 2.5 also supports the Java 6 built-in HTTP server. It also supports HTTP-based remoting using <code>SimpleHttpInvokerServiceExporter</code> and <code>SimpleHessian/BurlapServiceExporter</code>. You can set up a JRE 1.6 HttpServer by using <code>SimpleHttpServerFactoryBean</code>.</p>
<p>Java EE 5 support</p>
<li>integrates seamlessly
<li>new Java EE 5 APIs supported</li>
<ul>
<li>Servlet 2.5, JSP 2.1 and JSF 1.2</li>
<li>JTA 1.1, JAX_WS 2.0 and JavaMail 2.4</li>
</ul>
<li>J2EE 1.4 and 1.3 still fully supported</li>
<ul>
<li>eg BEA WebLogic 8.1 and higher</li>
<li>eg IBM WebShere 1.5 and above.</li>
</ul>
</li>
<p>But in Spring 3 they will drop J2EE 1.3 compatibility.</p>
<p>Java EE 5 APIs:</p>
<ul>
<li>Support for unified expression language</li>
<li>JSF 1.2: <code>SpringBeanFacesELResolver</code></li>
<li>Consistent use of JSR-250 annotations</li>
<li>JTA 1.1.: support new
<li>TransactionSynchronizationRegistry</li>
</li>
<li>new JTA, JavaMail and JAX-WS support also available for stand-alone usage</li>
</ul>
<p>Spring 2.5 also supports the Java Connectivity API (JCA)</p>
<p>Other J2EE ehnancements that come with Spring 2.5 include:</p>
<ul>
<li>Spring 2.5 officially supported on IBM WAS 6.x</li>
<li>WebSphereUowTransactionManager</li>
<li>WebSphereTransactionManagerFactoryBean replacement</li>
<li>no new features, but uses supported IBM API</li>
</ul>
<p>Spring 2.5 also works well with OSGI. it provides a dynamic module system and is bundled as central packaging unit.</p>
<p>It also supports new configuration features such as annotations-driven configuration, JMS and JCA support, enhanced AspectJ support and annotations-driven MVC controllers.</p>
<p>Spring 2.5 embraces annotations. It supports JSR250 annotations and Spring specific annotations (makes the code spring dependent). This doesn&#8217;t mean that they prefer annotations to XML, XML is in no way deprecated. Spring specific annotations can be used if you need more power than the traditional annotations, and also if you don&#8217;t care about migrating your application to another framework):</p>
<ul>
<li>New @Autowired annotation</li>
<ul>
<li>autowiring by type</li>
<li>of fields methods and constructors</li>
<li>AutowiredAnnotationBeanPostProcessor</li>
</ul>
<li>Autowiring by type might have too many candidates</li>
<li>provide hints using qualifiers</li>
<li>through new @Qualifier annotation</li>
<li>on fields or parameters</li>
</ul>
<p>Annotations-based autowiring pros and cons</p>
<ul>
<li>pros:</li>
<ul>
<li>self-contained: no XML configuration needed</li>
<li>work in much more cases than generic autowiring (ant method or field)</li>
<li>JSR 250 or custom annotations keep your code from depending on Spring</li>
</ul>
<li>cons:</li>
<ul>
<li>requires classes to be annotated</li>
<li>configuration only per class not per instance</li>
<li>changes require recompilation</li>
</ul>
</ul>
<p>At this point they presented a demo demonstrating the the pet clinic and showed the capabilities of spring.</p>
<p>Spring 2.5 also provides extra support for AspectJ</p>
<ul>
<li>new bean(name) pointcut element</li>
<ul>
<li>for use in aspectj pointcuts</li>
<li>matches beans by name</li>
<li>supports wildcards</li>
</ul>
<li>no more need for BeanNamedAutoProxyCreator</li>
<li>support AspectJ load-time weaving through spring&#8217;s LoadTimeWeaver</li>
<li>driven by META-INF/aop.xml files</li>
<li>for any supported paltform</li>
<ul>
<li>generic spring vm agent</li>
<li>various app servers: Tomcat, Glassfish, OC4J</li>
</ul>
</ul>
<p>You can use AspectJ to inject instances of objects that have not been constructed by Spring.</p>
<p>Since we are not using proxies any more but AspectJ, we can apply aspects that we were not able to do it before. We don&#8217;t have to force everyone to go through the proxy instead of the real object. The programme becomes more natural.</p>
<p>Spring has its own web framework, the Spring MVC, which in Spring version 2.5 it has</p>
<ul>
<li>Java5 variant of MultiActionController</li>
<ul>
<li>including form handling capabilities</li>
</ul>
<li>POJO based</li>
<ul>
<li>just annotate your class</li>
<li>works in Servlet and Portlet container</li>
</ul>
<li>Several annotations</li>
<ul>
<li><code>@Controller</code></li>
<li><code>@Requestparam</code></li>
<li><code>@RequestMapping/@RequestMethod</code></li>
<li><code>@ModelAttribute</code></li>
<li><code>@SessionAttributes</code></li>
<li><code>@InitBinder</code></li>
</ul>
</ul>
<p>The test context framework</p>
<ul>
<li>revised-annotation based test frameworks</li>
<li>supports JUnit 4.4, TestNG as well as JUnit 3.8</li>
<li>supersedes older JUnit 3.8 base calsses</li>
<ul>
<li>AbstractDependencyInjetionSpringContextTests and friends</li>
<li>they&#8217;re still there for 1.4</li>
<li>will be deprecated in Spring 3.0</li>
</ul>
<li>convention over configuration</li>
<ul>
<li>use only annotations</li>
<li>reasonable defaults that can be overridden</li>
</ul>
<li>consistent support for spring&#8217;s core annotations</li>
<li>spring-specific integration testing functions</li>
<ul>
<li>context management and caching</li>
</ul>
</ul>
<p>Another pet clinic demo of spring followed at this point.</p>
<p><a href="http://www.devoxx.com/pages/viewpage.action?pageId=1377607"><strong>Profiler: the better debugger</strong></a> (by Heiko Rupp)</p>
<p>This was a very similar talk to the one Kirk and Holly gave this morning. Nothing new really here (I shouldn&#8217;t have gone but since I got in the room and I thought I&#8217;d stay).</p>
<p>Main points I wrote down:</p>
<p>A debugger is a tool that steps through code, can look at variables, stop/.pause the programme on exception or breakpoints. But there are issues with time-outs in larger applications.</p>
<p>A profiler  analyses the CPU and memory usage. The application runs while profiling and there is no view on content of the variables. Free profilers, NetBeans profiler, Eclipse TPTP, commerical profilers: JProfiler, JProbe.</p>
<p>Why use a profiler for debugging?</p>
<ul>
<li>start of call chain is unknown</li>
<li>call stack uses reflection</li>
<li>use of big complex frameworks</li>
<li>transaction timeouts render values invalid in the debugger</li>
</ul>
<p>And then a NetBeans profiler demo followed.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thejavablog.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thejavablog.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thejavablog.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thejavablog.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thejavablog.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thejavablog.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thejavablog.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thejavablog.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thejavablog.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thejavablog.wordpress.com/121/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=121&subd=thejavablog&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thejavablog.wordpress.com/2008/12/09/devoxx-day-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c619b1ddf3905d8bc061a992b4e0a0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Panos</media:title>
		</media:content>
	</item>
		<item>
		<title>Devoxx &#8211; University Day 1</title>
		<link>http://thejavablog.wordpress.com/2008/12/08/devoxx-university-day-1/</link>
		<comments>http://thejavablog.wordpress.com/2008/12/08/devoxx-university-day-1/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 18:01:57 +0000</pubDate>
		<dc:creator>Panos</dc:creator>
				<category><![CDATA[devoxx]]></category>

		<guid isPermaLink="false">http://thejavablog.wordpress.com/?p=92</guid>
		<description><![CDATA[Back in Antwerp for yet one more devoxx event, second only to J1. Five days of Java overdose, lets see what we have. Today the first talk I attended was
Kick start JPA with Alex Snaps and Max Rydahl Andersen.
This was a talk I wanted to attend since we are using JPA at work. The talk [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=92&subd=thejavablog&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Back in <a href="http://en.wikipedia.org/wiki/Antwerp">Antwerp</a> for yet one more <a href="http://www.devoxx.com/display/JV08/Home">devoxx</a> event, second only to <a href="http://java.sun.com/javaone/">J1</a>. Five days of Java overdose, lets see what we have. Today the first talk I attended was</p>
<p><strong><a href="http://www.devoxx.com/display/JV08/Kickstart+JPA">Kick start JPA</a></strong> with <a href="http://www.jroller.com/greenhorn/">Alex Snaps</a> and <a href="http://jaoo.dk/aarhus-2008/speaker/Max+Rydahl+Andersen">Max Rydahl Andersen</a>.</p>
<p>This was a talk I wanted to attend since we are using JPA at work. The talk started by Alex Snaps giving an overview about JPA and why we need an ORM framework. Traditional CRUD code using JDBC tends to be ugly and hard to maintain. JPA eliminates the need for JDBC (CRUD and Querying), provides inheritance strategies (class hierarchy to single or multiple tables), associations and compositions (lazy navigation and fetching strategies).</p>
<p>It is vendor independent and easy to configure by using annotations (but you can override them by using XML) and JPA is available outside JEE containers. And as of JPA 2.0 there is a dedicated JSR to it (<a href="http://jcp.org/en/jsr/detail?id=317">JSR 317</a>).</p>
<p>One of the goals of JPA is that it should be transparent, but, according to Alex, it&#8217;s not there yet and he doesn&#8217;t think it will ever be.</p>
<p>After this small introduction the speaker moved to explaining what an entity class is. In JPA</p>
<ul>
<li>entity classes should not be final or have final methods</li>
<li>entity classes have a no argument constructor</li>
<li>collections in entity classes should be typed to interfaces.</li>
<li>associations in entity classes aren&#8217;t mapped for you.</li>
<li>and there must be an id field in the entity class</li>
</ul>
<p>Entity classes support simple types:</p>
<ul>
<li>primitive &amp; wrapper classes</li>
<li>String</li>
<li>BigInteger &amp; BigDecimal</li>
<li>Byte &amp; Char arrays</li>
<li>Java &amp; JDBC temporal types</li>
<li>Enumeration</li>
<li>Serialisable types</li>
</ul>
<p>In JPA we can have class hierarchies like inheritance, entity support, polymorphic associations, and we can also map concrete and abstract classes by using the <code>@Enity</code> or <code>@MappedSuperclass </code>annotations.</p>
<p>There are a few ways to implement polymorphism in an JPA. We can have one table per class (and use a discriminator value, this is a viable solution but the table can get very big), we can have a joined subclass (a class for a table and then you join some subclasses which are in their own tables) and one table per concrete class (optional).</p>
<p>Many-to-one association is supported by using the <code>@ManyToOne</code> annotation:</p>
<pre class="brush: java;">
public class Person
{
    @ManyToOne
    private Customer customer;
}
</pre>
<p>when you load the person, customer is also loaded as well.</p>
<p>Similarly one-to-one association is supported by using the <code>@OneToOne</code> annotation:</p>
<pre class="brush: java;">
public class Person
{
    @OneToOne
    private Address address
}
</pre>
<p>There is a unique constraint here: only one person can have this address. In a one-to-one bi-directional association both a person belongs to one address and an address belongs to one person.</p>
<p>A one-to-many uni-directional association is the same as the bi-directional associations but without the mappedBy annotation. In this case, without an owning side with cardinality of one, a join table is required.</p>
<p>Of course we can use generics for the mapping. If we do not use generics we will need to tell the container what entity it should be mapped to.</p>
<p>In order to manage the persistence we need to use <code>javax.persistence.Persistence</code> and create an <code>EntityMangerFactory</code> based on a persistence with name. With this entity manager factory instance  we can create an <code>EntityManager</code> instance which handles the persistence of the entities and use <code>Query</code> to query them back from the database.</p>
<p>In order to set the persistence unit we need to write a bit of xml (the <code>persistence.xml</code> file). We have to tell the persistence provider all the database properties (driver etc – the provider will use these properties for initialisation) and let JPA know the class that will be persistent.</p>
<p>The entity manager is the main object that takes care of the JPA stuff. It manages object identity and it  manages CRUD operations.</p>
<p>The life cycle of an entity can have four states:</p>
<ul>
<li>new (it&#8217;s new and not yet associated to a persistence context)</li>
<li>managed (is associated to a persistence context and the persistence context is active)</li>
<li>detached (has a persistent identity -i.e. it is associated to a persistence context- but this persistence context is not active)</li>
<li>removed (it is removed from the database).</li>
</ul>
<p>The persist method of the entity manager persists a new entity to the database. The remove method removes the entity from the database. If the entity is already scheduled for removal the operation is ignored. In all the above cases the operation might be cascaded if there are associated objects with the entities.</p>
<p>If an entity is managed an something changes in its state, its state will be automatically synchronised with the database. This is called flushing and we can have automatic flushing or a manual commit.</p>
<p>When an entity&#8217;s persistence context is closed (it can be closed when a) the transaction commits in a JEE environment or when the developer manually manages the persistence context&#8217;s life cycle in JSE b) the entity is serialised and c) an exception occurs) then the entity goes into the detached state.</p>
<p>An entity can also be merged using the entity manager&#8217;s merge method. When an entity is detached and a merge is applied to it then a new managed instance is returned, with the detached entity copied into it. If the entity is new then a new one is returned. Merge is also a cascading operation.</p>
<p>If we want to have optimistic locking with JPA we should annotate our entity with the <code>@Version</code> annotation. This field annotated with <code>@Version</code> will be updated by the entity manager every time the entity&#8217;s state is written in the database. The <code>@Version</code> field can be of type <code>int</code>, <code>Integer</code>, <code>short</code>, <code>Short</code>, <code>long</code>, <code>Long</code> and <code>Timestamp</code>. As an advice do not modify this field (except if you really know what you are doing).</p>
<p>JPA uses it&#8217;s own query language to query for an entity. This query API is used for named queries by using the <code>@NamedQuery</code> annotation (in TopLink you can cash all the queries/prepared statements), for dynamic queries and it supports polymorphism and pagination among other features.</p>
<p>You also have the chance to do bulk operation with JPA by using the Query API (caution! bulk operation will not affect the entity manager).</p>
<p>How do we deal in JPA with object identity? Do we use the database identifier as part of the operation? There is a remonder from the Object&#8217;s equal method that we should take into consideration: “Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.”</p>
<p>If we use a database identifier then we always need to have it assigned before we use the object. First persist the object, then flush it and then use the object (for example as part of a bigger collection).</p>
<p>Another solution is to use a business key, to have some sort of GUID/UUID. It is recommended not to override the <code>equals</code> or <code>hashCode</code> method, except if you really need to and know what you are doing. Yet , overriding the <code>equals</code> and <code>hashCode</code> method is okay if your object is going to be used as a composite identifier.</p>
<p>Then the talk moved to listeners and callback methods of JPA. Listeners are called before callbacks methods on entity classes and they are registered by using the <code>@EntityListeners</code> annotation in the entity class. The order is preserved and the container starts with the top of the hierarchy. Each event (PrePersist, PostPersist etc) is registered by adding the relevant annotation to a method with signature: void method(Object).</p>
<p>Callbacks are called after the listener classes and they are registered by using the same annotations to a method on the entity class. In case of a runtime exception the transaction will rollback.</p>
<p>In a JEE environment if we have a stateful session bean, the persistence context will be created when the stateful bean is created and will be closed when the stateful bean and all other stateful beans that inherit the persistence context are removed. If the stateful bean uses container managed transaction demarcation the prsistence context will join the transaction.</p>
<p>In summary JPA makes dealing with RDBMS much simpler&#8230; once you understand how JPA works. It is available in JEE as well as in JSE, multiple vendors support it, it has a dedicated JSR and there is great tools support.</p>
<p>Time for q&amp;a. What are the differences between different vendor implementations of JPA and what is the user&#8217;s personal preference? He said he prefers hibernate but he is biased since he&#8217;s been using it for years. He&#8217;s never used Eclipse link, he&#8217;s used TopLink and he saw that it doesn&#8217;t implement the specification properly sometimes. As an advice whatever ORM framework you choose make sure you know its flaws very well, especially towards the specification.</p>
<p>Second part of the talk was about two JPA tools we can use: the <a href="http://www.eclipse.org/dali/">Dali</a> tool and <a href="http://www.hibernate.org/255.html">hibernate tools</a>. This talk was delivered by Max.</p>
<p>The Dali tool supports the definition, editing and deployment of JPA entities and makes mapping simple. Hibernate tools (they are hibernate-centric but can be used for other entities as well) own a unique feature set (wizards, .hbm &amp; .xml editors, JPA query prototyping etc) to make writing JPA much simpler.</p>
<p>The goals of both the tools is simplicity (mapping assistance &amp; automatic generation), intuitiveness (use existing modelling), compliance and extensibility.</p>
<p>At this point the speaker presented these tools to us for the rest of his speaking time.</p>
<p><strong><a href="http://www.devoxx.com/display/JV08/Test+Driven+Development">Test driven development</a></strong> with <a href="http://www.davenicolette.net">Dave Nicolette</a>.</p>
<p>This was mainly a 3-hour development of a test driven application from scratch. Several people went to the speaker&#8217;s computer and pair-programmed an application (using Eclipse and JUnit 4), from an initial test (they started with a user story -a simple statement about the user, what the action is, what the person is going to do with the software, and the expected output-) to completion. This development took most of the time of the talk. While the application was being developed we were talking about the different steps and approaches to the problems solved.</p>
<p>Key things I wrote down:</p>
<p>Test driver development is tests we write to drive the code. We keep these tests as we write more code and we make sure that our new code didn&#8217;t break anything from the existing code. these regression tests have a lasting value throughout the application.</p>
<p>TDD works better with small specifications where we can break the problem down to smaller bits.</p>
<p>At this point some people from the audience got to the speakers computer and started developing a sample TDD application using Eclipse and JUnit 4. they started with a user story (a simple statement about the user, what the action is, what the person is going to do with the software, and the expected output). This development took most of the time of the talk.</p>
<p>In a TDD there is a 3-step cycle. Red (the test fails initially), green (we make the test pass with the simplest and quickest code) and re-factor, we make the code better without breaking the existing test.</p>
<p>Should we test getters/setters? If we write them manually we should, otherwise, if we let the IDE generate them for us, we could leave the tests out. Also it&#8217;s a good practice to write tests for mutators that mutate invariants of a class, for example a field that has to make sure that the balance of an account is never set to zero.</p>
<p>It&#8217;s not wrong to have more test code than production code, sometimes you might need to have even ten times more test code than production code.</p>
<p><strong><a href="http://www.devoxx.com/display/JV08/VisualVM+-+new+extensible+monitoring+platform">VisualVM &#8211; New extensible monitoring platform</a></strong> (by <a href="http://www.kodewerk.com/">Kirk Pepperdine</a>)</p>
<p>This was a short talk by Kirk Pepperdine (he actually replaced the original speaker from Sun) about how to use the VirtualVM. It was more of a demonstration rather than a talk.</p>
<p>The current VisualVM version is 1.0.1. This includes</p>
<ul>
<li>visual tool</li>
<li>combines several tools</li>
<ul>
<li>	command line</li>
<li>	jconsole</li>
<li>	profiler</li>
</ul>
<li>targeted for production and development</li>
<li>bundled with Sun&#8217;s JDK 1.6_07</li>
</ul>
<p>For monitoring and discovering local JVMs, use jps. For remote monitoring use jstatd which defaults to the following:</p>
<ul>
<li>com.sun.management.jmxremote.port=3333</li>
<li>com.sun.management.jmxremote.ssl = false</li>
<li>com.sun.management.jmxremote.authenticate = false</li>
</ul>
<p>For explicit jmx agent connection use: -J -Djconsole.plugin.path=path to the jconsole plugin</p>
<p>It does core dumps only on linux and solaris.</p>
<p>You start visual vm with visualvm –jdkhome $JAVA_HOME –userdir &lt;path to dir&gt;</p>
<p>When we use the visual vm to monitor an application we have to make sure that we have turned clustering off.</p>
<p>Sometimes when we get an <code>OutOfMemoryError</code> and the heap is empty it&#8217;s most likely a problem with the perm generation. </p>
<p>Objects that stay in the new (eden) space are easier to discard/gc than object that stay in the old heap space.</p>
<p><strong><a href="http://www.devoxx.com/display/JV08/Making+full+use+of+Hibernate+Tools">Making full use of hibernate tools</a></strong> (by <a href="http://jaoo.dk/aarhus-2008/speaker/Max+Rydahl+Andersen">Max Andersen</a>, JBoss Tools Lead)</p>
<p>This again was similar to the talk in the morning, but with more in-depth demonstration of how to use hibernate tools. In short</p>
<ul>
<li>Hibernate tools support Hibernate 3 and EJB3/JPA.</li>
<li>supports code completion in .hbm and .xml (class, properties, types etc).</li>
<li>Usually code generation is not as sophisticated or smart as manual code&#8230; but sometimes you have to bite the bullet.
</li>
</ul>
<p>It can export templates (like .ftl templates) into entity objects.</p>
<p>It provides custom JDBC binding (when we read stuff from the db how do we understand the meta-data in there).</p>
<p>It provides reverse engineering: </p>
<ul>
<li>use reveng.xmlfor basic control over:</li>
<ul>
<li>	included/excluded tables/colmns</li>
<li>	naming</li>
<li>	meta-attributes (&lt;meta attribute..</li>
</ul>
<li>use programmatic reverse engineering for complete control (extend <code>DelegatingReverseEngineeringStrategy</code>)
</li>
<li> you can also implement customizable reverse engineering</li>
</ul>
<p>Concluding statement: use the right tool for the right job. Even if you have a tool that does (almost) everything for you, you still have to think.</p>
<p>q&amp;a: are these tools available to netbeans. Short answer is no, but you can use the ant tasks for NetBeans. The source code is there but someone needs to integrate this code with NetBeans.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thejavablog.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thejavablog.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thejavablog.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thejavablog.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thejavablog.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thejavablog.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thejavablog.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thejavablog.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thejavablog.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thejavablog.wordpress.com/92/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=92&subd=thejavablog&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thejavablog.wordpress.com/2008/12/08/devoxx-university-day-1/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c619b1ddf3905d8bc061a992b4e0a0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Panos</media:title>
		</media:content>
	</item>
		<item>
		<title>JEE presentation</title>
		<link>http://thejavablog.wordpress.com/2008/12/01/jee-presentation/</link>
		<comments>http://thejavablog.wordpress.com/2008/12/01/jee-presentation/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 22:33:01 +0000</pubDate>
		<dc:creator>Panos</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[jee]]></category>

		<guid isPermaLink="false">http://thejavablog.wordpress.com/?p=90</guid>
		<description><![CDATA[Today I was invited to the City university to give a small talk about enterprise Java. It was my first ever talk in a university (it was quite different from giving presentation at work), and I was a bit nervous. Hope I did well because I really enjoyed it and I met interesting people. Thanks [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=90&subd=thejavablog&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Today I was invited to the <a href="http://www.city.ac.uk/">City university</a> to give a small talk about enterprise Java. It was my first ever talk in a university (it was quite different from giving presentation at work), and I was a bit nervous. Hope I did well because I really enjoyed it and I met interesting people. Thanks to everyone for coming.</p>
<p>If you would like to download the talk please follow the link: <a href='http://thejavablog.files.wordpress.com/2008/12/j2ee.ppt'>JEE</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thejavablog.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thejavablog.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thejavablog.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thejavablog.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thejavablog.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thejavablog.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thejavablog.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thejavablog.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thejavablog.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thejavablog.wordpress.com/90/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=90&subd=thejavablog&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thejavablog.wordpress.com/2008/12/01/jee-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c619b1ddf3905d8bc061a992b4e0a0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Panos</media:title>
		</media:content>
	</item>
		<item>
		<title>How to inject a generic interface using Guice</title>
		<link>http://thejavablog.wordpress.com/2008/11/17/how-to-inject-a-generic-interface-using-guice/</link>
		<comments>http://thejavablog.wordpress.com/2008/11/17/how-to-inject-a-generic-interface-using-guice/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 15:49:28 +0000</pubDate>
		<dc:creator>Panos</dc:creator>
				<category><![CDATA[Guice]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://thejavablog.wordpress.com/?p=79</guid>
		<description><![CDATA[In order to inject any generic type in Guice we should use a TypeLiteral. Lets say that we have a parameterised AnInterface interface and a myMethod method

public interface AnInterfacel&#60;T&#62;
{
    boolean myMethod(T object);
}
Now lets assume that we have two implementations of this interface, AnInterfaceImplA that uses the myMethod with a String and AnInterfaceImplB [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=79&subd=thejavablog&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In order to inject any generic type in <a href="http://code.google.com/p/google-guice/">Guice</a> we should use a <code>TypeLiteral</code>. Lets say that we have a parameterised <code>AnInterface </code>interface and a <code>myMethod </code>method</p>
<pre class="brush: java;">
public interface AnInterfacel&lt;T&gt;
{
    boolean myMethod(T object);
}</pre>
<p>Now lets assume that we have two implementations of this interface, <code>AnInterfaceImplA </code>that uses the <code>myMethod </code>with a <code>String </code>and <code>AnInterfaceImplB </code>that uses the <code>myMethod </code>with an <code>Integer</code>. We want to inject these two by using guice. In order to do that we need to create a TypeLiteral</p>
<pre class="brush: java;">
bind(new TypeLiteral&lt;AnInterface&lt;String&gt;&gt;(){}).annotatedWith(Names.name(&quot;NameA&quot;)).to(AnInterfaceImplA.class);
bind(new TypeLiteral&lt;AnInterface&lt;Integer&gt;&gt;(){}).annotatedWith(Names.name(&quot;NameB&quot;)).to(AnInterfaceImplB.class);
</pre>
<p>That&#8217;s it. We can then use the <code>@Inject</code> annotation to inject these implementation classes</p>
<pre class="brush: java;">
@Inject
public MyClass(@Named(&quot;NameA&quot;) AnInterface&lt;String&gt; implementationA, @Named(&quot;NameB&quot;) AnInterface&lt;Integer&gt; implementationB)
{
...
}
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thejavablog.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thejavablog.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thejavablog.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thejavablog.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thejavablog.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thejavablog.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thejavablog.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thejavablog.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thejavablog.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thejavablog.wordpress.com/79/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=79&subd=thejavablog&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thejavablog.wordpress.com/2008/11/17/how-to-inject-a-generic-interface-using-guice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c619b1ddf3905d8bc061a992b4e0a0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Panos</media:title>
		</media:content>
	</item>
		<item>
		<title>JHUG Java day &#8211; Athens 22/11/2008</title>
		<link>http://thejavablog.wordpress.com/2008/11/07/jhug-java-day-athens-22112008/</link>
		<comments>http://thejavablog.wordpress.com/2008/11/07/jhug-java-day-athens-22112008/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 14:00:10 +0000</pubDate>
		<dc:creator>Panos</dc:creator>
				<category><![CDATA[JHUG]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://thejavablog.wordpress.com/?p=60</guid>
		<description><![CDATA[



Jhug, is organising a Java day in Athens, Greece. The event will take place on Saturday 10.00 am, 22nd of November 2008 at President Hotel, and is expected to finish at 16.30 pm. Event&#8217;s speakers will be C. Loverdos, Sharon Cheong from Trasys Greece, Dr Heinz Kabutz, Serafeim Karapatis, a Glassfish speaker (TBA) and Dimitris [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=60&subd=thejavablog&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><table style="text-align:left;margin-left:0;margin-right:auto;font-size:100%;" border="0" cellspacing="0" cellpadding="5">
<tbody>
<tr>
<td width="100"><a title="duke" href="http://www.jhug.gr"><img src="http://thejavablog.files.wordpress.com/2007/10/duke-column-torch-black-tn.png" alt="duke-column-torch-black-tn.png" /></a></td>
<td width="438"><a href="http://www.jhug.gr">Jhug</a>, is organising a Java day in Athens, Greece. The event will take place on Saturday 10.00 am, 22nd of November 2008 at <a href="http://www.president.gr/" target="_blank">President Hotel</a>, and is expected to finish at 16.30 pm. Event&#8217;s speakers will be <a href="http://blog.ckkloverdos.com/">C. Loverdos</a>, Sharon Cheong from Trasys Greece, <a href="http://www.javaspecialists.eu/">Dr Heinz Kabutz</a>, <a href="http://serafeimk.blogspot.com/">Serafeim Karapatis</a>, a <a href="https://glassfish.dev.java.net/">Glassfish </a>speaker (TBA) and <a href="http://dandreadis.blogspot.com/">Dimitris Andreadis</a>, from <a href="http://www.jboss.org/">JBoss</a>. The full programme is listed below</td>
</tr>
</tbody>
</table>
<table style="text-align:left;margin-left:0;margin-right:auto;font-size:100%;height:206px;" border="1" cellspacing="0" cellpadding="5" width="450">
<tbody>
<tr>
<td width="92">10.00-10.30</td>
<td width="450"><strong>Registration &#8211; Coffee</strong></td>
</tr>
<tr>
<td>10.30-11.20</td>
<td><strong>Meet Scala. Object-Functional Programming</strong><strong> Has Already Begun </strong>C Loverdos</td>
</tr>
<tr>
<td>11.30-12.20</td>
<td><strong>Software Testing: Best practices</strong><strong> </strong>Sharon Cheong</td>
</tr>
<tr>
<td>12.20-12.40</td>
<td>Coffee break</td>
</tr>
<tr>
<td>12.40-13.10</td>
<td><strong>Un^H^HSelf-employed</strong><strong> </strong>Dr Heinz Kabutz</td>
</tr>
<tr>
<td>13.20-14.10</td>
<td><strong>Rapid application development using task flows and AJAX in JDeveloper 11g </strong>Serafeim Karapatis</td>
</tr>
<tr>
<td>14.10-14:40</td>
<td>Lunch Break</td>
</tr>
<tr>
<td>14.40-15:30</td>
<td><strong>Introducing GlassFish v3</strong><strong> </strong>(TBA)</td>
</tr>
<tr>
<td>15.40-16:30</td>
<td><strong>Introduction to JBoss AS 5</strong><strong> </strong>Dimitris Andreadis</td>
</tr>
</tbody>
</table>
<p>Sponsor to this event is Trasys Greece.</p>
<p>If you happen to be in Greece in the end of November it is well worth it paying a visit to the event.</p>
<p>For more info you can either send me an e-mail or visit the <a href="http://jugevents.org/jugevents/event/show.html?id=11070">jugevents site</a>.</p>
<p>Since we are always looking for speakers, if you are interested in speaking in one of JHUG&#8217;s future events please do send me an e-mail.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thejavablog.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thejavablog.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thejavablog.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thejavablog.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thejavablog.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thejavablog.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thejavablog.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thejavablog.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thejavablog.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thejavablog.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=60&subd=thejavablog&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thejavablog.wordpress.com/2008/11/07/jhug-java-day-athens-22112008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c619b1ddf3905d8bc061a992b4e0a0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Panos</media:title>
		</media:content>

		<media:content url="http://thejavablog.files.wordpress.com/2007/10/duke-column-torch-black-tn.png" medium="image">
			<media:title type="html">duke-column-torch-black-tn.png</media:title>
		</media:content>
	</item>
		<item>
		<title>How to create a TopLink EntityManagerFactory with Spring outside a J2EE container</title>
		<link>http://thejavablog.wordpress.com/2008/09/06/how-to-create-a-toplink-entitymanagerfactory-with-spring-outside-a-j2ee-container/</link>
		<comments>http://thejavablog.wordpress.com/2008/09/06/how-to-create-a-toplink-entitymanagerfactory-with-spring-outside-a-j2ee-container/#comments</comments>
		<pubDate>Sat, 06 Sep 2008 14:22:43 +0000</pubDate>
		<dc:creator>Panos</dc:creator>
				<category><![CDATA[Hsqldb]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[TopLink]]></category>

		<guid isPermaLink="false">http://thejavablog.wordpress.com/?p=51</guid>
		<description><![CDATA[Sometimes you need to create a JPA EntityManagerFactory outside a J2EE container. One of the cases is if you are using Spring and jpa with a standalone application. As the jdocs for the JpaTemplate state the preferred way is to use a LocalContainerEntityManagerFactoryBean and set the required properties. The example code below demonstrates the creation of an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=51&subd=thejavablog&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Sometimes you need to create a JPA <a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManagerFactory.html"><code>EntityManagerFactory</code></a> outside a J2EE container. One of the cases is if you are using Spring and jpa with a standalone application. As the <a href="http://www.jdocs.com/">jdocs</a> for the <a href="http://www.jdocs.com/spring/2.5.2/org/springframework/orm/jpa/JpaTemplate.html"><code>JpaTemplate</code></a> state the preferred way is to use a <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean.html"><code>LocalContainerEntityManagerFactoryBean</code></a> and set the required properties. The example code below demonstrates the creation of an <code>EntityManagerFactory</code> by using <a href="http://hsqldb.org/">HSQLDB</a></p>
<pre class="brush: java;">
DataSource datasource = new DriverManagerDataSource(&quot;org.hsqldb.jdbcDriver&quot;, &quot;jdbc:hsqldb:mem:test&quot;, &quot;user&quot;, &quot;password&quot;);
LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
bean.setJpaVendorAdapter(new TopLinkJpaVendorAdapter());
bean.setDataSource(datasource);
bean.afterPropertiesSet();
EntityManagerFactory factory = bean.getObject();
</pre>
<p><span style="font-family:'Lucida Grande';line-height:19px;white-space:normal;">First we create a <a href="http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/jdbc/datasource/DriverManagerDataSource.html"><code>DriverManagerDataSource</code></a> (from the Spring framework) and supply the required arguments (driver class, database url, username and password) and then we create an instance of the <code>LocalContainerEntityManagerFactoryBean</code>. We need to set the jpa vendor adapter (we can use Spring&#8217;s <a href="http://www.jdocs.com/spring/2.5.2/org/springframework/orm/jpa/vendor/TopLinkJpaVendorAdapter.html"><code>TopLinkJpaVendorAdapter</code></a> which is Spring&#8217;s implementation for <a href="http://oss.oracle.com/toplink-essentials-jpa.html">Oracle TopLink Essentials</a>) and the datasource. Then we call the <code>afterPropertiesSet()</code> method which means that the bean instance will only perform initialisation after all properties are set (in the event of misconfiguration it will throw an exception).</span></p>
<p>This is it. Once we have the <code>EntityManagerFactory</code> we can use it to create a <code>JpaTemplate</code></p>
<pre class="brush: java;">
JpaTemplate jpa = new JpaTemplate(factory);
</pre>
<p><span style="font-family:'Lucida Grande';line-height:19px;white-space:normal;">or if you programme to interface (which you should) the preferred way of doing this is</span></p>
<pre class="brush: java;">
JpaOperations jpa = new JpaTemplate(factory);
</pre>
<p><span style="font-family:'Lucida Grande';line-height:19px;white-space:normal;">Also it&#8217;s always proper to close the factory after you are done processing since leaving it open can result in a <a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/PersistenceException.html"><code>PersistenceException</code></a> exception with error message &#8220;Exception Description: Attempted to deploy PersistenceUnit &lt;unit name&gt; while being in the wrong state [Undeployed]. Close all factories for this PersistenceUnit. &#8221;</span></p>
<p>If you get this error you need to close the factory after you are done processing</p>
<pre class="brush: java;">
factory.close();
</pre>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thejavablog.wordpress.com/51/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thejavablog.wordpress.com/51/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thejavablog.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thejavablog.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thejavablog.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thejavablog.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thejavablog.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thejavablog.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thejavablog.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thejavablog.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thejavablog.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thejavablog.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=51&subd=thejavablog&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thejavablog.wordpress.com/2008/09/06/how-to-create-a-toplink-entitymanagerfactory-with-spring-outside-a-j2ee-container/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c619b1ddf3905d8bc061a992b4e0a0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Panos</media:title>
		</media:content>
	</item>
		<item>
		<title>SpringSource seminar &#8211; Athens &#8211; Greece</title>
		<link>http://thejavablog.wordpress.com/2008/07/19/springsource-seminar-athens-greece/</link>
		<comments>http://thejavablog.wordpress.com/2008/07/19/springsource-seminar-athens-greece/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 21:12:38 +0000</pubDate>
		<dc:creator>Panos</dc:creator>
				<category><![CDATA[JHUG]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://thejavablog.wordpress.com/?p=41</guid>
		<description><![CDATA[The Hellenic Java User Group and SpringSource are proud to present the free Spring Seminar. This Seminar will be a 4-hour seminar with 2 talks of Iwein Fuld, consultant at SpringSource based around the Spring Portfolio and the SpringSource Application Platform. The sessions will start around 1.30 PM and ends at 6 PM.
In addition to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=41&subd=thejavablog&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The <a href="http://www.jhug.gr">Hellenic Java User Group</a> and <a href="http://www.springsource.com/">SpringSource</a> are proud to present the free Spring Seminar. This Seminar will be a 4-hour seminar with 2 talks of <a href="http://blog.springsource.com/main/author/ifuld/">Iwein Fuld</a>, consultant at SpringSource based around the Spring Portfolio and the SpringSource Application Platform. The sessions will start around 1.30 PM and ends at 6 PM.</p>
<p>In addition to the SpringSource Seminar, SpringSource organizes a 4-day Core Spring training in Athens, during 26-29 of August. For more information:<a href="http://www.springsource.com/training/spr001/2008/core-ath-1">http://www.springsource.com/training/spr001/2008/core-ath-1</a>. Take advantage of the Early Bird discount, register before July 26th and save EUR 300!</p>
<p>During the SpringSource Seminar, the following sessions will be presented;</p>
<p><strong><em>Spring Portfolio; Current state and beyond</em></strong></p>
<p>The Spring Framework 2.5 introduced comprehensive support for annotation-based configuration, along with full support for the Java 6 and Java EE 5 platforms. Now Spring is preparing for the Spring 3.0 release, introducing further annotation-based configuration options and unified expression language support. This talk discusses Spring as a modern Java 5 oriented application framework &#8211; covering the core component model, integration with common technologies such as JPA and JSF, as well as Spring&#8217;s annotation-driven web MVC.</p>
<p><strong><em>Application Platform</em></strong></p>
<p>If you&#8217;re a Java web developer, you&#8217;re certainly familiar with monolithic WAR deployments and library bloat, and you&#8217;ve probably thought numerous times, &#8220;There must be a better way.&#8221; Well, there is! By building on the benefits of an OSGi runtime environment and combining the Spring and Spring-DM programming models, the SpringSource Application Platform offers enterprise web developers exciting new opportunities. This session will focus on developing web applications in an OSGi environment and will include a discussion of the migration path from a standard Java EE WAR to a fully OSGi-enabled web application packaged as a Web Module within a PAR. We will begin with an overview of deployment and packaging options available on the Platform and then take a closer look at each supported web deployment model from Standard WARs to Shared Libraries WARs, Shared Services WARs, and finally Web Modules. Attendees will walk away with a solid understanding of how to both develop and deploy next generation web applications on the S2AP.</p>
<p>More information can be found <a href="http://www.eventbrite.com/event/139182298">here</a>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thejavablog.wordpress.com/41/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thejavablog.wordpress.com/41/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thejavablog.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thejavablog.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thejavablog.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thejavablog.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thejavablog.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thejavablog.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thejavablog.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thejavablog.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thejavablog.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thejavablog.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thejavablog.wordpress.com&blog=1995949&post=41&subd=thejavablog&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thejavablog.wordpress.com/2008/07/19/springsource-seminar-athens-greece/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c619b1ddf3905d8bc061a992b4e0a0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Panos</media:title>
		</media:content>
	</item>
	</channel>
</rss>