hmm... ok, I take another example:


I want to generate an Exception for every <<Entity>>, and every <<Service>>. 
All exceptions should have the same structure, the difference is just the Name. 

For getting the name I need some logic. (i.e. putting a suffix 
"PersistenceException" or "ServiceException").



So, now I have more than one way to solve this: 

1. Logic in the template:



#if&#40;$class.isService&#41;

#set&#40;$className = "$&#123;class.name&#125;ServiceException"&#41;

#elseif &#40;$class.isEntity&#41;

#set&#40;$className = "$&#123;class.name&#125;PersistenceException"&#41;

#end



I think, this is not the proper position for this logic. I think its better to 
do that in a MetaFacage. So, we come to solution 2:



2. Doing the name-logic in the MetaFacade

Then I have in each of my EntityFacade and my ServiceFacade a method 
"getExceptionName". I can call this method in every template, where I use the 
EntityFacade repectively the ServiceFacade.

So, I think, thats also not a good way. Thats the reason why I want to use 
version 3:

3. using a special EntityExceptionFacade and a ServiceExceptionFacade

This special facades can handle the functionality to generate the 
Exception-Name. And in the template-deskriptor I want to do this:

cartridge.xml:



<template

&nbsp; &nbsp; path="templates/mytemplates/service.java.vsl"

&nbsp; &nbsp; outputPattern="$generatedFile"

&nbsp; &nbsp; outlet="exceptions"

&nbsp; &nbsp; &nbsp;generateEmptyFiles="false"

&nbsp; &nbsp; overwrite="true">

&nbsp; &nbsp;<modelElements variable="service">

&nbsp; &nbsp;&nbsp; &nbsp;<modelElement stereotype="Service">

&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<type 
name="de.dpcom.metafacades.uml.ServiceFacade"/>

&nbsp; &nbsp;&nbsp; &nbsp;</modelElement>

&nbsp; &nbsp;</modelElements>

</template>



<template

&nbsp; &nbsp; path="templates/mytemplates/entity.java.vsl"

&nbsp; &nbsp; outputPattern="$generatedFile"

&nbsp; &nbsp; outlet="exceptions"

&nbsp; &nbsp; &nbsp;generateEmptyFiles="false"

&nbsp; &nbsp; overwrite="true">

&nbsp; &nbsp;<modelElements variable="entity">

&nbsp; &nbsp;&nbsp; &nbsp;<modelElement stereotype="Entity">

&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<type 
name="de.dpcom.metafacades.uml.EntityFacade"/>

&nbsp; &nbsp;&nbsp; &nbsp;</modelElement>

&nbsp; &nbsp;</modelElements>

</template>



<template

&nbsp; &nbsp; path="templates/mytemplates/exception.java.vsl"

&nbsp; &nbsp; outputPattern="$generatedFile"

&nbsp; &nbsp; outlet="exceptions"

&nbsp; &nbsp; &nbsp;generateEmptyFiles="false"

&nbsp; &nbsp; overwrite="true">

&nbsp; &nbsp;<modelElements variable="exception">

&nbsp; &nbsp;&nbsp; &nbsp;<modelElement stereotype="Entity">

&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<type 
name="de.dpcom.metafacades.uml.EntityExceptionFacade"/>

&nbsp; &nbsp;&nbsp; &nbsp;</modelElement>

&nbsp; &nbsp;&nbsp; &nbsp;<modelElement stereotype="Service">

&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<type 
name="de.dpcom.metafacades.uml.ServiceExceptionFacade"/>

&nbsp; &nbsp;&nbsp; &nbsp;</modelElement>

&nbsp; &nbsp;</modelElements>

</template>





metafacades.xml:



<metafacade class="de.dpcom.metafacades.uml.ServiceFacadeLogicImpl">

&nbsp; <mapping class="org.omg.uml.foundation.core.Classifier$Impl">

&nbsp; &nbsp; <stereotype>Service</stereotype>

&nbsp; </mapping>&nbsp; &nbsp; &nbsp; &nbsp; 

</metafacade>



<metafacade class="de.dpcom.metafacades.uml.EntityFacadeLogicImpl">

&nbsp; <mapping class="org.omg.uml.foundation.core.Classifier$Impl">

&nbsp; &nbsp; <stereotype>Entity</stereotype>

&nbsp; </mapping>&nbsp; &nbsp; &nbsp; &nbsp; 

</metafacade>



<metafacade class="de.dpcom.metafacades.uml.ServiceExceptionFacadeLogicImpl">

&nbsp; <mapping class="org.omg.uml.foundation.core.Classifier$Impl">

&nbsp; &nbsp; <stereotype>Service</stereotype>

&nbsp; </mapping>&nbsp; &nbsp; &nbsp; &nbsp; 

</metafacade>



<metafacade class="de.dpcom.metafacades.uml.EntityExceptionFacadeLogicImpl">

&nbsp; <mapping class="org.omg.uml.foundation.core.Classifier$Impl">

&nbsp; &nbsp; <stereotype>Entity</stereotype>

&nbsp; </mapping>&nbsp; &nbsp; &nbsp; &nbsp; 

</metafacade>





But If I do this, nothing is generated for my Exceptions...



Do you understand now, what I want to do?



MArtin
--
AVIs Samsung-Forum: www.samsung-forum.de
_________________________________________________________
Reply to the post : http://galaxy.andromda.org/forum/viewtopic.php?p=2428#2428
Posting to http://forum.andromda.org/ is preferred over posting to the mailing 
list!


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP, 
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Andromda-user mailing list
Andromda-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/andromda-user

Reply via email to