Resin, what happened?
April 29, 2007 on 2:54 pm | In Technical stuff | 3 CommentsI’ve been a loyal Resin user for about 3 years now. For a time, it was one of the fastest servlet containers. Well, I have an web-app, made up of 3 wars. It uses a number of open-source, 3rd party libraries, such as Hibernate, Spring, Acegi, DisplayTag. The length of startup time has never really been an issue. However, after upgrading from resin-3.0.19 to resin-3.0.23, and deploying the expanded war, startup time went from 90 to 117 seconds.
Since I simply deployed the expanded war from on instance to another, I knew it had nothing to do w/ the war contents. Rather Resin was doing something different. The majority of load time seems to be during the precompiling of jsps. I wouldn’t mind the extra time, if a benefit was visible at request-time, but I didn’t see that. Although just a visual inspection, the pages returned in about the same speed.
I was initially writing to see if maybe i was imagining this — and then I saw a comparison done by Matt Raible. Guess should to take a closer look at Tomcat-5.5.
Re-attachment
April 24, 2007 on 12:39 am | In Technical stuff | 5 CommentsIf you use Hibernate and Spring, but no JTA or Seam, and you have to subscribe to the session-per-request-with-detached-objects model, you may have run into the following situation: having to reattaching detached objects to the current open Hibernate session. Even with an Open-Session-In-View filter or interceptor, you may have situations where you need to perform and operation on a detached object, but its parent session is closed.
Well, there are a few ways to handle this. Jason C. showed me some code that would merge pending changes, using the merge(…) method on the Session interface. In my situation, I needed a way to attach the persistent parent to the current open session, and let the natural cascading occur. So, AOP to the rescue. I added the ReattachAdvice (below) as advice to the all my DAOs, for their “save*” and “update*” methods.
public class ReattachAdvice implements MethodBeforeAdvice {
...
public ReattachAdvice(String... inomingMethodNames) {
// store incoming method name patterns
}
/**
* @see org.springframework.aop.MethodBeforeAdvice#before(java.lang.reflect.Method,Object[],Object)
*/
public void before(Method method, Object[] incomingArgs, Object target) throws Throwable {
...
if (!(target instanceof AbstractHibernateDao)) return;
final HibernateTemplate template = ((AbstractHibernateDao) target).getTemplate();
final String methodName = method.getName();
for (String pattern : namePatterns) {
// Is a handled method?
if (CommonUtil.stringMatch(pattern, methodName)) {
for (int index = 0; index < incomingArgs.length; index++) {
Object tmpArg = incomingArgs[index];
if (tmpArg instanceof Entity) {
incomingArgs[index] = handleEntity(template, (Entity) tmpArg);
}
}
return;
}
}
}
private static Entity handleEntity(HibernateTemplate template, Entity entity) {
if (entity.isPersisted()) {
try {
entity = (Entity) template.merge(entity);
} catch (StaleObjectStateException e) {
template.load(entity, entity.getId());
}
}
return entity;
}
}
Then I had to make the following addition in my Spring context files. Pre-AOP, I would have had to ensure that any method that might run into this issue, would call some re-attach method. This seems cleaner.
<bean id="reattachAdvice" class="somepackaging.ReattachAdvice">
<constructor-arg>
<list>
<value>save*</value>
<value>update*</value>
</list>
</constructor>
</bean>
...
<bean id="daoTemplate" class="org.springframework.aop.framework.ProxyFactoryBean" abstract="true">
<property name="interceptorNames">
<list>
<value>reattachAdvice</value>
... other advice
</list>
</property>
</bean>
just like a mini-mall…
April 22, 2007 on 12:34 am | In Funny | No CommentsI saw this months ago, and sent it in an email to a few people. When I last checked it had 960,020 views. It’s basically the best commercial ever! Well, I saw a reference to it on SNL last night, and thought why not post it here. Enjoy.
Echoes
April 18, 2007 on 2:56 pm | In General | No CommentsSome guy (Jason) takes digital pictures of stuff (Rochester, NY). Vote for his work here. Note: You’ll have to sign up.
Cash to Kermit
April 6, 2007 on 10:43 pm | In Funny | No CommentsJohnny Cash’s last video before he and his wife passed on was to the song Hurt. It was excellent. Here’s a rendition of that video with Kermit the Frog. Enjoy.
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^

