Case history: Web application
This is a complex template that we developed internally. This template is used to produce code for a web application based on EJB 3.0 and Hibernate.
User layer was developed using Google GWT technology and some of the generated code regarded also this level.
This template is quite complex because it covers different levels of code generation, from EJB beans to GWT user interface.
For what concerns EJB Java Beans, outr approach was to manually code a generic EJB class with a set of functions that allows us ot cover a wide variety of requirements of our code. This class was then coded as a Sar-K template and applied to all database tables that required it. In this way we produced a common skeleton that allows to store and retrieve information on the DB. As an example, here we show a snippet of the EJB generated code.
@Stateless
public class GeneralConfigurationBean implements GeneralConfigurationService {
@PersistenceContext
private EntityManager entityManager = null;
@PersistenceUnit
private EntityManagerFactory entityManagerFactory = null;
public List findAllGeneralConfiguration() {
...
}
private Long countByFilter(GeneralConfigurationFilter
generalConfigurationFilter) {
...
}
private List findGeneralConfigurationListByFilter(
GeneralConfigurationFilter generalConfigurationFilter) {
...
}
public PagedQueryResult findGeneralConfigurationByFilter(
GeneralConfigurationFilter generalConfigurationFilter) {
...
}
public GeneralConfiguration findGeneralConfigurationById(Long id) {
...
}
}
As you can see this is a generic interface that allows the class to execute simple queries on the database. This is supported by other Sar-K generated classes, like the filter ones (GeneralConfigurationFilter) or the model ones (GeneralConfiguration).
Using the same method, in this project we generated all the required interfaces and modules to implement required servlets and asynchronous GUI calls.
For what concerns the GUI modules, Sar-K was used to produce the most common widgets (i.e. drop down boxes whose value depends on specific databases queries) or standard pages to interact with simple tables (i.e. add/remove/edit tables).
