Late last night I updated the ColdSpring Bean Utilities RIAForge project. The updates include:

  • Added DynamicXMLBeanFactory: This extends the standard DefaultXMLBeanFactory but allows the ability to replace dynamic properties anywhere in the XML file, as well as in imported XML files.
  • Added MetadataAwareProxyFactoryBean: This extends the ColdSpring ProxyFactoryBean and automatically injects metadata information into any Advices that extend AbstractMetadataAwareAdvice after the AOP proxy is created.
  • Added MetadataAwareRemoteFactoryBean: This extends the ColdSpring RemoteFactoryBean and automatically injects metadata information into any Advices that extend AbstractMetadataAwareAdvice after the remote proxy is created.
  • Updated the AbstractMetadataAwareAdvice and the VOConverterAdvice for better integration with the new custom FactoryBeans.
  • Added an Examples subfolder to show these components working. A readme file is include to explain how to set it up.

The CFCs themselves all contain fairly thorough documentation in their header comments, but I'll talk briefly about some of the new components.

The new custom FactoryBeans (MetadataAwareProxyFactoryBean and MetadataAwareRemoteFactoryBean) are something of uncharted territory for me, and I'll be interested to hear what some other ColdSpring users think of how I am doing this. Basically, these extend the base ColdSpring ProxyFactoryBean and RemoteFactoryBean and contain logic to loop over the advice chain and inject metadata information into any advices that extend AbstractMetadataAwareAdvice.

Back when I first started talking about making metadata available to Advices by having ColdSpring pass the beanID of the proxied bean into the Advice, there was a lot of concern about increased coupling between the Advices and ColdSpring. I believe that the way I am using this sidesteps the issue.

My Advices are still extremely generic. All the metadata does is allow them to behave more flexibly. For example, I could create some security metadata that specifies different rules for different method calls, and a SecurityAdvice could would be able to process the correct rules for the current method call without a lot of conditional logic or actual dependence on the name of the bean or the name of the method. All it knows is that the metadata it was handed says "apply these rules now", and it does. The same could be true for a LoggingAdvice. All it would know is that the metadata being passed to it says "log these variables", and it does. The fact that you can specify different logging settings for different beans or methods is totally hidden from the Advice.

Overall I've found these new components to be very useful. I hope others agree! As always, please reply with any questions or comments. Thanks.

Comments Comments (5) | del.ico.us del.icio.us | Digg It! Digg It! | Linking Blogs Linking Blogs | 6895 Views

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)

  • # Posted By Jon Messer | 7/10/08 11:50 AM

    I really appreciate these tools and your ideas Brian. I started using the DynamicXml factory when you first blogged about it and love it. And of course I've been using the TDO injector for ever now.

    Very minor detail, when I went to run the examples there was an error. I'm on a mac and this line in app.cfc fails

    dynamicProperties.applicationPath = "/beanutils/example/"

    it works fine if I strip the trailing slash

    dynamicProperties.applicationPath = "/beanutils/example"


    Again thank you for sharing, these are excellent tools.

  • # Posted By Brian Kotek | 7/10/08 12:57 PM

    Hmm, odd Jon. It runs fine on my Macbook. Can you confirm that you have the latest version of ColdSpring from the CVS repository?

  • # Posted By Jon Messer | 7/10/08 1:23 PM

    I just checked out a new copy. The coldspring CVS repo is pretty messy, I'm using HEAD from /coldspring, I don't know how to tell the version from CVS, I assume that is the BER.

    It could be just me, I did have to add back the "/" to the remote proxy path for it to work since I removed it form the ${applicationpath}

    I get a java.io.FileNotFoundException for http://...beanutils/example/index.cfm//RemoteUserS...

    Not a big deal, as the actually utilities work fine. BTW I had not really looked at the meta data aware advice stuff before, wicked cool...

    I really like the advice for typed struct vo conversion.

  • # Posted By Jon Messer | 7/10/08 1:34 PM

    To follow up...

    I use apache virtual hosts for different dev sites, if I run from localhost:8300 it works without modification, but if I run from an apache vhost it has the problem.

  • # Posted By Brian Kotek | 7/22/08 4:07 PM

    Interesting, it sounds like it is this problem regarding Apache and the default document:

    http://www.horwith.com/index.cfm/2008/7/22/apache-...