On 3/11/07 1:17 PM, "Dave Newton" <[EMAIL PROTECTED]> wrote:
> --- Mark Menard <[EMAIL PROTECTED]> wrote: >> Take a look: http://www.vitarara.org/cms/groovyworks > > Is this primarily a classloader for Groovy actions so > you don't need to define them in an applicationContext > config? Yes, because Spring seems to return a proxy of the scripted bean. So, you have to have an interface for all of the methods you want to be accessible on the action. My purpose is to save work, not create it, by having to have interfaces for all of my actions. The plugin is very much an extension of the spring plugin, just inserting the code to use the GroovyClassLoader when it encounters an action class name that ends in ".groovy". public Class getClassInstance (String className) throws ClassNotFoundException { if (className.endsWith (".groovy") ) { log.debug ("Attempting to load a Groovy script: " + className); // Check and see if the resource exists on the Classpath. InputStream inputStream = ClassLoaderUtil.getResourceAsStream (className, this.getClass () ); if (inputStream != null) { // The script file exists in the classpath and has been loaded as an InputStream. // Use the GroovyCLassLoader to load the class. Class clazz = gcl.parseClass (inputStream, className); try { Object ob = clazz.newInstance (); } catch (Exception e) { log.debug (e); } return clazz; // return gcl.parseClass (inputStream, className); } else { log.debug ("GroovyClassLoader did not return a class."); throw new ClassNotFoundException ("ERROR: Could not load groovy script " + className); } } else { return super.getClassInstance (className); } } I would prefer to simply have Spring instantiate the actions, but there is the proxy issue, plus Spring only support singleton scripted beans. (Although I have a patch for the singleton issue.) My reason for preferring that Spring instantiate the action is then I could wire it explicitly in my applicationContext. Right now they are being wired by name, which I do not prefer. I have that turned off in my application context myself. The other reason to prefer Spring is then this would work with any scripted language supported by Spring. You could implement your actions in JRuby, or whatever you'd like. (I personally like Groovy because it's so close to Java.) Take care, Mark --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]