A Day In Paris (JUG) With Java EE 6
After the session we spend about 2 hours in restaurant and another 2 hours in a bar - still discussing Java EE, Clustering, Failover, scalability, private / public Clouds Java, even JINI. We discussed 98% Java and 2% private stuff (like the relation of a freelancer to vacations :-)). Paris JUG is really well organized - and all participant seem to have lots of fun. Really enjoyed that. Already looking forward to SophiaConf in Nice. What also interesting - there is a female group of Java Hackers in Paris. This could be the beginning of a female Java Champions division as well.
Java FX CSS Reference Available
Its a kind of "Convention Over Configuration" again :-).
EJB 3.1 + Hessian = (Almost) Perfect Binary Remoting
EJB 3.1 + REST are perfect combo for HTTP and resource style programming. REST is not very well suited for the exposure of already existing interfaces. The RPC-misuse of REST will result in hard to understand and so to maintain code.
With hessian it is very easy to expose existing Java-interfaces with almost no overhead. Hessian is also extremely (better than IIOP and far better than SOAP) fast and scalable. The size of the whole hessian library (hessian-4.0.7.jar) is smaller than 400 kB and so compatible with the "Kilobyte Deployment" style of Java EE 6 programming and deployment.
To expose an existing EJB 3.1 with hessian:
@Stateless
public class CurrentTime {
public long nanos(){
return System.nanoTime();
}
}
You will need an interface:
public interface TimeService {
public long nanos();
}
...and hessian-specific implementation of the endpoint:
public class HessianTimeEndpoint extends HessianServlet implements TimeService{
@EJB
CurrentTime currentTime;
@Override
public long nanos() {
return currentTime.nanos();
}
}
The hessian enpoint is an servlet - so the dependency injection works here without any XML configuration. You can just inject your no-interface EJB 3.1 view bean into the servlet.
The client side is also very lean. You only need a two lines of code to get a reference tot he proxy:
public class HessianTimeEndpointTest {
private TimeService timeService;
@Before
public void initProxy() throws MalformedURLException {
String url = "http://localhost:8080/EJB31AndHessian/TimeService";
HessianProxyFactory factory = new HessianProxyFactory();
this.timeService = (TimeService) factory.create(TimeService.class,url);
assertNotNull(timeService);
}
@Test
public void nanos() {
long nanos = this.timeService.nanos();
assertTrue(nanos>0);
System.out.println("Nanos: " + nanos);
}
}
HessianServlet inherits from GenericServlet and not from HttpServlet. This is a shame, because you will have to use a web.xml deployment descriptor, instead of a single annotation @WebServlet:
<web-app >
<servlet>
<servlet-name>TimeService</servlet-name>
<servlet-class>com.abien.patterns.business.sf.hessian.HessianTimeEndpoint</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TimeService</servlet-name>
<url-pattern>/TimeService</url-pattern>
</servlet-mapping>
</web-app>
You will find the executable project (tested with Netbeans 6.9 and Glassfish v3.0.1) in: http://kenai.com/projects/javaee-patterns/ [project name:
EJB3AndHessian].
The whole WAR (EJB 3, Servlet, web.xml and the hessian "framework") is 393 kB. 385 kB hessian, and 7 kB EJB + Servlet :-)
The initial deployment of the WAR with EJBs took:
INFO: Portable JNDI names for EJB CurrentTime : [java:global/EJB31AndHessian/CurrentTime!com.abien.patterns.business.sf.CurrentTime, java:global/EJB31AndHessian/CurrentTime] INFO: Loading application EJB31AndHessian at /EJB31AndHessian INFO: EJB31AndHessian was successfully deployed in 807 milliseconds.
Don't worry: the subsequent deployments are substantially faster :-):
INFO: Portable JNDI names for EJB CurrentTime : [java:global/EJB31AndHessian/CurrentTime!com.abien.patterns.business.sf.CurrentTime, java:global/EJB31AndHessian/CurrentTime] INFO: Loading application EJB31AndHessian at /EJB31AndHessian INFO: EJB31AndHessian was successfully deployed in 568 milliseconds.
[See also Service Facade pattern, page 69"Real World Java EE Patterns - Rethinking Best Practices]
A French And Free Java EE 6 Week - Some Slides, More Code
Java EE 6 is so lightweight - that it may look overly complicated on slides. For that reason I will spend the majority of the time in the IDE. Hope it is o.k.
Thanks for the invitation (and sorry for the rollbacks in the past)! I guess I'm the only speaker with a truly french last name - but without any capability of speaking french :-).
How Popular Is Actually Java EE 6?
I'm back from the JAX 2010 - one of the biggest european Java conferences. There was lot more interests in Java EE 6, than expected:
- The "Simpler? - Is Impossible - Java EE 6" Workshop was fully booked - with 75 reservations. The actual number of attendees was approx. 100-150. Even the repetition at the very last day was well attended (12-20 attendees I had far more attendees at the end, than at the beginning :-)).
- The "60 Minutes With Java EE 6" talk was also well attended - it took place in one of the biggest rooms (the keynote room).
- We got a table with the topic "Weightless Beans" for the open space part of the conference. Because of the number of attendees, we had expand to the next table near us - and had a lot of fun and nice conversations about Java EE 6 (EJB, CDI, JPA) and the craziest errors in production.
- Java EE 6 trainings are almost sold out. I increased the max-number of attendees to 20.
- We asked the audience after our (Peter Rossbach, a Tomcat-Committer and me) Tomcat + openEJB session, who would be interested in a Tomcat+EJB distribution. More than half attendees were interested.
- Several conference attendees reported me that they are in the process of migration to Java EE 6 ...from Java EE 5
JAX was really nice conference with great food and interesting topics. Already looking forward to W-JAX! Thanks for attending the workshops, sessions - your feedback is highly appreciated.
Gosling's Thoughts On "Next" - Oracle, Lawyers And Fun
Read the whole post.
SOA Is Not Dead - Deutsche Bahn (DB) Is Highly Decoupled, HA, Service Oriented and Implementation Agnostic
Thinking about that from the software perspective - its genius:
- bahn.comfort service is location agnostic: the implementation of the service on the other side (another clerk), could sit whenever he want. I even suspect he was in the same room :-)
- The interface (=phone) is very generic. Everything is replacable - even the telephone-device.
- Built-in throughput throttling: there was only one shared phone used by three clerks (what I observed): the guy (a singleton) on the other side couldn't be overloaded.
- The whole process is highly available: the clerk who called the bahn.comfort service tried to reach someone several times until the eventual success. He also wrote down the ID on paper (this can be considered as TX log or persistent message). Now the clerk itself is replacable, another clerk could just complete the process having the Id
- The whole process is consistent: I stayed in touch with him and could react to any system-exceptions (like busy line). There is no need for rollbacks or compensative transactions, because he could ask me (the end-user) how to further proceed
- Cloud ready: partially it seemed like the clerk tried to reach someone in the clouds :-)
With this genius approach, most of the challenges, described in my How To Kill A SOA Project post are not only addressed, but entirely solved :-)
Now I'm in the ICE - with a ticket bought in highly service oriented way and enjoy the ride.
Upcoming Java EE 6 "Kill The Bloat" Workshops
- Java EE 5/6 Patterns in Hamburg (26.04-30.04.2010) - some (3-5) places left
- 60 minutes with Java EE 6, 04.05 at JAX conference - this should be fun. I will hack a Java EE 6 application in 60 minutes on stage. Still no idea which one - but suggestions are highly appreciated. I will use Java EE 6 - and so less slides, than last year for explanation (Java EE 6 is even simpler, than Java EE 5) :-).
*After the session*, we will discuss Java EE 6 / EJB / JMS etc. features, problems and workarounds during the "open space" part at the JAX conference. Watch the table "Weightless Beans" in the Ballroom. - Simpler is Impossible. From UI to Integration Layer with plain Java EE, 03.05.2010 (at JAX Conference)
- End 2 End Java EE 6 in Munich (07.06-09.06.2010) - this one is almost sold out
Caution: we spend usually more time in the IDE, than with slides (reason: slides don't crash :-)). I tend to explain stuff with code. I also usually have > 100 slides prepared - for warm-up purposes :-).
I will probably offer another workshop in autumn - because of current (Java EE 6) project / request load, I'm still searching for a free slot.
GlassFish will be Killed, Closed Source, Children's Edition And The Official Response
[I borrowed the title from slide 4]
James Gosling Leaves Oracle
An excerpt from his bio: "...He briefly worked for Oracle after the acquisition of Sun. He is now blissfully unemployed :-)..."
Compact Attribute Declaration In Java
public class VerboseClass {
private String firstName;
private String lastName;
private String description;
}
Attributes of the same type and visibility can be declared in a more compact manner:
public class CompactClass {
private String firstName,lastName,description;
}
This works in most cases - except you want to annotate each attribute in different way....