woensdag 19 december 2007

Java multiple inheritance

shown by example:

We need multiple inheritance when developing the Web client that talks to the message server. Our Web client is a simple servlet used to get the message from a form and send it to the message server. To complete that task, the servlet must be both an HttpServlet and a MessageClient. Since Java does not allow such behavior, the main class extends the HttpServlet class, as shown in Listing 2. This main class contains an inner class that extends MessageClient. The outer class then creates an instance of the inner class.

public class SendMessageServlet extends HttpServlet{

private MessageClient m_messageClient;
private String m_serverName;

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException{
//Get server name
m_serverName = request.getServerName();
System.out.println("ServerName is " + m_serverName);
//Create message client to communicate with message server
m_messageClient = new ServletMessageClient();
System.out.println("Created Message Client");

//Get message and phone number
String phoneNum = (String) request.getParameter("PhoneNum");
String message = (String) request.getParameter("Message");

//Send message

//Display page to tell user message was sent
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/SendMessageForm.jsp");
dispatcher.include(request, response);
}catch (Exception e){

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);

/** Inner class used to extend MessageClient */
public class ServletMessageClient extends MessageClient {
public ServletMessageClient(){
public String getServerName(){
System.out.println("Returning ServerName " + m_serverName);

This approach isn't true multiple inheritance because we used delegation. (i.e., MessageClient is extended by a member of the outer class and not the outer class itself), but the effect is the same. Although MessageClient could have been extended in a separate class, using an inner class allows it to access all the members and methods of the outer class. This makes it easier for the two classes to interact.

This example only extends two classes, but there is no reason why this technique couldn't be used to extend as many classes as needed by creating an inner class for each class that must be inherited.

source: http://www.javaworld.com/javaworld/jw-10-2005/jw-1024-multiple.html

donderdag 13 december 2007

Javapolis 2007

I was lucky to be present :)

Conference Day 1 : Wednesday December 12th


We focused on the Swing related sessions.

JavaFX by Jim Weaver

Very interesting speaker. Had the original idea to throw paper airplanes (of some value, I think free ebook) to people asking good questions.

Was my first real contact with java fx code. Looks like an easy syntax. Still for making a complete and complex gui I'm afraid you still end up with pages and pages of code. Anyway less than you would with swing.

He suggested we should play with the compiled version and have a look towards his blog for getting started information and examples.

The Elepehant is through the door example references that this project has left most of the work behind and is now wrapping up to get a stable production release.

Showed examples of syntaxt in general, binding, ... (need my notes to complete this)


http://www.javapolis.com/confluence/display/JP07/JavaFX (session)
http://www.javapolis.com/confluence/display/JP07/Jim+Weaver (speaker)
https://openjfx.dev.java.net/ (official project homepage)
http://learnjavafx.typepad.com/ (blog speaker)

Filthy Makeover by Chet Haase

Showed us a lot of relatively simply gui iprovements. Real life examples of gui's morphing from the standard grey ones towards fancy and therefore attractive user interfaces. The book is on my wishlist now.

Some of the topics (need my notes again)

* shadows
* blur
* gradients
* glass panels


http://www.javapolis.com/confluence/display/JP07/Filthy+Makeover (session)
http://www.javapolis.com/confluence/display/JP07/Chet+Haase (speaker)
http://filthyrichclients.org/ (book)

Web 2.0 Collaboration and Social Networking by Thomas Schaeck

This speaker was less interesting. End up showing a bunch of new web 2.0 tools for the lotus platform. Communities, Media Library, Blogs, Profiles, ... nothing really new. But most of all this was more like a commercial in conference disguise.


http://www.javapolis.com/confluence/display/JP07/Web+2.0+Collaboration+and+Social+Networking (session)
http://www.javapolis.com/confluence/display/JP07/Thomas+Schaeck (speaker)

Practical JRuby on Rails by Ola Bini and Charles Oliver Nutter

I had experience with Ruby on Rails (RoR) for profiling before and was very impressed back then. This session was not that new to me, the new part was the interaction with java. Which is interesting. Still all looked to have slow startup times... no surprises there :). Programmers also found some bugs while demonstration. Still this technology is impressive and very nice to play with. For prototyping I believe in this project.

The testing possibilities of this framework combined with the java code loading looked promising. Having nice mocking abilities, dynamic code loading and ease of specifications added to Java. Definitely something I wil get into.


http://www.javapolis.com/confluence/display/JP07/Practical+JRuby+on+Rails (session)
http://www.javapolis.com/confluence/display/JP07/Ola+Bini (speakers)
http://www.javapolis.com/confluence/display/JP07/Charles+Oliver+Nutter (speakers)
http://jruby.codehaus.org/ (official project homepage)

blueMarine by Fabrizio Giudici

blueMarine is a good looking image organizer. It is designed by and for photographer(s).

Allthough I couldn't always follow into detail this was an interesting session. The message I get is that swing is no framework but a great base for frameworks. We should look beyond swing, not to different approache but towards frameworks that built on swing. The most promising example libraries were swinglabs for general gui's, and netbeans rcp for more advanced, complex gui's. The last provides plugin funtcionality etc.

The programmer also showed some interesting options of his program (like the light panel and binding pictures towards a gps track) that are not available yet.


http://www.javapolis.com/confluence/display/JP07/blueMarine (session)
http://www.javapolis.com/confluence/display/JP07/Fabrizio+Giudici (speaker)
http://bluemarine.tidalwave.it/ (project homepage) http://swinglabs.org/ (swinglabs)
http://platform.netbeans.org/ (netbeans rcp)

recorded presentations : http://www.parleys.com/display/PARLEYS/Home

dinsdag 4 december 2007


We get errors from the following SQL on an Oracle database:

ALTER TABLE table_name
ADD CONSTRAINT constriant_name

Finally we found out 2 things:
Oracle has no ON DELETE NO ACTION, use ON DELETE SET NULL instead
Oracle has no ON UPDATE at all for constraints so use trigger

So the fixed SQL looks like:

ALTER TABLE table_name
ADD CONSTRAINT constriant_name

and a trigger