The technology used by SPIDER to create templates of code is the Velocity. An Apache Jakarta project (http://jakarta.apache.org/velocity/).
It's documentation is very good. In case that it does not know, these are main links:
- http://jakarta.apache.org/velocity/docs/user-guide.html
- http://jakarta.apache.org/velocity/docs/developer-guide.html
- http://jakarta.apache.org/velocity/docs/vtl-reference-guide.html
Now specifically on this project (SPIDER), the Velocity is used of the following form:
Name of the archive:
- All the archives that are templates of velocity have that to finish with the archive original extension, more the extension standard it velocity (.vm).
Example: web.xml would be web.xml.vm and Usuario.java would be Usuario.java.vm
In case that the archive does not finish with .vm, it will be dealt by SPIDER's engine as an archive that must be copied, without processing velocity.
Example: logo.gif (this archive, if to exist, only must be copied for its destination, without any velocity action).
Comment: if the archive to only finish with .vm (former: tree.vm), without a previous extension, wants to say that this archive is one template of velocity that it does not have to be processed (it could be processed later, when twirling the project that is being generated). If he was tree.xml.vm, it would be processed now (in the hour of the generation of the archives).
Available variable:
7 available variable exist to be used in templates of velocity. They are they:
- configSpider
- databaseTypeConfig
- bundle
- listBuilds
- pathFolderTemplate
- pathFolderGeneration
- crud (only in the generation of CRUDs)
configSpider
This is the main source of information on what it must be generated. This variable is an instance of the class org.j2eespider.ide.data.domain.ConfigSpider. In it are stored all the configurations (layouts, colors, technologies, etc) made for the user in the interface of the SPIDER.
databaseTypeConfig
It has informations about databases (string of connection, to driver, etc). This variable concern to the archive databaseTypeConfig.xml, wich it will be explained in the next topics.
bundle
It makes reference to properties file (i18N) referring the chosen language for the project. Then the code template access a file called template.properties, wich contains keys that they must be internationalized. Example of necessity: the folder of business rules is generated as "negocio" if the project will be in Portuguese, or "rules" will be in English. Then the archives and folders can respect the language used in the project.
listBuilds
Shows the list of builds has been made in this project (CONFIG.LAYOUT, PACKAGE, TECH, CRUD).
pathFolderTemplate
Path for the folder of template in the HD. Case that it is necessary inside of one template to know the complete path of the folder of templates, it is possible through this variable.
pathFolderCommon
Path for the folder common of templates. The folder common keeps files that can be used for diverse templates, as jars and others.
pathFolderGeneration
Path for the folder of the project that will be generated in HD. Used, for example, to create the context file for application deployment, wich must point with respect to the project folder and needs this path.
crud
This variable is an instance of the class org.j2eespider.ide.data.domain.Crud. Here are stored all settings of the user for the CRUD (name of the class, validations, layout, etc.).
Using these variables that have application informations, technologies and internationalization, it is possible to mount any template in the Velocity for the SPIDER.

