Archive for the ‘Jan's Blog’ Category

Today’s web applications

Tuesday, September 22nd, 2009

I gave a talk on today’s Java EE and related web applications at yesterday’s London Digital Week event at Skills Matter. I had a full room of geeks keen to find out what I think about web application development. I hope that all attendees learned at least one new thing and that they’ll all find the time to try out Spring, Ruby on Rails or Grails.
To get started, you can download the source code of the talk from http://github.com/janm399/ldw/tree/master; the PDF version of the talk is available at http://github.com/janm399/ldw/raw/master/talk/ldw-pdf.pdf.

I’m looking forward to seeing most of you again at the next Java User Group or Spring User Group event!

Spring MVC at London JUG

Friday, September 4th, 2009

I had the privilege of giving a talk on Spring MVC at yesterday’s London JUG meeting. I had a full room of Java programmers keen to find out about how to write Spring MVC web applications. I hope that all attendees went away with good understanding of just how easy it is to write the Ms, Vs and Cs in Spring MVC.
You can download the source code of the talk from http://github.com/janm399/smvc/tree/master; the PDF version of the talk is available here.

I’d be happy to give a repeat of the talk at another JUG meeting or, if you prefer, give another talk on Spring-related topic. Spring AOP seemed to be quite popular!

That’s what I call performance

Thursday, August 27th, 2009

We are completing work on caching and routing tier we added to a lived-in system. The performance increase is very substantial and I will write a lot more about how we achieved this next week.
For now, I’ll wet your appetite with a screenshot that says it all

Service node statistics

Service node statistics


P.S. Yes, we’re talking about the RDTSC and System.nanoTime()!

Jeabu is coming

Monday, August 24th, 2009

Our new open-source project, Jeabu, is on its way. If you are very adventurous and interested in the earliest code, pull it from http://github.com/janm399/jeabu/tree/master.

COBOL is fifty

Friday, August 14th, 2009

Not today, of course, COBOL celebrated its fiftieth birthday in April. It is the hidden language, no one will openly admit that they have COBOL systems, yet there are millions of lines of COBOL code that no one dares to throw away. The number one reason is “if it ain’t broke, don’t fix it”, closely followed by the fact that software rewrites usually end in tears. Joel Spolsky gives excellent evidence on his blog.

Why is COBOL still out there?

So, how come COBOL has survived for so long? It is an old, cumbersome language; yet, it has modern compilers and runtime environments. You can compile your COBOL program on 32bit Windows, on 32 and 64bit Linux, HP-UX, Solaris, AIX, and many others.
Seven years ago, I worked in Ortex and they (not me, I was the cool new dude) were churning out thousands of lines of COBOL code every day.
I helped replace the aging Windows 3.1-style user interface with something that looked a bit more modern, but underneath the pretty UI, we were still talking to green-screen UNIX COBOL monster. And there lies the key to COBOL’s continued success.

What did COBOL give us?

It did not use complex binary protocols, it relied on the XML of the seventies — fixed width text messages. This simple data exchange format lends itself to easy integration with other systems. As long as your system can read and write fixed-width text, you can talk to COBOL-based systems — OK, I know I’m leaving out details, but bare with me.
Fast forward to 2006 and watch the WS-* approach. Why, did the WS-* people ask, are our systems talking to each other in closed binary formats; why can’t we use an easy to read and write format? Why aren’t we using XML? It turns out that WS-* approach is still cumbersome. For example, you cannot determine what a WS-* call will do just by looking at the endpoint, you need to examine the payload. Hmmf!
Enter REST. Again, we are sending structured plain text, but this time around, we’re making the most of the HTTP protocol. We use the HTTP methods properly and we give meanings to the URIs.

nmnon

Wednesday, August 12th, 2009

If you are in charge of a garden-variety Linux system, you’ll probably like nmon. It is a performance monitoring tool that combines statistics for the core kernel objects. You can see process list (similar to top), memory, network, block I/O and many other statistics, all in nice ncurses-based environment.

nmon screenshot

nmon screenshot


Interested? Get downloadin’!

SpringSource and VMWare

Wednesday, August 12th, 2009

Now that the news that VMWare bought SpringSource for a lot of money is out, let’s think about what it means for Spring developers. This post is pure speculation, something I would like to happen; the only satisfaction I will have if it does is being able to say “I said so”.

The old

I do not expect anything to happen to SpringSource’s open source products; in other words, the entire Spring Portfolio, tc Server and dm Server will remain free for us to explore and use.

The new

So, what new can SpringSource offer? Well, VMWare are in the virtualisation game, therefore I think they will offer virtualised enterprise solutions built on the Spring Portfolio and either tc Server or dm Server.
Imagine being able to download (still for free) a pre-configured dm Server or tc Server appliance. Download it, start it, and presto, you have a pre-configured enterprise-ready application server. Now, let’s take it up a notch. Imagine that these appliances allow themselves to be automatically discovered. All you need now is a central appliance (call it orchestrator, manager or clever load balancer). This central appliance would discover the tc Server or dm Server appliances on the network, monitor them, and provide a central point for deploying your applications.
Such approach would take away most of the pain of today’s enterprise deployment. You deploy to the orchestrator appliance and it then propagates the new version of the application to its worker appliances. Now, the orchestrator appliance may have access to a pool of shutdown worker appliances and it may be able to start them up if the load suddenly increases.
I think this is where the big money is: enterprises will be happy to pay licenses for the orchestrator appliance, because it solves so many headaches.

When?

So, when is this exciting future coming? I don’t know — in fact, I have no idea. But one thing is certain: if SpringSource do not start working on the orchestrator appliance, we at Cake Solutions will.

Running dm Server as a service

Friday, July 24th, 2009

Once you install dm Server, you may want to run it as a service or daemon. In this post, I will give you an excerpt from Chapter 2 of dm Server 2.0 in Action.

Running dm Server as daemon

On UNIX platforms, you can use nohup $SERVER_HOME/bin/startup.sh& to allow the dm Server’s shell process tree to become child of the init (or launchd) process and thus survive SIGHUP signal.

Configuring dm Server as Windows service

On Windows platforms, you can use Project Kenai’s winsw to run the dm Server as Windows service. The service wrapper can execute arbitrary executable file and pass it different command line arguments on service startup and shutdown.

To get started, download winsw from its homepage at http://projectkenai.com/projects/winsw/pages/Home. Once you have downloaded the winsw.exe, rename it to, for example, dmss.exe and copy it to %SERVER_HOME%\bin. The listing of %SERVER_HOME%\bin should now show files in Listing 1.

Listing 1. Files in %SERVER_HOME%\bin

C:\>dir %SERVER_HOME%\bin
 Volume in drive C has no label.
 Volume Serial Number is 7408-8BB9

 Directory of C:\opt\springsource-dm-server-2\bin

24/07/2009  14:49    <dir>          .
24/07/2009  14:49    </dir><dir >          ..
24/07/2009  14:21            31,744 dmss.exe
14/07/2009  16:42               953 jconsole.bat
14/07/2009  16:42             1,071 jconsole.sh
14/07/2009  16:42             2,468 jmxPermissions.vbs
14/07/2009  16:42               291 setupClasspath.bat
14/07/2009  16:42               658 setupClasspath.sh
14/07/2009  16:42             1,017 shutdown.bat
14/07/2009  16:42             1,243 shutdown.sh
14/07/2009  16:42             3,561 startup.bat
14/07/2009  16:42             3,459 startup.sh
              15 File(s)         50,298 bytes
               2 Dir(s)   1,316,659,200 bytes free

Because the service wrapper (now renamed to dmss.exe) executes the same executable to start or stop the service, we must create an executable that can decide whether to start or stop the dm Server based on command line argument. Let’s call this executable dmscontrol.bat; if we pass the run command line argument, we want it to call the startup.bat. Similarly, if we pass the stop command line argument, we want it to call the shutdown.bat. We show the entire source code of dmscontrol.bat below:

@ECHO OFF

IF "%~1"=="run" CALL %SERVER_HOME%\bin\startup.bat
IF "%~1"=="stop" CALL %SERVER_HOME%\bin\shutdown.bat

The final piece of the puzzle is the service configuration file. The service wrapper will look for a configuration file whose file name matches the executable of the service wrapper, but with xml extension. In our case, dmss.exe will look for dmss.xml. Take a look at Listing 2, which shows the dmss.xml service configuration file.

Listing 2. The service wrapper configuration file

01 <service>
02  <id>dmserver2</id>
03  <name>dm Server 2.0</name>
04  <description>
05    Controls the SpringSource dm Server 2.0
06  </description>
07  <env name="JAVA_HOME"
08    value="c:\Program Files\Java\jdk1.6.0_14" />
09  <executable>%SERVER_HOME%\bin\dmscontrol.bat</executable>
10  <startargument>run</startargument>
11  <stopargument>stop</stopargument>
12 </service>

02 The service identifier, it must start with a letter and must not contain spaces
03 The service name, this is the name that the Services listing will show
05 The description of the service that the Services listing will show
08 We need to set the JAVA_HOME environment variable for the service
09 The path to the service executable
10 The command line argument that the service wrapper will pass to the service executable to start the service
11 The command line argument that the service wrapper will pass to the service executable to stop the service

Before we can install the service, we must check that the permissions on the dm Server’s directory allow access from the service’s account. By default, the service will run under the SYSTEM account, therefore, we must give the SYSTEM account full control of the %SERVER_HOME% directory. Once this is done, we must execute the following commands:

cd %SYSTEM_HOME%\bin
dmss install

This will install the dm Server service, the proof is in the pudding – the Services listing in Figure 1.

services-listing

Figure 1. The dm Server service appearing in the Services listing

Notice in the Services listing that the name matches the contents of the <name> element in the dmss.xml file and description matches the contents of the <description> element in the configuration file. We can now start the service; when the service starts, its shell process will become child of the services.exe process (see Figure 2).

process-tree

Figure 2. Process tree showing the dm Server’s dmss.exe wrapper

You can verify that the service starts dm Server successfully by going to http://localhost:8080, you should see the splash screen you saw when you started the dm Server by running %SERVER_HOME%\bin\startup.bat.

Note on security

Regardless of whether you are running dm Server on UNIX or Windows, you should create a separate user account to run it. Having a separate account to run the dm Server will help limit the damage a potential successful attacker may cause.
Now that we have explored the different ways to start and run dm Server, let’s find out how we can control it once it’s running. We will begin by looking at the simple web administrative console, followed by the more complex OSGi console.

And there you have it!

Whether you’re running UNIX or Windows, you can now configure dm Server to survive a logoff!

First chapters of dm Server 2.0 in Action submitted

Monday, July 20th, 2009

We have just submitted the first two chapters of our upcoming book, dm Server 2.0 in Action. We are pressing on, already working on the next two chapters. After this, we will have one third review; we’ll then need a week or so to recover from the review and then continue with the work.
Keep watching this space and subscribe to Manning Early Access Program to get your hands on the early text.

dm Server 2.0 in Action

Saturday, June 27th, 2009

We strongly believe that OSGi is the future of Java EE development. Let me be more clear (mea maxima culpa!) clearer: if Java EE applications do not clean up their act and become more manageable, they will face the slow death of COBOL (notice that I spell COBOL with upper-case letters — I have some COBOL programming experience under my belt — scary!). It means that there will be a lot of development and a lot of work for us Java programmers to do, but all the cool stuff will be happening elsewhere. Let’s name drop: Ruby on Rails, Grails, dare I say JavaScript?

Take your Java EE skills to the next level

Because of this, you really should get to MEAP and get your hands on the early releases of our new book, dm Server 2.0 in Action.