Vita Rara: A Life Uncommon

Spring issue solved

I modified a bit your Groovy Works class, and now Groovy defined beans are exposed as expected by Struts. It's pretty simple actually, all you have to do is to add this method:

public Object buildBean(String beanName, Map extraContext)
throws Exception
{
Object o = super.buildBean(beanName, extraContext);

if (o != null) {
String name = o.getClass().getName();
if (name.startsWith("$Proxy")) {
Method m = o.getClass().getMethod("getTargetSource", null);
o = m.invoke(o, null);
m = o.getClass().getMethod("getTarget", null);
o = m.invoke(o, null);
}
}

return o;
}

My name is Martin Mavrov, and I came to your page while evaluating different web frameworks that have expressive power at least matching JSF's. At the same time I want to be able to do most things without restarting the J2EE server, so the framework should support Groovy. This is how your solution got in my field of view. But I still wanted to have everything nicely embedded in Spring, so I tried to find a way to have reloading scripted Spring beans as actions in Struts 2. Now hopefully I have settled for Struts 2 + Spring + Groovy + JPA for future projects.

BTW, if you are satisfied with the solution, you are free to put it in GroovyWorks.

Reply

Please solve the math problem above and type in the result. e.g. for 1+1, type 2
  • Allowed HTML tags: <a> <img> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <h1> <h2> <h3>
  • Lines and paragraphs break automatically.
More information about formatting options