
|
If you were logged in you would be able to see more operations.
|
|
EJB Cartridge
Created: 16/Apr/08 05:19 PM
Updated: 17/Apr/08 11:26 AM
|
|
| Component/s: |
None
|
| Affects Version/s: |
None
|
| Fix Version/s: |
None
|
|
|
Environment:
|
AndroMDA 3.3-SNAPSHOT + EJB3 cartridge
|
|
Working on the patch to separate DAO and Transformer (http://galaxy.andromda.org/jira/browse/EJB-105), I asked myself a question about the way we decide if DAO implementation class has to be generated in core/src/main/java or core/target/src. I have many DAO implementation classes generated in core/src/main/java, but with no method to complete !
This choice is based upon daoImplementationRequired property of entity. In the metafacade class, I saw this property is true in one of the the three following cases :
1 - Entity has value objects references
2 - Entity has business operations, i.e. static methods
3 - Entity has query operations (methods checked as a query or having <<FinderMethod>> stereotype).
I agree with the first two cases, but I don't understand the third one. For what I understood, if a method is checked as a query or has the <<FinderMethod>> stereotype, the query itself will be totally generated in DAOBase class, so no need for the developer to implement it in a DAOImpl class. So the first two methods should be enough to decide whether the developer will have to write the DAO implementation.
After applying the patch about Transformer / DAO separations, it means there's only one case when you need to generate DAO implementation class : when the entity has business operations.
See also this topic : http://galaxy.andromda.org/forum/viewtopic.php?t=5664
|
|
I made changes to the cartridge to implement this. It's hard to make a patch since these changes concern some templates that are already concerned by the patch to separate daos and transformers, so such a patch would work only if you have applied patch for dao / transformers before.
Anyway, you don't need a lot of changes to make it work.
In EJB3EntityFacadeLogicImpl class, you have to change implementation for handleIsDaoImplementationRequired method :
/**
* @see org.andromda.cartridges.ejb3.metafacades.EJB3EntityFacadeLogic#handleIsDaoImplementationRequired()
*/
protected boolean handleIsDaoImplementationRequired()
{
return !this.getDaoBusinessOperations().isEmpty();
}
In cartridge.xml.vsl template you have to remove these lines :
<template
path="templates/ejb3/DaoImpl.vsl"
outputPattern="$generatedFile"
outlet="daos"
overwrite="true">
<modelElements variable="entity">
<modelElement>
<type name="org.andromda.cartridges.ejb3.metafacades.EJB3EntityFacade">
<property name="daoImplementationRequired">false</property>
<property name="embeddableSuperclass">false</property>
</type>
</modelElement>
</modelElements>
</template>
In ejb-jar.xml.vsl template, you have to change the way dao session beans are defined :
<session>
<description>
<![CDATA[
$entity.getDocumentation("", 64, false)
]]>
</description>
<ejb-name>${entity.daoName}</ejb-name>
<local>${entity.fullyQualifiedDaoName}</local>
<ejb-class>#if ($entity.daoImplementationRequired)${entity.fullyQualifiedDaoImplementationName}#else${entity.fullyQualifiedDaoBaseName}#end</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
And finally in DaoBase.vsl template you have to change the class definition line so that the class is abstract only if there is a Dao implementation :
public#if ($entity.daoImplementationRequired) abstract#end class $entity.daoBaseName
|
|