Archive for March, 2005

Transactions

March 18, 2005

There is a huge debate/discussion going on recently on a project I’m on. Basically, the project is like 1/5 into development and there is little or no direction on handling transactions. What is there is directly managing them from the business delegate…which is ok…if handled properly. They aren’t playing nicely with others (seeing if one already exists, not committing if didn’t start, etc).

The biggest voice advocating that a standard or reusable pattern emerge is recommending an approach that would wrap the entire web request in a transaction (if the associated request would result in a call to a delegate that need to be executed in the context of a transaction). I really don’t want to settle with this as the only method for identifying/handling transactions. The delegates are written to be reused…and, in part, to encapsulate (and insulate the caller from) the underlying details. By having the delegate just assume it is running in the context of a transaction and/or forcing all calling code to know that a transaction is required will break that encapsulation and inevitably lead to breakages.

I agree that handling the transactions in the code is not easy (when done properly and thought through), and it can be messy. This is why I (and many others) like(d) session beans…and spring’s declarative transaction management. We don’t have the luxury of spring on the project, but we can easily implement a template approach (a la spring jdbc layer), or even more directly, just factor out the start/end/rollbackonly transaction logic into a helper class. The decision is leaning heavily toward the last. I didn’t propose that solution, but it is a good on for our case. The delegates still start/stop transactions, but it is much cleaner (much of the detail is handled in the helper). This allows for those who feel the entire web request should be handled in a transaction to still do that, but when the delegate is reused in a different (possibly non-request related) context, the behaviour will be predictable (won’t break).

Rules Engine

March 17, 2005

Just another comment about web flow. The scenarios and workflows in ATG are really considered rules engines. I wonder if it would be worth it to have a core rules engine for spring that the web flows is built on top of.

Spring Web Flow

March 17, 2005

Sounds like spring Web flow is seeing some major improvements. I’d really like to give this a look. It looks like the new stuff has moved to a kind of ‘context-injection’ where the context of the flow/flow environment is injected into the methods. Or maybe I’m just seeing it that way because of the article on TSS on The validity of IOC. Also it is sounding more like they should change the name…less a ‘web flow’…more a general flow technology. Its interesting how things tend to line up. I have recently been looking at ATG’s scenarios and workflows and they sound a lot like spring web flow.

I’ll definitely start playing with it soon.

I want a powerbook

March 16, 2005

I really really want a powerbook. My laptop (dell inspiron 4000) is really really about to bite the dust. I actually put some more money into it about 5-6 months ago. Now the touchpad will stop working for like 30 seconds if the keyboard is flexed. Also the screen will turn all sorts of shades of blue sporadically…like all the red goes out. Friend of mine got a powerbook…I’ve wanted one for so long. My wife keeps telling me “Just get it and stop talking about it!” I’m really just waiting for Tiger to come out…which I heard should be mid april. So, I’ve waited this long, I can wait until april I guess…

SpringLive

March 15, 2005

I just read the sample chapter for Raible’s Spring Live book on SourceBeat. It was decent. Here are my thoughts.
Liked:

  • The example he is working through is done Tests-first (TDD).
  • The explaination/example of using the tomcat targets in ant was good…I’d never done that before (though I knew it was out there) so it was good to see them in action.
  • The example of MockStrutsTestCase…I definitely need to try this out (actually Matt asked me at one point if the AutowiringStrutsRequestProcessor would work with it…need to look closer).

Didn’t Like:

  • Doesn’t use the spring base test cases to autowire the actions…but I can understand the need for simplicity in this chapter.
  • Has comments telling the user to “Organize Imports” I would expect the source example to be complete and then include a hint to do an organize imports.
  • His business delegate is “Web Friendly”…basically it takes Strings and converts where it shouldn’t. Not major…just don’t like the feel of it.
  • I think he should have split the adding transactions via Spring AOP stuff to a different section. Seems like too much is being crammed into one section.
  • Made his form request scope…then explaination of it was confusing.
  • Step 8 on page 45 says you need to also list the applicationContext.xml…I don’t think this is true (I’ll have to check) I think the web app context is automatically set as the parent context.
  • It was a bit long for a “quick start” tutorial.

All-in-all, it was a good read. I’d like to read the rest, but not sure about 30 a year…

UPDATE: Just read through the ref-guide and found that the reason for specifying the appcontext in the plugin is to get around a problem with MockStrutsTestCase…namely, that it will not load the listeners (and hence the parent spring context). I guess this won’t cause problems when running this way from an actual container? Will there be 2 instances of all the beans in applicationContext.xml at 2 different levels in the context tree?

Things to look at

March 14, 2005

I wish I had more time (doesn’t everyone?). I want to look at:
Ruby
Groovy
Spring Web Flows
XUL
Tapestry
Spring MVC
TestNG
Equinox/AppFuse
XmlHttpRequest

Books:
Beauty of CSS Design
J2EE W/O EJB
Tom Kyte’s books (had 2…need them again…work owned them)
(many more I’m sure).

I’ll get around to it all I’m sure…eventually.

I want a good CMS

March 11, 2005

I’m the webmaster for d8toastmasters.org. It is the website for District 8 Toastmasters (speaking club). I didn’t design the site, I’m currently just maintaining it. I want to put up a content management system so that the district officers (and members) can help publish content (or make posts that need to be approved). I’ve looked at php-nuke, post-nuke and mambo. I don’t really like any of them. Post nuke fit best, but I don’t like their article/category/content arrangement. It has to be super simple for the user (SUPER SIMPLE). I primarily need news articles, categories, calendar, static content, and it would be nice to have a custom module for management of the district structure. I really don’t want to write one (CMS) myself.

Like I said, PostNuke seems to fit pretty well…I just don’t think it is easy enough for my users. Well, it wasn’t the last time I looked at it. I tried to install it last night (via cpanel) and it wouldn’t startup (cannot create session).

Oh well, I’ll look into it some more. I guess I could write some custom district8 modules to make it simpler for what they want to do.

Struts AutowiringRequestProcessor

March 10, 2005

It looks like the guys at spring are looking into the AutowiringRequestProcessor. It allows the struts actions to be automatically wired by spring. Previously the Spring support allowed you to include bean definitions for the actions and you would wire them yourself. This led to 2 seperate config files for the actions: one for struts and one for spring. With the AutowiringRequestProcessor, the spring config file for the actions is eliminated. The processor will instantiate the class and then have the spring container autowire it by name. So Actions need only indicate their dependency on a bean in the container by having a setter for it. It also implements a cache-by-class scheme so that only one instance of an action is loaded by the processor. In the current support one instance is created per mapping (so if you have 100 forward actions, 100 instances are created…in this version there would only be 1). This is perfect considering the thread-safe’ness of the Actions (or at least they should be written that way).
It also tries to be smart and check to see if there is a bean in the container whose name matches the action mapping. This is essentially what the existing DelegatingRequestProcessor does. I figured it would be nice to allow the flexibility of wiring the Action directly if you have more complex needs. I have never needed it…and may never need it. I just thought it was TOO easy to allow the flexibility. Following proper (at least what is seen as proper today) design, I should never need it…but (to quote a colleague of mine) “Somtimes you gotta write bad code”. This flexibility may not wind up in the final implementation…and I’m ok with that, I mean we do want to encourage good coding practices right.

Another Nucleus Post

March 9, 2005

I haven’t got any replies to my developer list post yet, but someone posted to the spring user list asking if anyone had ported their ATG app to Spring. I replied with the following:

I’ve only been working with ATG for 2 weeks…but I did put together
some code to tie the 2 IoC containers together that may help you
during the migration.
You can easily reference Nucleus components from Spring by using the
JndiObjectFactory since ATG publishes all the Nucleus components to
JNDI:

<bean id=”test” class=”com.foo.Test”>
<property name=”nucleusBean”>
<bean class=”org.springframework.jndi.JndiObjectFactoryBean”>
<property name=”jndiName”><value>dynamo:/some/nucleus/bean/Test</value></property>
</bean>
</property>
</bean>

Where /some/nucleus/bean/Test is the location of the bean in Nucleus.

You can also go the other way (reference spring managed beans from
Nucleus)…but this is a bit more involved and may not help in you
situation.

JNDI and Nuclues

March 8, 2005

Ok so just one more…Dynamo makes all ATG components available via JNDI. That means I don’t need a custom factory bean to grab a Nucleus component…I can just use the JndiObjectFactoryBean. I think this actually shows the strengths of both frameworks.