Dec 14, 2009

CZJUG Prosinec - Vaadin a Vánoční hrátky s JAXB

Prosincové setkání Czech Java User Group probehne 14.12. od 19 hodin v posluchárně S5 na Matematicko-fyzikální fakultě Karlovy Univerzity na Malostranském náměstí 25, Praha 1.
  • Vaadin - Rich web applications in plain Java without plugins or JavaScript
  • Vánoční hrátky s JAXB

Dec 13, 2009

Xmarks for Chrome!

Xmarks is the #1 bookmarking add-on. Xmarks synchronizes across multiple computers, and across web browsers: Chrome, Firefox, Safari and Internet Explorer. After you install the add-on, click on the notification to set up Xmarks and start backing up and synchronizing your bookmarks. Xmarks sync profiles give you full control over which bookmarks are synced to which computers, allowing you to keep private bookmarks at home while syncing everything else to your work computer. Xmarks automatically keeps a backup of each bookmark change, making it easy to backup and restore your bookmark sets.

Dec 7, 2009

HTTP basic authentication with JAX-WS (Client)

JAX-WS does not do very well with HTTP basic authentication. In general, to create and use a web-service client you have to perform the following steps: 1. Use wsimport to generate the stub files 2. Create a service class in the client 3. Retrieve a proxy to the service, also known as a port All three steps could require HTTP basic authentication. And for each step it have to be handled in a different way.

1. The stub files generation

If access to a wsdl file is restricted with basic authentication, wsimport fails to get it. Unfortunately it does not support the common approach to write access credentials right into the
URL (RFC 1738). It is not a big deal to resolve this issue. You just need to create a server authentication file: $HOME/.metro/auth. This file should have the WSDL URL with username and password in the RFC 1738 format:
You can have line delimited multiple entries in this file and they can be used for various sites that need basic authentication.

2. The service class creation

A constructor of the service object requires access to the WSDL. And again it does not support basic authentication out of the box. You have an option to download the wsdl file and use it locally. Another option is to use the default authenticator:
Authenticator.setDefault(new Authenticator() {
 protected PasswordAuthentication getPasswordAuthentication() {
   return new PasswordAuthentication(

3. The service class configuration

And the last but not least part of our adventure is configuration of the service port:
OurWebService service = new OurWebService ();
OurWebServicePortType port = service.getOurWebServicePortType();

BindingProvider bindingProvider = (BindingProvider)port;
Map requestContext = bindingProvider.getRequestContext();
requestContext.put(BindingProvider.USERNAME_PROPERTY, USER_NAME);
requestContext.put(BindingProvider.PASSWORD_PROPERTY, PASSWORD);
Done! Now you are able to use methods of the port object to communicate with a web service.

Dec 2, 2009

java6 splash screen and maven project

Splash screens are a standard part of any modern graphical user interface (GUI) application. Their primary purpose is to let the user know that the application is starting up. An application that displays a polished and professional-looking splash screen can occupy the user's attention and gain the user's confidence that the application is starting. Fortunately, Java™ SE 6 provides a solution that allows the application to display the splash screen even before the virtual machine starts. A Java application launcher is able to decode an image and display it in a simple non-decorated window. How to configure splash screen for the application in a maven project? 1. Put you splash screen image somewhere in a class path. Let it be something like "YourProjectName/src/main/resources/images/splash.png" 2. Add maven-jar-plugin to the POM file 3. Configure a manifest generation The final fragment of the POM file looks like one below: