Quick Glance at JArchitect

Few months ago Dane from JArchitect team was kind enough to provide me with a license for JArchitect 3.1.0 Professional Edition, a multiplatform (GNU/Linux, Mac, Windows) software for static code analysis. While I was really swamped with my every-day work (and personal life) I didn’t have really much time to take a closer look at it that time. Few days ago I’ve said to myself ’that’s enough’ and X-rayed one of our company projects using JArchitect....

August 18, 2013 · 7 min

EJB Inheritance is Different From Java Inheritance

Despite the fact that EJB inheritance sometimes uses Java inheritance – they’re not always the same. Just as you could read in my previous post, EJB doesn’t have to implement any interface to expose a business interface. The other way around is also true – just because EJB is implementing some interface or extending other EJB doesn’t mean it exposes all or any of its views. Let’s say we want to have some basic EJB exposing remote business interface....

March 21, 2013 · 4 min

JPA and CMT -- Why Catching Persistence Exception is Not Enough?

Being in EJB and JPA world using CMT (Container Managed Transactions) is very comfortable. Just define few annotations to demarcate transaction boundary (or use the defaults) and that’s it – no fiddling with manual begin, commit or rollback operations. One way to rollback your transaction is to throw non-application exception (or application exception with rollback = true) from your EJB’s business method. It seems simple: if during some operation there is a possibility that an exception will be thrown and you don’t want to rollback your tx than you should just catch this exception and you’re fine....

March 10, 2013 · 5 min

Using JGroups Directly From JBoss AS 7 Component

UPDATE (5.08.2013) – I’ve updated this post to support JBoss EAP 6.1 Final (JBoss AS 7.2). Enjoy UPDATE (2.09.2013) – Bela Ban pointed to his very interesting post about new ForkChannel feature and easy channel hijacking directly from JBoss AS / Infinispan. Read about it here JGroups is Bela Ban’s piece of software for reliable message exchange that is highly configurable and can use either TCP or UDP as a transport protocol....

February 24, 2013 · 5 min

Compiling Java Source File From Running Java Application

Did you know that you can compile Java source code from your running Java Application? It’s not even so hard and the JavaCompiler javadoc is quite verbose. Try it for yourself: package com.piotrnowicki.javacompiler; import javax.tools.JavaCompiler; import javax.tools.ToolProvider; public class Executor { public static void main(String[] args) { JavaCompiler jcp = ToolProvider.getSystemJavaCompiler(); // Compile pointed *.java file jcp.run(null, null, null, "/home/piotr/MyClass.java"); } } Now imagine that you can compile your Java code from a Java application that compiles your Java code....

May 27, 2012 · 1 min

After the GeeCON 2012

Whoa, those few days of GeeCON – Polish Java conference – just passed way too quick. A lot of great speakers, pretty good organisation and the overwhelming Java climate. Yep, it’s geeky or even nerdy but – what the hell – me like it! ;-) But for all of you who was not able to attend this conference – it consisted of 3 parts: University Day (1 day), Conference (2 days), Open Spaces with Bruce Eckel (1 day)....

May 23, 2012 · 12 min

After the Spring 3 Core Training

At the end of march 2012 I was attending a Spring 3 Core Training in Cracow which was organised by the SpringSource. Because I am more of a pure Java EE world type and mainly develop in this area, I wanted to improve my knowledge about Spring. Sure, I’ve used Spring, worked with it but never felt really comfortable with it. I was missing the big picture and so that’s why I decided to go to this training....

May 19, 2012 · 3 min

DWR -- Access Your Java Objects Directly From JavaScript

I must admit – I’m neither very experienced in the field of user interfaces nor really familiarised with all that JavaScript, jQuery stuff. I was always thinking of myself more as a service layer guy. Nevertheless, I wanted to improve my knowledge, so I decided to learn more about something called DWR (Direct Web Remoting). I’ve heard about it few years ago but never actually passed the “yeah, I’ve heard about it” stage....

May 11, 2012 · 7 min

One Servlet Instance to Rule Them All...

I see a lot of people saying that: “there is only one instance of servlet per application”. Surely it gives you some information and knowing this will save you from a lot of strange, unexpected errors. However, the above statement is not very accurate and precise. It’s useful to know what is the actual contract between the web container and developer. Moreover, a lot of questions arise because of the multi-threading issues, so let me sum this up backing my words with Servlet 3....

April 30, 2012 · 2 min

To FEST or not to FEST?

When you write your unit tests you must use some kind of assertions. I think that most of you will agree with me on that the asserts that comes with the JUnit aren’t the easiest and most readable ones. So, some time ago I started to use a Hamcrest matcher library. It was a great progress, as I was able to move away from JUnit’s unintuitive: assertEquals(11.0, actual). I mean, if you try to read it out loud it doesn’t seem very logical:...

April 27, 2012 · 3 min