Upgrading Twitter

Posted by Martin Homik | Posted in WebApp | Posted on 19-03-2009

0

There is a nice post by Gojko Adzic about a talk he attended. The talk was given by Evan Weaver about experience with upgrading twitter.  It is quite interesting to know how sites having huge traffic solve performance problems.

Overloading methods and passing ‘null’ as argument

Posted by Martin Homik | Posted in Java | Posted on 28-10-2008

2

Today, I came across a NPE which pointed me to a problem which I cannot resolve. Assuming, you have two overloaded methods in a class:

  1. public void setProperty(Collection c);
  2. public void setProperty(String c);

Which method will be invoked when the parameter is null?

Answer: you cannot call setProperty with a null parameter. The compiler will complain. In all other cases the signature of the method is matched. So, it doesn’t matter if your String has the null value, it only matters that you apply a method applied to a String parameter. This is the signature. This is matched.

German Web2.0 Paper Magazin

Posted by Martin Homik | Posted in Java, WebApp | Posted on 05-09-2008

0

Yesterday I went to town to get the new Java magazine. While I was at the store, I thought I could also try a new magazine. In that moment I realized that customers have many options to get A Linux or a Mac magazine which is a change when I payed attention to the fact the last time (a few years ago).  But actually, I searched for a magazine on Web2.0 or JavaScript. Both are fields I am diving into right now. Though I know many sources on the Net, I was surprised to see, or more accurately not to see, any magazine that covers this topic.

Can you recommend any magazine?

Struts2 URL Tag

Posted by Martin Homik | Posted in Java, WebApp | Posted on 26-08-2008

0

I use the Struts2 URL tag all the time to expand relative paths with the current context. I also use it to address images. I have not proven it, but today, I got the hint that an image to which an argument is appended, will be loaded each time the page is displayed. To prevent appending of additional parameters, use the includeParams attribute and set the value to none. Below is an example for a dynamically created URL.

  1. <s:url value="%{‘images/flags/’+locale+’.png’}" includeParams="none" id="localeURL"></s:url>

Debugging Maven projects with Eclipse

Posted by Martin Homik | Posted in Java, WebApp | Posted on 31-07-2008

1

Debugging Maven projects with Eclipse or any other IDE on Windows is not trivial. In the beginning. But once you know the mechansim, it’s simple. I googled and found a few helpful pages. Look here. Here are my experiences.

Maven supports two debug modes: the Generic and the Surefire. If you want to debug maven itself, one of maven’s plugins, or a maven project, use the Generic Approach. If you want to debug a test in your project launched by surefire, use the Surefire Approach.

Surefire Approach.

  • Create a new Java Project and call it “Maven Debug”. This Project will never have any source code in it, it is just a shell for attaching the debugger.
  • Create a debug configuration: Run -> Debug Configurations and then right click on Remote Java Application and select New launch configuration. Call it “Maven Surefire”.
  •  On the Connect tab click the Browse button and select the “Maven Debug” project.
  • Set connection properties to localhost and port 5005. This is the port on which Surefire waits for the debugger.
  • The connection type is Standard (Socket Attach)
  • On the Source tab add all projects that have any Maven source that you want to debug.

Now let’s do the actual debugging.

  • Select break points in the code you’re are going to run. Note, you cn select only code in your test classes. It won’t work on classes outside the test phase.
  • In your command line, append the following switch to your maven command: -Dmaven.surefire.debug. For example, to debug the tests run by the maven lifecycle install do mvn install -Dmaven.surefire.debug
  • Wait for maven to pause its execution and display the message: Listening for transport dt_socket at address: 5005
  • Attach the debugger to the running maven by selecting the “Maven Surefire” debug configuration created above. Your debugger should stop at your breakpoint.

Generic Approach.

  • Follow the instructions, presented here. The only instructions that worked for me. They are very similar to the Surefire Approach.
  • Note: use Maven 2.0.8 or higher. The, you don’t need to write your own maven debug script. It’ll be sufficient to use the shipped mvnDebug script.

Some experience with RSS/Atom frameworks

Posted by Martin Homik | Posted in Java | Posted on 20-06-2008

3

10 days ago, I had the idea to enhance my web application by integration Roller. Instead of implementing a blog model myself, I wanted to implement the UI only and pass all the blog entries to a stable blog server. The problems were:

  • Blog entry management. How to exchange blog entries with Roller?
  • User management. How to synchronize users with Roller?

To solve the the management of blog entries, Roller provides an RSS/Atom interface. The only thing I would need is a blog client. Lucky me, there is the ROME and ROME Propono. ROME is a RSS/ATOM framework and Propono is a subproject of it that implements a RSS/Atom client. It seemed to be a good solution, because:

  • ROME is quite mature.
  • It is written by Dave Johnson, the author of RSS/Atom in Action. Dave is also involved in Roller.
  • Dave keeps blogging on a regular basis and informs the community about progress.
  • There is a discussion forum on Nabbles.
  • The blog client, described in the book has been extracted from the example sources and and has been further developed. Today we know it as ROME Propono.

But once, I started to test, compile, and integrate into a Maven based project, I ran into trouble. To make a long story short:

  • ROME has never reached 1.0 status. Propono is still 0.6. Progress is slow. There is since 2006 a discussion what needs to be done to move to 1.0. The discussion was never intense and therefore, never reached a fix point.
  • Dave works for a different company and does not invest too much time in ROME.
  • Compiling ROME 0.9 is okay, but Propono 0.6 requires 0.9.1-dev. So you need to get the binary or get the sources from CVS. But even these don’t compile.
  • While ROME is available via Maven repositories, and hence, easily to include into a project, ROME 0.9.1-dev is not available. Actually, there is no need for that, because ROME Propono is not available via Maven repositories add all.
  • Finally, I observed quite often that users in discussion forums waited for answers from experts quite long. Some questions stayed unanswered.

Meanwhile, I found an article about Abdera in Dave’s blog. Abdera is a promising Atom framework that provides many features. It has many committers and the forum seems to be quite busy. It is easy to integrate into maven projects and even the build is fun. Despite of its early status it promises a good quality. Documentation is still scarce, however, it is sufficient to get started. One annoying thing is, that James Snell, one of the project leaders, maintains a wordpress blog which does not offer RSS/Atom feeds. This is really dull, because he is blogging about Abdera and the Atom specification quite often.

To solve the user management requirement, Roller offers an atom admin interface to create/update/delete users. This is necessary in order to have the same users on Roller as in my application. Again, to access the interface, the source application needs a client through which it can talk to Roller. Propono offers an atom client solution. However, it is not applicable because of the explained problems. The work around is to use Abdera. Abdera has a clean interface and following a few examples should help to solve this requirement.

In the end, I dropped both approaches due to some Spring problems I did not understand. Instead, I looked at the Roller’s code closely and decided to integrate very basic blogging facilities into my application. To get things done, this is the most efficient way. Maybe, one day, I get back to Roller.

Java Podcasts in iTunes

Posted by Martin Homik | Posted in Java | Posted on 11-06-2008

2

Yesterday evening, I came across the Podcast function in iTunes. I downloaded a few keynote presentations by Steve Jobs and uploaded these to my iPhone. I had the idea to use my iPhone for education for some time, but I could not find any good video podcasts. Today, I went o iTunes store, selected the podcast tab and searched for Java. I got a few hits, some of them I want to recommend:

  • Algorithmen; a German lecture podcast on algorithms and Java implementations
  • jQuery

Do you know any other video podcasts? In particular, I am searching for conference podcasts related to Java, Web2.0, and e-learning.

OSGI and Spring

Posted by Martin Homik | Posted in Java, WebApp | Posted on 11-06-2008

0

There is a great presentation on OSGi and Spring at Parleys by Adrian Colyer and Costin Leau. They give a great introduction into OSGi and Spring and explain how to integrate both frameworks.

If you ask what are the benefits of going OSGi with Spring, read Adrian’s article Why should I care about OSGi anyway? 

Parleys.com

Posted by Martin Homik | Posted in Java | Posted on 10-06-2008

0

Parleys offers some new presentations on the latest Java technology. Also, the website got a new UI which looks pretty cool now. You can view the talks online or download and watch locally on your host.

Have fun!

Book Review: RSS and Atom

Posted by Martin Homik | Posted in Java | Posted on 02-06-2008

1

Like most of Manning’s books, RSS and Atom in Action is a high quality book. Beginning with some real-world scenarios, Dave Johnson introduces the interested reader into the world of blogging. Often, he talks about examples and points to ideas on how to (re-) use weblogs in a sophisticated way.

The book consists of two parts, the first part introduces related technical knowledge, the second part is a hands-on tutorial which presents various application ideas.

In the technical part, Dave Johnson presents details  on the history of different newsfeed formats (RSS and Atom), the ROME newsfeed utilities, a BlogClient API (known as Propono), how to serve newsfeeds, and how to publish with XML-RPC based APIs (MetaWeblog)  as well as with Atom protocol. All examples are accompanied by code snippets either in Java or in C#. The full code is available from the website.

In the application part, you’ll learn how to implement diverse applications such as as group aggregator, searching and monitoring the web, keeping your blog in sync, blog by sending an email (from your mobile), sending a daily digest by email, blog your software build process, blog from a chat room, distribute files podcast style, automatically download podcasts, automatically validate newsfeeds, and lots more.

You get the idea, this book is written for a practitioner who need to grasp the idea and learn by training. I highly recommend this book if you are interested in blogging, syndication, aggregation, etc.

If you need more details about software and if you are a Java developer, have also a look at Roller, Propono, and Rome. Dave is involved in all three quite popular frameworks. Follow his blog to get the latest news.