Pages

reuse of visual content in java projects

Hm.. what are my options when you want to reuse some visual content rendered by some other runtime component?

Let’s say you have war A that renders some pages. Let’s say you’re writing another war (B)  and you suddenly want to reuse some ot the content from A. Let’s say you want to inherit, but also tweak. Parameterize I guess. I could..

  • do: jstl <c:import url=”<absolute or relative url>”/>in a jsp page. This includes rendered content however, so you don’t get to influence the content before rendering.
  • do: response.sendRedirect(<absolute or relative url); on the server side. Ditto disadvantage as above.
  • make a jsp taglib. I principle I guess you may put anything in the start and end tag methods, but in practice it is at best an unelegant method for reusing visual content with some size and layout
  • use maven2’s war plugin’s overlay functionality. This works, but is somewhat crude, and requires good control over naming and directories.
  • make a (jsf 2.0+) facelet taglib. No disadvantages, but a huge added bonus that you may include all kinds of fancy layout and composition as you would normally do with facelets. And paramterization works just fine. :-D

So this last option is the only good option in my opinion. Let’s have a look;

Component A

In web.xml you define the taglib;

<context-param>
 <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
 <param-value>
 /META-INF/mfoTags.taglib.xml
 </param-value>
 </context-param>

In META-INF (nowhere else, or the inter-module/war dependency will not work) you define mfoTags.taglib.xml (and it needs to have both taglib and xml as postfixes) :

<?xml version="1.0" encoding="UTF-8"?>
 <facelet-taglib>
 <namespace>http://yarc.name/mfoFaceletTags</namespace>
 <tag>
 <tag-name>siteNav</tag-name>
 <source>../WEB-INF/tags/siteNav.xhtml</source>
 </tag>
 </facelet-taglib>

..and you need (at least) an empty faces-config.xml:

<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC
 "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
 "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
</faces-config>

Finally, you need to package this as a jar (not a war). My solution here was to make a symbolic link since I wanted component A to remain a war since it is used as a war component on it’s own.

That’s it. Now for the user of this component;

Component B

You need to include a classpath ref to the above mentioned jar.

In the .xhtml file you’re going to refer to the facelet tag

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:mf="http://yarc.name/mfoFaceletTags"

...

>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 ...
 </head>
 <body>
 ...
 <mf:siteNav/>
 </body>
 </html>

If that isn’t simple and beautiful, then I don’t know what. Almost poetry. :-)

Week-end time!

Thanks to Laliluna for small tricks and hints and the excellent facelet documentation.

Wow and wine on ubuntu 9.04 64 bit

I find you quite frequently need to have a fresh development version of Wine to play world of warcraft on linux. So, these are the steps I followed:

  • GitWine – sets you up with Wine’s latest development snapshot. Only section 2 applies for those of us who do not contribute.
  • Building 32-bit Wine on a 64-bit (x86-64) system:
    • “Building Wine on Ubuntu / Kubuntu 9.04 (Jaunty Jackalope)” section worked for me. A plain “make” doesn’t work out of the box and the
sudo apt-get build-dep wine

is crucial.

After that, one may do

wine InstallWoW.exe

..from the account management download client page. Now, the wow login page will fail with a “runtime error” r6034. Thanks to Neckrippa at http://forums.worldofwarcraft.com/thread.html?topicId=21723844202&sid=1 there is a fix;

Change the version number in

<assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.4053" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>

in the Microsoft.VC80.CRT.manifest (wow install directory) with

version="8.0.50727.762"

Then login is ok, and the game is works well.

secure copy which continues where you left off if interrupted

If I’m at liberty, I’ll in 10/10 cases be ssh based when communicating between hosts. Secure, easy, terminal with graphics (ssh -X), copy (scp) , remote filesystem (sshfs) and only one port to keep track of. Large copy operations are a bit annoying over a normal scp however, since if the copy is interrupted for some reason, you have to start all over again. Combined with rsync however, this problem goes away;

$ rsync -avz –partial -e ssh me@remotehost:/remotedir localdir

The z flag is dependent on the tradeoff between cpu power, bandwidth and the nature of the files I guess.

The only other annoying thing I can think of is the lack of sshfs support with Windows. But NTFS is a dinosaur, so what can one expect I guess..

Latex config for Springer

Hm. With my ubuntu 9.04 64 bit there were a couple of things that were needed to be able to compile the provided typeinst.tex file from Springer:

  • copy all .zip content into dir where you write your article
  • apt-get install texlive-latex-base
  • apt-get install texlive-latex-extra
  • setup you graphics.cfg file:

\ExecuteOptions{dvips}

  • setup your TEXINPUTS path:

#!/bin/bash

export TEXPATH

for dir in `ls /usr/share/texmf-texlive/tex/latex`; do
TEXPATH=$TEXPATH:/usr/share/texmf-texlive/tex/latex/$dir
done

export TEXINPUTS=.:./styles:./templates:./instructions:$TEXPATH

A better browser multimedia config for Ubuntu 64 bit

I don’t know why, but my ubuntu 9.04 64 bit comes with a sub-optimal firefox multimedia setup. As previously discussed, the BBC world service doesn’t work out of the box, the australian open videos don’t work with the Totem/VLC (or whatever it is) plug-in, even after waiting for codec downloads. It’s just not particularly good.

But, it can be configured to play just about any video, dvd or audio I’ve managed to find. Thanks to Ariel, medibuntu and MPlayer.

But why ubuntu? Why choose something suboptimal when it is really easy to do better?

Glue and scissors in Spring Integration

It looks deceptively elegant. There is just so little that is required to make channels, gateways, publishers, subscribers and content transformers with spring integration. This ultrashort tutorial guides you through the basics, including the extremely condensed glue;

 <gateway id="leadGateway"
        service-interface="crm.integration.gateways.LeadGateway" />

    <publish-subscribe-channel id="newLeadChannel" />

    <service-activator
        input-channel="newLeadChannel"
        ref="leadService"
        method="createLead" />

    <transformer input-channel="newLeadChannel" output-channel="confEmailChannel">
        <beans:bean>
            <beans:property name="confFrom" value="${conf.email.from}" />
            <beans:property name="confSubject" value="${conf.email.subject}" />
            <beans:property name="confText" value="${conf.email.text}" />
        </beans:bean>
    </transformer>

    <channel id="confEmailChannel" />

    <mail:outbound-channel-adapter
        channel="confEmailChannel"
        mail-sender="mailSender" />

The example code comes as a maven bundle. Compiles nicely. Short and concise. But I didn’t get it to deploy to my GlassFish V3 out of the box via a http://localhost:31843/crm-1.0.0.RELEASE/ url.

Oh well. Better have to look at that tomorrow or so then..
 

Accessing ext3 drive from windows 7 64 bit

My main laptop is a dual boot Windows 7 64 bit Enterprise and an Ubuntu 9.04 64 bit. I want to access my ext3 drives from windows. Before I always used ext2ifs, but that doesn’t work with this os setup.

EXT2FSD does the trick however. It installs in the 64 bit Program files directory and it needs to be run as administrator. Not all the mount options (under f4->”add” button) seems to work, but the last option – “Create a permanent MountPoint via SessionManager..” works after system reboot. I did not check the “write” when I installed the app.

BBC world service plain url

I’m a great fan of the BBC World Service. I’m not a fan of BBC’s media streaming service. For us who are routinely using non-windows operating systems, it is a pain to stream the world service. The iPlayer they’ve devised is difficult on linux and does in general not work out of the box.

Why can’t we be presented with a simple, plain url?

Buried deep inside the iPlayer, the url exists however;

mms://livewmstream-ws.bbc.co.uk.edgestreams.net/reflector:38972

So, my plea to the BBC is; do what the Norwegian Broadcasting Authority has done for years – present a set of streaming url’s and then let users themselves use whatever client they want to to play the stream.

architectural viewpoints and perspectives

I’m somewhat confused, I guess. I thought my understanding of a software architectural viewpoint was fairly sound. I read about work on architectural perspectives, in particular the work by Nick Rozanski and Eoin Woods (here is an accessible presentation).

Now, let’s have a look at the original view and viewpoint definition (all from the aforementioned presentation);

“A viewpoint is a collection of patterns, templates and conventions
for constructing one type of view. It defines the stakeholders
whose concerns are reflected in the viewpoint, and guidelines and
principles and template models for constructing its views.
A view is a representation of all or part of an architecture, from
the perspective of one or more concerns which are held by one or
more of its stakeholders.”

Typical views may be the 4+1 by Kruchten (RUP)  – Logical, Development, Physical, Process. Other blueprints have been suggested.

Now, let’s turn to perspectives. Defined, by the same source;

“Architectural perspective is a collection of activities, checklists,
tactics and guidelines to guide the process of ensuring that a
system exhibits a particular set of closely related quality properties
that require consideration across a number of the system’s
architectural views.”

Fair enough. Blueprint-type examples they come up with are essentially quality attributes as viewpoints, e.g. “Performance and Scalability, Security, Availability and Resilience, Evolution etc.

Now, what I don’t get is why this has to be a new type of concept in IEEE 1471-2000’s taxonomy. Why can’t we use viewpoints for quality attributes? A viewpoint is governed by a stakeholder’s concern. If the stakeholder is concerned with a particular quality attribute – fine, then a view may be constructed to reflect this. I cannot see why I need a perspective to cater for this.

Clearly, there is something I’m missing.

Anybody?

Eve Online tribute

I’ve played my share of games over some 25 years or so. One of the great ones is Eve online. It is quite different from other MMOs I’ve played. Fundamentally, I guess it is the feeling that there is real risk involved that makes it different.And it’s a bonus that it may be played on a linux host. Ubuntu 64 bits. :-D

Infinity exiting Oursulaert