Cairngen: Create Sequence Use Existing Delegate
I've created an additional task that can be added to Eric Feminella's super handy Cairngen project. The task is a slight modification of the out-of-the-box "create sequence" tasks. Create Sequence Use Existing Delegate does just what the name implies, and allows you to specify an existing Delegate class to wire your newly generated Command class to. This is the most common repetitive task I use when coding Cairngorm-based Flex applications as any Commands that call the same remote service will utilize the same Delegate class. To use this task you simply need to add CommandUseExistingDelegate.tpl to your templates directory and add the target node below to your existing Cairngen build.xml file.
Note that I've added a couple of input nodes to the beginning which will cause Eclipse to open a dialog box asking you to enter the sequence name and full class name (e.g. MyCoolDelegate) of the Delegate you wish to use. You could easily strip these out and have the task get these values from your properties file if you so desire. Hopefully someone out there finds this useful!
<target name="create-sequence-use-existing-delegate" depends="log">
<input message="Sequence name: " addproperty="seq" />
<input message="Delegate class: " addproperty="del" />
<echo>${log.sequence.exclude.delegate.message}</echo>
<copy file="${cairngorm.templates.dir}/${cairngorm.framework.name}${cairngorm.version}/Event.tpl" tofile="${project-uri}/${events.dir}/${seq}Event.as" overwrite="${overwrite.existing.files}">
<filterchain>
<replacetokens>
<token key="sequence" value="${seq}" />
<token key="namespace" value="${namespace}" />
<token key="events" value="${events.dir}" />
</replacetokens>
</filterchain>
</copy>
<copy file="${cairngorm.templates.dir}/${cairngorm.framework.name}${cairngorm.version}/CommandUseExistingDelegate.tpl" tofile="${project-uri}/${commands.dir}/${seq}Command.as" overwrite="${overwrite.existing.files}">
<filterchain>
<replacetokens>
<token key="sequence" value="${seq}" />
<token key="namespace" value="${namespace}" />
<token key="events" value="${events.dir}" />
<token key="commands" value="${commands.dir}" />
<token key="business" value="${business.dir}" />
<token key="delegate" value="${del}" />
</replacetokens>
</filterchain>
</copy>
</target>
Both comments and pings are currently closed.
