Hello all, over the course of developing my new EJB cartridge, I have in several places found that I need to have finer control over what files are generated. For example, take local or remote interfaces for Session EJBs: Ideally, the decision to generate a local or remote interface or not is based on the viewtype of the corresponding <<Service>>. In general, it is desirable to switch file genreration on or off based on model information. Or the creation of value objects (next feature on my list - I need them in my current project :-) should be switched on or off based on user poperties specified in the ant task.
As you are probably all aware, this is not possible with the current system. Also, I do not think that it is really feasible to extend the current andromda-cartridge.xml semantics to allow for this decision, because you'd end up with a complete expression language in there to handle all possibilities. Instead, I propose to base the decision of whether to generate a file or not on whether the template in question actually produces any output. This is very easy to implement: Buffer the output in AndroMDAGenTask .processModelElementWithoneTemplate() instead of writing directly to a file, and only write the file if the buffered output is not empty - not more than a handful of lines of code. It is equally easy to use from the template (simply encapsulate your "conditional" templates in one big #if (condition)...#end), and it gives maximum flexibility to the template developer because all information available in the template's context can be used for the condition. The only drawback I can think of is that it would be impossible to create empty files with this system. But then, I can't think of a situation where someone actually wants to do this, and we can easily make this behaviour configurable on a per-template basis. So, what do you think? Richard -- Richard Kunze [ t]ivano Software, Bahnhofstr. 18, 63263 Neu-Isenburg Tel.: +49 6102 80 99 07 - 0, Fax.: +49 6102 80 99 07 - 1 http://www.tivano.de, [EMAIL PROTECTED]
pgp00000.pgp
Description: signature
