Book a Demo

Author Topic: Code Template Help  (Read 2634 times)

moacsjr

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Code Template Help
« on: July 21, 2005, 10:13:56 am »
Hi,

I want some help with custom code template. I need to create the comments bellow for classes with the <<EJBImplementation>> stereotype

/**
*
* @ejb.bean
*

name="ManterCategoriaFuncionalBean"
*

descripton="Realizar Manutencao de Categoria Funcional Bean"
*

display-name="ManterCategoriaFuncionalBean"
*

jndi-name="ejb/ManterCategoriaFuncionalEjb"


*  
local-jndi-name="ejb/ManterCategoriaFuncionalEjbLocal"
*

view-type="local"
*

type="Stateless"
*

transaction-type="Container"  
*
   impl-class-name="br.syndeo.dms.service.pessoa.ejb.ManterCategoriaFuncionalBean"
*
* @ejb.env-entry
*

name="ejb/BeanFactoryPath"
*

type="java.lang.String"
*

value="META-INF/applicationContext.xml"
*
* @ejb.home local-extends="javax.ejb.EJBLocalHome"
* @ejb.interface local-extends="javax.ejb.EJBLocalObject, br.syndeo.dms.service.ManterBase"
*
*/

I´m without luck with Templates and can´t make it work.
Could somebody help me, and send a step by step help.

thanks Moa.


Moa.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code Template Help
« Reply #1 on: July 21, 2005, 04:12:25 pm »
1. Add the stereotype "EJBImplementation" to your model.
 a) Open Configuration | UML | Stereotypes.
 b) Enter EJBImplementation in the stereotype.
 c) Select Class as the Base Class.
 d) Click Save.

2. Add a stereotype override for java class notes.
 a) Open Configuration | Code Generation Templates.
 b) Select Java as the language.
 c) Select the Class Notes template.
 d) Add a new stereotype override (click the button and select EJBImplementation as the class stereotype.
 e) Click on the new template in the stereotype override.

3. Write the template.
 a) It's easiest to start with the stuff that appears in all notes.
Code: [Select]
%if genOptGenComments != "T"%
%endTemplate%

/**
*
* @ejb.bean
*
*
*/

 b) Then start considering where you are getting all the extra information from.  (Most likely tagged values)  So, you'll have to add some lines like the following in.
Code: [Select]
 * name=%qt%%className%%qt%
* display-name=%qt%%classTag:"display-name"%%qt%

 c) Finally, if some entries appear only if their value is set.  You can do conditionals, here's a couple of examples.
Code: [Select]
%if classTag:"local-jndi-name" != ""%
* local-jndi-name=%qt%%classTag:"local-jndi-name"%%qt%
%endIf%
%if classTag:"env-name" != ""%
$env = " * name=" + %qt% + %classTag:"env-name"% + %qt% + "\n"
%endIf%
%if classTag:"env-type" != ""%
$env += " * type=" + %qt% + %classTag:"env-type"% + %qt% + "\n"
%endIf%
%if $env != ""%
*
* @ejb.env-entry
*
%TRIM_RIGHT($env)%
%endIf%


Hope that helps.

moacsjr

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Code Template Help
« Reply #2 on: July 22, 2005, 05:00:41 am »
Thank's a lot Simonm for replying me. It realy helpd me to solve this problem.

Thank´s again.

Good Day,

Moa.