FAST CODE ECLIPSE PLUG-IN


J2EE BASE TEMPLATES

Using this template one can setup a standard J2EE base environment.  This template creates the basic folder structure and all the required components like APIs, JSPs, classes like service, dao, impl, and controller classes which provides basic functionality for developing multi-tiered, web-based applications.  This template is for a spring based application. One can also update the template to develop other applications. Brief explanation of this template can be found below.

One can invoke the menu in any type of file as the allowed variation in templates-config.xml is set as “*”.  To use this menu, just type Ctrl+Alt+Shift T and select the snippet type as "J2EE_BASE” as shown.

j2eebaseTemplates

To develop web applications, one has to design a standard folder structure for each modules.  One can pass the module name as a variable which is injected into the template using additional parameters as shown:  For example, a Product module can be created for a web application. The folders and files will get created in the Sample project which is selected in the snippet dialog. By default the files get created in default path "src/main/java" which is set in FastCode Preference page.

j2eebaseTemplates1

The below selection dialog shows the list of elements which are created for a product module.  The module is a placeholder which holds the value “product” which is passed as a parameter to create all the packages, folders, classes and files which helps to maintain a standard naming structure for a web application.  The classes for interface, service, dao, impl are created and a folder to store webapp files like jsp, js files are also created.

The Action Selection Dialog shown below has all the elements checked to be created except Test Class which is unchecked. This is done in <fc:class> tag using an optional attribute where user has the option to select the element at runtime.

j2eebaseTemplates6

A complete J2EE structure is created as shown:

Before J2EE template executed                           After J2EE template executed

j2eebaseTemplates4       j2eebaseTemplates4

Using this template, one can develop a spring based web application within short time period which reduces lot of coding time.

This template can further be updated/enhanced as required.

	

Brief description for the above template:

Line 7: <fc:class> is used to create the Controller class.

Line 8: One can add ${class_header} for each <fc:class> tag.

Line 22: ${module}Service is automatically injected into the controller class.

Line 23: A Static Logger variable is defined for logging the output for controller class.

Line 38: <fc:class> creates the ${module}Service class.

Line 44: <fc:class> creates the ${module}ServiceTest class in src/test/java folder. Here Fc:class tag uses type attribute type="test" to create Test classes in test folder. By default the files get created in default test path "src/test/java" which is set in Fastcode Preference Page as shown.

In fc:class tag attribute optional is set to "true", for the test class. User can decide, in the runtime, if they want the test class to be created or not. If they want it to be created, they can select it in the action selection dialog, else they can ignore it.

fastcodesrcpath

Line 63: <fc:class> creates the ${module}ServiceImpl class which implements the service class.

Line 74: <fc:class> creates the ${module}Dao class which abstracts the data access for the {module}.

Line 80: <fc:class> creates the ${module}DaoImpl class which abstracts the data access implementation for the ${module}Dao class.

Line 97: <fc:file> is used to create the ${module}.js file in the specified location.

Line 106: <fc:file> is used to create the ${module}.jsp file in the specified location.

To get started, please install the FastCode Plugin.