Metro 0.9 Now Available

2009 April 28
tags: ColdSpring · Metro · Transfer
by Paul Marcotte

Metro is creeping ever closer to a 1.0 release, which will likely be followed up by something else in short order.  I never really set out a timeline to development, instead, I've let the needs of my current project drive the schedule.  Today marks the 0.9 release which features one improvement (depending on how you look at it) to the TransferAuditObserver. The first cut of the Observer focused on recording create, update and delete events and the class and PK of the object which fired the event.

I needed the ability to invoke a custom method on the observer, so I re-factored the Observer to accept a tad mo' metadata. Here is the new ColdSpring configuration and a sample Observer which extends metro.model.security.TransferAuditObserver. The configuration now allows one to specify a target method by class.

<bean id="AuditMap" class="coldspring.beans.factory.config.MapFactoryBean">
    <property name="sourceMap">
    <map>
    <entry key="create">
       <map>
          <entry key="some.Class">
          <value>doSomething</value>
          </entry>
          </map>
    </entry>
    </map>
    </property>
   </bean>

   <bean id="MyObserver" class="model.package.MyObserver" lazy-init="false">
      <constructor-arg name="transfer">
         <ref bean="transfer" />
      </constructor-arg>
      <constructor-arg name="auditMap">
         <ref bean="auditMap" />
      </constructor-arg>
      <property name="SomeService">
         <ref bean="SomeService" />
      </property>
   </bean>

And here is a sample Observer.

<cfcomponent displayname="MyObserver" output="false" extends="metro.model.security.TransferAuditObserver" hint="I am a Transfer AfterCreate, AfterUpdate and BeforeDelete observer.">

   <cffunction name="doSomething" hint="Performs some important event driven action" returntype="void" output="false" access="private">
      <cfargument name="obj" type="transfer.com.TransferObject" required="true" hint="The event object">
      <cfargument name="action" type="string" required="true" hint="The action that occurred (create|update|delete).">
      
      <cfscript>
       // something gets done.
      </cfscript>
   </cffunction>

</cfcomponent>