Spring Code Generation
From Skyway Wiki
Contents |
Project
When you create a Skyway Project, the following gets generated automatically:
- persistence.xml (JPA configuration)
- web.xml
- jta.properties
- log4j.properties
- hibernate.properties
- projectName-generated-dao-context.xml - Spring context file for generated DAO layer components
- projectName-generated-domain-context.xml - Spring context file for generated domain layer components
- projectName-generated-service-context.xml - Spring context file for generated service layer components
- projectName-generated-web-context.xml - Spring context file for generated web layer components
- projectName-dao-context.xml - Spring context file for custom (non-generated) DAO layer components
- projectName-domain-context.xml - Spring context file for custom (non-generated) domain layer components
- projectName-service-context.xml - Spring context file for custom (non-generated) service layer components
- projectName-web-context.xml - Spring context file for custom (non-generated) web layer components
- projectName-dao.properties - properties for each database used by project (derived from configured Eclipse data connection)
- projectName.java - Interface for Project (project variables and constants)
- projectNameImpl.java - Implementation class for Project (project variables and constants)
If you created a Maven-based project with Skyway Builder, the following also gets generated:
- child pom.xml
- parent pom.xml
Service
When you create a Service, the following gets generated automatically:
- serviceName.java - interface
- serviceNameImpl.java - implementation class (@Service annotated)
- serviceNameTest.java - junit test
Addition code generation based on Service configuration:
- Variables - generated as variable declarations in service
Operation (Service)
When you create an Operation in a Service, the following gets generated automatically:
- each operation is generated into a method in Service interface and implementation classes
- Input variables - are generated as method parameters
- Output variables - are method outputs
- if single output variable defined, the operation signature reflects that output variable type and the variable is returned from method
- if multiple output variables defined, a response object is automatically generated, reflected in operation signature, and populated in operation method
- operationNameResponse.java - response object
- operationNameResponseBeanInfo.java - bean info for response object
Action
application logic in operation (combination of code generated from Skyway steps and/or hand written code)
Controller
When you create a Controller, the following gets generated automatically:
- controllerName.java - implementation class (@Controller annotated)
- controllerNameTest.java - junit test
Addition code generation based on Service configuration:
- Variables - generated as variable declarations in service
- URL mappings - reflected in web.xml and operation @RequestMapping
Operation (Controller)
When you create an Operation in a Controller, the following gets generated automatically:
- each operation is generated into a method in the controller interface and implementation classes
- each generated method is annotated with @RequestMapping
- Variables - generated as variable declarations in method
- Input variables are method parameters
- primitive types are annotated with @RequestParm
- complex types are annotated with @ModelAttribute
- Output variables are method outputs
- if zero output variables defined, the view (JSP) is returned
- if one or more output variables defined, a model and view object is created, variables are added, and JSP is specified as the view
- if bindingresult (Spring Validation) is specified as input parameter, code will be generated to call validation class specified in URL mapping
Exception
When you create an Exception in a Service, the following gets generated automatically:
- exceptionName.java - a custom exception that extends java.lang.Exception
Model
When you create a Model, the following gets generated automatically:
- modelName.java - interface
- modelNameImpl.java - implementation class; @Component annotated; named and available as a Spring resource
- each variable and constant is added to class, getters/setters generated
Data Type
- datatypeName.java - POJO encompassing attributes defined in data type
- datatypeNamePK.java - primary key classed used for JPA.
- getters/setters generated
If data type can be persisted (by associating it with a DAO), the following annotations are added to class
- @IdClass - JPA annotation w/ reference to primary key class
- @Entity - JPA annotation ; identifies classes as persistent and eligible for JPA services
- @NamedQueries - set of @NamedQuery
- @NamedQuery - pre-define query including name
- @Table - the table to be used for the entity represented from the data type
For each attribute the following annotations are used based on the configuration of the data type
- @Column
- @Basic
- @Id
- @Temporal
- @Lob
For each relationship defined between data types, the following annotations may used:
- @OneToMany
- @ManyToOne
Data Store
- datastoreName.java - interface
- datastoreNameImpl.java - JPA implementation class (if using JPA queries)
- datastoreNameJDBCImpl.java - JDBC implementation class (if using JDBC queries)
- datastoreNameTest.java - junit test
Named Queries
- each pre-defined query is generated into data types and data store classes
- the class will be determined by the query type (JPA or JDBC)

