Hjem   |   Kontakt   |   Sitemap
Hvem er vi Hvad kan vi Vores kunder Ledige stillinger Kontakt os Blog

Welcome to CODE3's Techchat

Scala and project jigsaw at JavaOne

Published Wednesday, June 24th, 2009 by AN

A couple of us from Code3 went to JavaOne this year. I saw some great presentations (and some not-so-great). And of course I missed some great presentations. Unfortunately not that many presentations are online. Here is one I missed, which has a great segment (first 30 mins) on project jigsaw – the proposed module system for OpenJDK7. It looks like Java will finally fit well on modern GNU/Linux operating systems like Ubuntu.

My favorite presentation was “The feel of Scala” by Bill Venners (I ran out and bought his Scala book after the presentation). This presentation is not online (yet?) but I have found a video of the talk from another conference


Enjoy!


Groovy web shells – ajaxgroovyshell

Published Tuesday, May 19th, 2009 by AN

For the JEE web-app I am currently working on the main audience is power users/admins. So while I can code some usecases as nice seam pages that help the user solve a task, other usecase are difficult. The most difficult are the general batch processes that take the form “select, filter, apply”.

Unix users (who use shell scripts) know that a small amount of programming is effective at solving these problems. So for my web-app I was contemplating how to get something “shell-like” into the project. There are several projects that present a nice AJAX based web interface to the system shell on unix machines. Eg. shellinabox and ajaxterm. And there are several programming languages that seem suited for interacting with a Java app. Eg. Groovy, Jython, or Beanshell.

So I decided to try to combine the interactive groovy shell with an ajax frontend. After looking around quite a lot I found shellinabox which has a nice GPL’ed javascript vt100 front end (I found another here which is LGPL’ed).

After a some weekend studies of shellinabox I could make a prototype with the vt100.js of shellabox and the nice little python webserver of ajaxterm. With a little more hacking I was able to hook up the groovyshell as a web-app through a java servlet. The interactive performance sucked, because of some weirdness in standard java.io.PipedInput/OutputStream classes, but fortunately I was not the first with that problem so with some small hacks to the replacement classes from LiveGraph the interactivity became tolerable.

From this working state there is actually still quite a bit of work to have something that I can deploy on a customer production server. But when Guillaume Laforge announced his cool little app “GroovyWebConsole” to run a groovyshell on the Google AppEngine I figured that I might as well upload what I had and announce it as well. Here is the announcement I sent to groovy-users

I have made a similar app to administer a JEE app I’m doing. It is
similar but is stateful and uses a vt100 interpreter in javascript (from
shellinabox).

You can find it here

http://code.google.com/p/ajaxgroovyshell

It is mostly a prototype – to be really useful for me I need to add

1) Access control
2) A way to paste text from the system (a pop-up textarea?)
3) Proper sessions
4) A robust way to handle threads
5) Syntax highlighting?
6) Better tab completion in GroovyShell (more like ipython)
Unfortunately it won’t run on the Google AppServer since I need a thread
for the GroovyShell.

Best
Anders

Since then I have noticed several java server projects that have some kind of console facility. But not as an ajax webpage (yet). I have suggested it a couple of places (like for Hudson, and for FRESH).


(Reusable) Dependent dropdowns in Seam and Richfaces

Published Thursday, May 7th, 2009 by AN

In the previous post I had some code to illustrate how I do dependent dropdowns with seam and richfaces. I cleaned it up to focus on the important stuff and I am not sure to which degree it compiles and runs. However, you may have noticed one thing that is certainly odd. Most of the operations are on the object named “vendormodelselector” which is described in the post. But the search action is on “searcher”. This is because I include the seam file on multiple pages with “ui:include” (xmlns:ui=”http://java.sun.com/jsf/facelets”). and with “ui:param” I can pass a different searcher object depending on the page. Like this

<ui:include src="vendormodelmenu.xhtml">
	<ui:param name="vendormodelheader" value="Appropriate header"/>
	<ui:param name="searcher" value="#{searcher_object_name}"/>
</ui:include>

Neat!


Dependent dropdowns in Seam and Richfaces

Published Friday, April 17th, 2009 by AN

It is not uncommon to want to make a combobox with choices that depend on another combobox. But it often seems very complicated to actually do this. So here is a piece of example code that I use with Seam and Richfaces. Imagine we have different vendors Vendors each with different Models of something.

The somewhat large blurb of Richfaces markup is to make two ordinary input textfields feel like two ajaxy comboboxes. It sucks a bit, but on the other hand the Java code is nice and clean.

How do you make dependent gui elements?


xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<div class="dialog">
Vendor</div>
<div class="dialog">
Model

<br class="clear" /></div>
package test;

import java.util.ArrayList;
import java.util.List;

import javax.ejb.Remove;
import javax.ejb.Stateful;

import org.jboss.labs.seam.guice.Guice;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.log.Log;

import com.google.inject.Inject;

import dk.telenor.tacs.api.DBApi;
import dk.telenor.tacs.db.Model;
import dk.telenor.tacs.db.Vendor;

@Stateful
@Scope(ScopeType.SESSION)
@Name("vendormodelselector")
@Guice
public class VendorModelSelectorBeanImpl implements VendorModelSelectorBean {

@Inject	private DBApi dbApi;

@Out(required = false, value="model")
private Model model = new Model();

@Out(required = false, value="vendor")
private Vendor vendor = new Vendor();

public List autocompleteVendor(){
return dbApi.getMatches(new Vendor());
}

public List autocompleteModel(){
if (vendor == null || vendor.getName() == null) {
return new ArrayList();
}
return dbApi.getMatches( new Model(vendor, null) );
}

public void setVendor(final Vendor vendor){
this.vendor = vendor;
}

public void setModel(final Model Model){
this.model = model;
}

public Model getModel(){
return model;
}

public boolean isReady(){
return model.getId() != null;
}

@Remove
public void destroy(){}
}

Working on One Thing At A Time

Published Wednesday, April 8th, 2009 by AN

…With Git-Svn)- to not break the build.

I hate breaking the build! So I have been looking for ways to use a
version control system to help me avoid it.

Currently I mostly work in SVN trunk, with the ocational feature branch
for large changes. The constant danger when I work in trunk is that I
start fixing two bugs at the same time, but try to commit the fixes
separately. If I screw that up it will sometimes break the build. Alas!

Now I found a blog-post by Frederic Jean describing a workflow (with git) that I think is what I was looking for. It sounds a bit complicated, but I will probably give it a try to see if it is worth the effort.


Using python SUDS for web service testing

Published Saturday, March 28th, 2009 by AN

I used to use something like SoapUI for casual calling of webservices. But most of the time a GUI feels like overkill for just calling one webservice function.

Recently I found the python SUDS library . It is so simple that I now just launch my all webservice calls from the command line.

from suds import WebFault
from suds.client import Client

client = Client('http://localhost:8080/myapp/mywebservice?wsdl')

print client

print client.service.MyFunction('Hello')

The “print client” in the middle prints an overview of the functions defined in the wsdl (nice to have). It is really easy. The only problem is that SUDS is not packaged in Debian/Ubuntu yet, so it is a little more trouble to install than just “apt-get install ….”. Maybe I should try to do something about that.


Serialize java objects

Published Wednesday, March 18th, 2009 by AN

For my current project I want to serialize some plain old java objects and store them in a database. That’s easy. However, for debugability I would like the serialized data to be human readable, and I figure that there should be plenty of libs that supply drop in replacement functionality for ObjectInputStream/ObjectOutputStream.

Well, it was a bit more difficult than I thought. From my first go at the problem I concluded to myself.

I can’t seem to find an XML serialization framework that works the same way as the plain old java serialization.

1) java.beans.Encoder : requires no-arg constructor, but doesn’t seem to handle collections properly (fails, returns null)

2) XStream : has too many dependencies.

3) Simple : requires annotations, and requires knowing the Class that we want to deserialize to (ugly but workable). Best candidate.

4) Betwixt : requires knowing the Class that we want to deserialize to, fails to handle collections without silly naming conventions or extra code.

5) Castor : requires knowing the Class that we want to deserialize to, not tried yet.

Fortunately I was too fast in my judgement of XStream (and maybe the other libs too?). Anyway, all of the dependencies for XStream are optional. And it has a plesantly simple API. Yay, XStream…


Using TDC’s Columbine with modern browsers

Thursday, April 14th, 2011
On columbine.tdc.dk there is a gui with tools for resellers of TDC eBSA products. These ...

Groovy CPE

Thursday, February 3rd, 2011
I've been working quite a lot on a TR069 AutoConfigurationServer. As part of the prototyping ...
 
© 2011 Code3 ApS  |  Kigkurren 8G, 3.TH  |  2300 København S  |  +45 7020 3383  |  kontakt@code3.dk