RSS Feed
15
October
2003

Why extending Struts? Why not simply use WW2?

Posted by woeye | Comments: 0

Some people might wonder why I worked on IoC and interceptor support for Struts. Though I really like WW2 for it is very well designed it is sometimes not possible for me to use WW2 in production enviroments. Decision makers are seldom interesseted in "technical well designed" but rather in "well known". Struts is nowadays a well known framework. Even IBM has a hole chapter about Struts in one of its WebSphere 4.0 RedBooks. But I really hope that WW2 gets more publicity so that it is easier for me to convince those decision makers :-)

15
October
2003

How I have added IoC to Struts Actions

Posted by woeye | Comments: 7

One of the cool features of WebWork2 is the use of the IoC (Inversion of Control) design pattern. I asked myself wether it would be possible to add IoC to Struts Actions as well and after some meditation I have ended up with a solution which I want to discuss now. The class who is responsible for creating Action instances is RequestProcessor or TilesRequestProcessor if you are using Tiles. If you look at RequestProcessor you will notice the method processActionCreate. As the name suggests this method is responsible for creating the Action instances. Therefore I decided to derive from TilesRequestProcessor and overwrite processActionCreate. Inside the method I use reflection in order to find out wether the action returned by super.processActionCreate(...) implements on of the registered awareable interfaces. In case the action does I call the setter method declared in the interface. The registered awareable interfaces are maintained by a class called ComponentRegistry. This class is designed as a singleton. At last I wrote a Struts plugin that performs the initial registration of the awareable interfaces and their corresponding object instances.

Here's a code snippet from my custom RequestProcessor:
[code] protected Action processActionCreate(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) throws IOException { Action action = super.processActionCreate(request, response, mapping);

// Look for Awareable classes (IoC) and invoke the setters if present ComponentRegistry registry = ComponentRegistry.getSharedInstance(); Set classes = registry.getRegisteredClasses(); Iterator it = classes.iterator(); while (it.hasNext()) { Class awareableIf = (Class)it.next(); if (awareableIf.isAssignableFrom(action.getClass())) { Object instance = registry.findComponent(awareableIf); log.debug("instance for interface [" + awareableIf + "]: " + instance); if (instance != null) { Method[] methods = awareableIf.getMethods(); if (methods.length != 1) throw new IOException("The awareable interface must exactly contain one method"); try { log.debug("Invoking method: " + methods[0]); methods[0].invoke(action, new Object[]{instance}); } catch(Exception ex) { log.error("Could not invoke setter on awareable interface", ex); throw new IOException("Could not invoke setter on awareable interface"); } } } } return action } [/code]

As you can see currently the setter of the awareable interface will be called on every request because the action caching is handled inside super.processActionCreate(...) and there's no way to find out if an action was created or reused as far as I know. Therefore you might want to cache the name of the classes whose setter you called.

Now that I have IoC I am looking into Interceptors :-) ...

15
October
2003

Restarting webapps in JBoss/Jetty broken on win32 systems?

Posted by woeye | Comments: 0

If you try to redeply a webapp via jmx-console in JBoss/Jetty you may get the following error:

java.io.FileNotFoundException: C:javajboss-3.2.1...jbossweb-jetty.sar.webdefault.xml 
is alias of C:javajboss-3.2.1...jbossweb-jetty.sarwebdefault.xml
...
After digging into the sources I possibly found the bug in the toString() method of BadResource.java because the toString() method appends additional information to the original URL. The toString() method, however, is used by WebApplicationContext as the path to webdefault.xml.
I have already posted a mail on the jetty-discuss mailinglist. I will keep you informed about the status ...

15
October
2003

Now I have interceptors for Struts actions as well

Posted by woeye | Comments: 5

I have extended my custom RequestProcessor once again. With the help of Jakarta's Commons Digester it was very easy to create a simple XML based configuration file. Then I decided to move the IoC stuff from the RequestProcessor into an interceptor called ComponentInterceptor. Not only it shows that my interceptor extension does work but the code looks much cleaner now. I hope to release my work under Open Source soon. But before that I must set up an infrastructure first ...

15
October
2003

How I've got WebSphere 4.0 running on Gentoo 1.4

Posted by woeye | Comments: 50

Some days ago I've installed Gentoo 1.4 on my Dell box because I was sick of the RPM hell. The good thing is that Gentoo is up-to-date concerning system software packages. The bad thing is that Gentoo is up-to-date concerning system software packages? Err? Well, in case you are able to compile the sources on your own ... fine! But commercial software very often requires old system packages, mostly older versions of the GLIBC. IBM's WebSphere 4.0 is such a candiate (in fact the bundled JVM is affected) and therefore it requires some tweaking in order to run on Gentoo 1.4. After some investigation I found out that WebSphere 4.0 requires a GLIBC with kernel 2.2.5 support. Fortunately the GLIBC which comes with Gentoo 1.4 can support this feature. It is, however, disabled by default and therefore you must recompile the GLIBC. The following steps are required: [code] 1. Change into the directory /usr/portage/sys-kernel/linux-headers 2. Emerge linux-headers-2.2.20.ebuild 3. Drink some coffee 4. Change into the directory /usr/portage/sys-libs/glibc 5. Emerge glibc-2.3.2-r1.ebuild 6. Drink lots of coffee or take a walk [/code] Make sure that you do not have "ntpl" in your USE variable before rebuilding the GLIBC. Afterwards WebSphere 4.0 should run fine =)

« 1 2 3 ...  24 25 26 27 28 29 30 »