Blog

Secure Remoting with Spring and JBoss

If you are faced with having to write a rich client application in a multi-tier Java EE environment, you will typically connect to the application server over RMI. In theory, you are meant to use the servers Application Client Container and deploy your application as a client in that container. You probably won't do that though, because the client container is unfriendly for many reasons: As an example, the WebSphere 6.1 Client Container is a 200 megabyte install, Client Containers tend to be started as batch commands which set up the environment in which your application will run. If you however have an application that is meant to be started with a sexy launcher, as is the case with Eclipse RCP applications, you will struggle to get the environment created properly by the launcher, and its not supported by the vendor anyway, If you need to connect to the server securely (ie. so that serverside you have a valid security context allowing you to authorise users to call given services), then I personally have never been able to get the security callback mechanism to work. Theoretically you can tell the container to call your code at the point which it logs on to the server in order to get the credentials (eg. you can pop up a little login window), For these reasons, I have never ever used a client container in a production environment. Instead I have repeatedly gone to the trouble of getting the client environment fit so…

Read more

The decline of dinos

No, not a report about the death of dinosaurs many millions of years ago, nor a report about how in fact many dinosaurs didn't die out, but rather evolved into birds... Rather, this blog entry is about dinos which is a Facebook Application written by maxant. Basically, you get a virtual dinosaur which you need to feed. It can also fight or flirt with the dinosaurs of your friends, which directly affects its health. The idea is to keep your dino alive as long as possible. There were several goals in developing it. First of all it was an experiment to see how the Facebook API worked. Second, it was to see how much faster a Facebook application would grow, compared to a normal website, because Facebook gives you  "free website advertising" in terms of being able to invite friends to play your game/application. As such it is a type of viral marketing. The aim is to give it enough momentum that its growth will become exponential. At a minimum, growth should be linear shouldn't it? Well, right from the start, Google Analytics were used to track site traffic. Below are some graphs showing this traffic. The general trend is slow but certain death, much like most original dinosaurs, all those years ago. The point of this blog is not to show that maxant is good at making crap games. Generally speaking Facebook application installations are falling fast, as the novelty wears off. The result is less new people playing…

Read more

OSGi – Just another fad?

In the last few weeks I have heard the term OSGi come up more and more, and one blog posting I read suggested that it was the hot topic of 2008. So I started to research a little. I am currently working heavily with the Eclipse Rich Client Platform building applications which use services deployed to IBM WebSphere. Both these platforms are built up on OSGi (the standard) and both use Eclipse Equinox (an implementation of the standard). So it must be important right? Well you don't have to read too much before you start to get the feeling that you have been there and done that before. One aim of OSGi is to provide a micro kernel for deploying and managing services. Well, from a high level, JMX (MBeans) already does that. Not enough? Well there used to be a project called Apache Avalon Phoenix, which was a mirco kernal and although that project died and was resurrected as Loom from Codehaus (which incidentally has a very interesting history of Apache and Phoenix), it is still the basis of some big projects like the Apache James mail server. Other micro kernals? How about JBoss? There is a good blog article dicussing how JBoss has been based on a micro kernel for some time now. The idea is nothing new and in fact in their case, OSGi does not really go far enough that they could be solely based on it. Actually, doesn't the Java EE EJB specification let you…

Read more

Eclipse Help / Infocenter – External Web Application Mode

Previously in this blog, the Eclipse Help / Infocenter was discussed and details on how to set up the help for an RCP application were given. But often you want to have your help for an application online as well as part of the product, for example if the customer does not have the latest version of the product installed. Indeed the IBM and Eclipse web sites have what they call an Infocenter - an online version of their help system. In reality, when the Eclipse Help System is running, it runs as an embedded web server within your application. So in theory, it should be possible to deploy that as a standard web application. Quoting the Eclipse Help, "The help system can run in three modes: workbench (normal), infocenter, and standalone." Normal is when it is part of your application. Infocenter is when it runs as a seperate process acting as a web server. Standalone is when it is used outside of an RCP application. In fact, from Eclipse 3.4 upwards, it can also be deployed as a standard Java EE web application. The following blog shows how to deploy that help to a standard Java EE web server, namely Tomcat 5.5. Unfortunately, at the time of writing, there is no simple way to get this running. Neither is there any good tutorial showing how to overcome the pitfalls of the descriptions provided in the Eclipse 3.4 Help (search for WAR and you will get the details). Those details…

Read more

Eclipse Help / Infocenter – Workbench Mode

Eclipse offers plugin authors the ability to add Eclipse Help to their plugins. Opening that help will give a nice window with searchable help, something like this (click on the image to see it in full size): The following blog entry shows how to integrate help into an RCP application (or indeed a plugin or feature). The first thing you need to do, is to extend your plugin.xml to tell your plugin that you want to have help. In the source view of your plugin.xml include the following extension points:      To go with these entries, you now need to add the help folder to your plugin project:      The html folder under the help folder contains simple HTML documents for each page of help that you want to write. The toc.xml file is the table of contents which defines what appears in the left pane of the help system when it is opened. The help_contexts.xml file contains mappings from "context names" to files which are relevant for that context. Contexts are used when opening context sensitive help, for example when pushing the F1 button. An example of the toc.xml follows:     <toc label="BookStore"> <topic label="Introduction" href="help/html/general/overview.html"></topic> <topic label="Starting Up" href="help/html/general/startup.html"></topic> <topic label="The Process" href="help/html/general/process.html"></topic> <topic label="Screens"> <topic label="Customers" href="help/html/views/Customers.html"></topic> <topic label="Products" href="help/html/views/Products.html"></topic> </topic> <topic label="Frequently Asked Questions" href="help/html/general/faq.html"></topic> </toc> An example of the help_contexts.xml follows:      <?xml version="1.0" encoding="UTF-8"?> <!--==================================================================== Definition of Context-Sensitive-Help (for the F1 Button) ========================================================================--> <contexts> <!--==================================================================== In the code, set the context on the control…

Read more

GUI Performance Enhancement Strategies

Graphical User Interfaces (GUIs) tend to be event driven. A user performs an action and the GUI sends that event to any interested components through a Model-View-Controller mechanism. When the events being sent represent fine grained actions (for example a single field on a form changed, as opposed to coarse grained events like the form being submitted), the performance of the GUI can become an issue. Other examples of when performance of the GUI might become an issue are: when the model in the GUI is large, when the GUI needs to process the data a lot in preparation for displaying it (either client or server side), when the GUI is poorly implemented and duplicate listeners exist meaning that components are refreshed multiple times, unnecessarily. The following strategy has been used to help improve GUI performance. This list is ordered with the easiest / most important tasks (least effort, best improvement) at the top: ensure a clean MVC implementation, without duplicate listeners, add data caches, optimise caches (e.g. they hold more than one object graph), optimise refreshing of non-active elements. 1) Clean MVC Implementation First of all, read the MVC article on this blog. Then, using a profiler or debugger follow your controller as it fires model change events. Are any model listeners fired more than once for any reason? If they are, it is less than optimal and you need to first look for mistakes in the programming logic. If there really is a good reason that the event…

Read more

Extreme Productivity

A year ago I was the architect of a small project (Project A) building a Client / Server application, based on Eclipse SWT/JFace/RCP, Websphere, Oracle, JMS and an Object Relation Mapping (ORM) tool, Hibernate. We were 3.5 developers on average, and we finished in 7 months. We used Feature Driven Development (FDD, similar to eXtreme Programming) as its implementation methodology. This year I worked as a lead developer on a much larger project (Project B), which I joined in its second half. The project as a whole had nearly 50 people on it at times, although our part was again an Eclipse SWT/JFace/RCP Client using a Websphere Server with Oracle and a different ORM tool, Toplink. We were 5 developers on average, finishing in 9 months. Here a kind of waterfall based methodology was used. In my spare time, I work on a tiny project, BookStore. Again an Eclipse SWT/JFace/RCP Client but not using Websphere, and instead of Oracle it uses MySQL but also with Hibernate. Its developed by just me. I do however track time spent on implementation, as well as metrics. The methodology used here is an extremely Agile one, where the documents are in the code (unless its really major, then it gets its own document), priority is given to bug fixing, then feature development, then product improvement. The aim is to be able to release a stable version at any time so that bugs can be fixed super quick. The product auto-updates from the web, to…

Read more

Object Orientation (OO) in GUIs

I was taught (hopefully rightly) that a class contains data relevant to it and methods which act on that data. For example, a class representing a Monkey might have attributes like date of birth, male/female, number of children, and a reference to the zoo where it lives. Methods might be getYearsOld() to work out how many days old it is, haveSex(List<Monkey> partners) , addChild(Monkey kid), setZoo(Zoo newHome). Equally a complex graphical user interface component like a tree or a table might contain a matrix or hierarchy of cells and methods for setting the cells attributes (data, size, borders, rendering information, etc). It would typically have renderers for painting the cells as well as perhaps editors for editing the data in the cells. In fact, Swing has a rather nice implementation of Tables, Trees and even Tree-Tables. Eclipse JFace is fast catching up. So if you do find yourself building something like this, say in Java Script, look at the nearest thing you can find that already exists, analyse how object oriented it is, then implement something similar (even sub-class it). What you want to avoid is creating a load of helper methods which just build the GUI in a totally pre-object-oriented manner - Builder Classes as I call them. I have seen this done several times by programmers that learned to program in the object oriented age. It might be expected from an older programmer who learned to program pre-object orientation, or one that has never used an object oriented…

Read more

Model – View – Controller (MVC) Design Pattern

Here is a quick challenge: Go to Google and search for "MVC". Check each of the first ten search results. What do you notice? Each description of MVC is different. Perhaps not in terms of the Model, the View and the Controller, but in terms of the details of how they interact with each other. In some descriptions the controller sits between the View and the Model. In others they all talk to each other. I have even seen implementations where an update in the GUI sends an event to the Controller which updates the Model which sends an event back to the Controller which updates the View, with the same data which it just changed, resulting in a very active user interface! Now it starts to makes a lot more sense, that both Java Swing and Eclipse SWT / JFace do not implement true MCV but rather a light weight version referred to often as separable model architecture. Here, the Model is seperate from a "delegate" which is a combination of the Controller and View. It makes a lot of sense and reduces complexity and confusion a great deal. One case where I would advocate a separate Controller is where the View is very complex and there are also a lot of business rules dictating how the data is validated before being set in the model. Then it is useful to implement a Controller. In such cases I suggest the following rules for your three MVC components: The View…

Read more

Simple Web Services

UPDATED: Something like Hessian - http://hessian.caucho.com/ - would have been exactly what I was looking for to send binary data over HTTP. I recently had the need to send an object model from an applet back to the server. The model was rather complex and what might have been normal in the office, would have been to marshal the data into an XML document and send it to a SOAP interface. But that's rather excessive and would take quite some time to develop (think generating XML definitions, JAXB, generating a web service and some WSDL, then the web service clients, yawn, yawn). So I had a quick think about what I wanted to achieve. I wanted some data to be sent from the client to the server. I wanted to develop it quickly too (so no time for research and the trials of software selection). It had to be HTTP friendly as well, since I am paranoid about opening ports on my public servers. So I wondered about serialising the model and sending it to a simple servlet where it could be stored into a database as a BLOB. If necessary (which was later to become the case) I would also be able to deserialise the model server side and extract some data from it. The only problem I faced was whether I could send binary data (the serialised data) over an HTTP request? To be on the safe side, and to avoid worrying about things like MIME types, I took…

Read more