MyEclipse for Spring Reference – Spring DSL
1. Project Editor
The Spring DSL is only applicable to projects that have been enabled with Spring code generation capabilities using the Enable Spring DSL wizard.
The Project Editor is accessed by double-clicking the Spring DSL node in the project, and it’s comprised of the Overview tab, the Web Application tab, the Code Generation tab, the Enterprise Configuration tab, the Spring Configuration tab, and the Category Mapping tab. The follow sections describe each tab in detail.
Note: Spring scaffolding requires a MyEclipse Spring or Bling subscription.
1.1 Overview Tab
The Overview tab allows a user to describe the project and link to other tabs in the Project Editor.
Details | Description | ||
---|---|---|---|
Name | Identifies the name of the project. | ||
Description | Provide a meaningful description of the project. |
1.2 Web Application Tab
The Web Application tab is used to specify the default suffix used for operation URLs (for controllers) created using the New Operation Wizard.
Details | Description | ||
---|---|---|---|
Default URL Mapping Suffix | The suffix to be appended to the end of new URL mappings. |
1.3 Code Generation Tab
The Code Generation tab is for configuring various project-level code generation options, including the collection type that should be use for persistent relationships and the default code generation options for the generated code.
The Code Generation section configures the default code generation settings for the entire project. From the Project Editor, there is an entry for every artifact generated using MyEclipse. The settings can be overridden individually on an artifact by using the artifact’s code generation tab, which contains only entries for the artifact’s generated resources.
Options | Description | ||
---|---|---|---|
Persistent Collection Type | Select the type of collection to use for persistent relationships.
| ||
Generate | Specifies whether this resource should be generated. By default all resources are generated and regenerated, but you can disable this at the project level by deselecting the checkbox for the resources that should no longer be generated. | ||
Name | A friendly name for the resource represented by the configuration entry. | ||
Filename | The name of the file to be generated for the resource. You can reference the artifact name by using the ${model.name} expression in the filename. | ||
Package | The package name to be used for the generated resource. This setting applies only to resources that get generated into Java classes. You can reference the model package the artifact was created in by using the ${model.package} expression in the package name. | ||
Path | The directory to which the resource should be generated. You can reference the category mapping (from the Category Mapping tab) location in the path by using the ${category} expression. You can also reference the model package the artifact was created in by using the ${model.package} expression in the path. To generate the resource to multiple locations, you can specify multiple paths (comma delimited). | ||
Category | Associates the artifact with an application layer. This is primarily related to the category mappings where you can change the project into which the resource is generated. |
Here is a list of available code generation tokens that can be used for configuring code generation options.
Token | Description | ||
---|---|---|---|
${model.name} | References the name given to the artifact in the Spring DSL. | ||
${parent.name] | References the name of the parent artifact for artifacts that have a parent artifact (i.e. Controller/Operation and Service/Operation) | ||
${model.package} | References the model package that contains the artifact in the Spring DSL. | ||
${category} | References the project path configured for the category (using Category Mapping tab). |
1.4 Enterprise Configuration Tab
The Enterprise Configuration tab of the Project Editor allows a user to configure the Spring Security settings for the project.
Details | Description | ||
---|---|---|---|
Secured URLS | This subsection allows a user to specify URLs and set them as secured. | ||
URL Pattern | Lists the URL patterns added. | ||
Secured | Select this checkbox to secure the associated URL. | ||
Add | Click this button to Add a new URL pattern. | ||
Remove | Click this button to remove a selected URL from the URL Pattern list. | ||
Up/Down | Click these buttons to change the order of the selected URL from the URL Pattern list. | ||
Secured Resources | This subsection allows a user to specify resources and set them as secured. | ||
Service | Displays the project’s services available to secure. | ||
Secured | Select this checkbox to secure the associated Service. | ||
Data Access Object | Displays the project’s data access objects available to secure. | ||
Secured | Select this checkbox to secure the associated Data Access Object. | ||
Configured Views | This subsection allows a user to select the views that handle security functions. | ||
Login View | Default page: /login.jsp | ||
Login Failure View | Default page: t/login.jsp?login_error=1 | ||
Login Success View | Default page: /success.jsp | ||
Access Denied View | Default page: /accessDenied.jsp | ||
Security Information Source | This subsection allows a user to configure the security information source as either Database or LDAP. | ||
Database | Select this radio button to configure database settings. | ||
LDAP | Select this radio button to configure LDAP settings. |
1.5 Spring Configuration Tab
The Spring Configuration tab allows a user to configure the mail server.
Details | Description | ||
---|---|---|---|
Mail Server | Enter the mail server. By default this is not set. When the mail server is specified, a mail sender bean is emitted into service context file. |
1.6 Category Mapping Tab
Use the Category Mapping tab to reconfigure the target projects for each artifact category. Each Spring DSL artifact is associated with an artifact category, and the artifact category can be individually configured to generate to a particular Eclipse project.
The Category Mapping tab is also used to disable automated updates to project dependencies. For a Maven-based project, this option prevents MyEclipse from automatically updating the Maven pom file (pom.xml). For an Eclipse-based project, this option prevents MyEclipse from automatically updating your classpath (build path). If disabled, you are responsible from manually maintaining the project classpath.
Details | Description | ||
---|---|---|---|
Artifact Categories | Used to configure the destination project for each available application layer. | ||
Category | The application layer name. This column is read-only. | ||
Project | The specific Eclipse project to which the application layer should be generated. This setting is originally set by the Enable Spring DSL wizard when specifying the target project for web, service,domain and DAO layers. It can be reconfigured here or by re-running the wizard. | ||
Id | The id used to reference the category from the Code Generation tab. | ||
Edit | Select an artifact category, and click this button to invoke the Project picker. |
2. Service
The Spring DSL Service is for generating Spring @Service components and managing related source code and configuration files.
The Spring framework supports the @Service annotation, which is a specialized stereotype for service layer components, and the Spring DSL Service artifact manages the creation of Spring services by:
- providing a New Service wizard.
- providing a Service Editor for editing Spring Services managed by the Spring DSL
- generating a Spring Service interface
- generating Spring Service implementation classes(annotated with @Service)
- generating JUnit test classes for service testing
- [optional] enablement of the service for Java API for XML Web Services (JAX-WS – SOAP)
- [optional] enablement of the service for Direct Web Remoting (Javascript/JSON)
While Services are often used in a Spring MVC application, Services are also applicable to just about any other presentation technology related to Spring. If you are using a presentation technology other than Spring MVC (i.e., Spring Web Flow, JSF, Struts, GWT, AJAX, or Adobe Flex), they can all use Services for implementing the back-end business logic.
Tip: For a Service implementation example, try scaffolding a Spring MVC application using the Scaffold Spring MVC Application wizard. It generates a full Spring MVC application, including Spring Services.
2.1 New Service Wizard
The New Service wizard is for creating new Spring Services for a development project.
The New Service window is for specifying the name of the service and the model package that will contain the service.
Details | Description | ||
---|---|---|---|
Service Name | Name of the new Service |
2.2 Service Editor
The Service Editor is used for configuring a Spring DSL Service, and it’s comprised of the Overview tab, the Variables tab, the Code Generation tab, the Flex tab, the DWR tab, the JAXWS tab, and the Spring Bean Configuration tab. The follow sections describe each tab in detail.
2.2.1 Overview Tab
The Overview tab is for providing a description of the Service, navigating to the files generated from the Service, and navigating to the other Service configuration tabs.
Details | Description | ||
---|---|---|---|
Name | Name of the new Service | ||
Files | Click the Views link to display the generated source code. | ||
Description | Provide a meaningful description of the Service. |
2.2.2 Variables Tab
The Variables tab is for defining Service variables. Service variables are available to all service operations.
Details | Description | ||
---|---|---|---|
Name | Identify the variable name. | ||
Type | Select the data type of the variable. Click the desired row in the Type column to invoke the Select Type Picker. Select the desired data type, and click OK. | ||
Collection | Identify whether the parameter is a Collection. | ||
Initial Value | (Optional) a variable can be initialized with data by populating this column with the initial value. |
2.2.3 Code Generation Tab
The Code Generation tab is for configuring the generation options for a Service. This tab shows you all code artifacts generated and managed by the Spring DSL Service. Each entry in this table represents a code artifact generated for the Service. In addition to enabling and disabling code generation on an artifact-by-artifact basis, you can also customize the name of the artifact, the package used, and the location to where the artifact is generated.
The code generation settings can be specified at the project level, which controls the code generation settings for the entire project. The code generation settings can also be customized for each Service using the code generation tab from the respective Service.
For a description of the code generation settings available from the Service Editor, please refer the to Code Generation tab of the Project Editor.
2.2.4. Flex Tab
The Flex tab is used for configuring the Adobe Flex options for the Service. By default a Service isn’t Flex enabled. This tab is for enabling the Service to be published as a Flex remote service using Spring-Flex.
Details | Description | ||
---|---|---|---|
Publish | Determines if the service will be published as a Flex remote service | ||
Destination Id | Channel name for the remote Flex service |
Unless otherwise excluded, each operation in a Spring DSL Service is published as a Flex remote function. The following table describes the Flex configuration options for the operations.
Details | Description | ||
---|---|---|---|
Exclude | Determines if the current operation will be excluded from Flex; by default all operations are included in a service that is published for Flex. | ||
Method Name | Name of the dynamically generated Flex remote method; the name is defaulted to the name of the Spring DSL operation artifact |
2.2.5 JAXWS Web Service Tab
The JAXWS Web Service tab is for configuring the web service options for the Service. By default a Service isn’t web service enabled. This tab is for enabling the Service to be published as a Web Service and for configuring the JAX-WS options for the Service and Operations.
When a Spring DSL Service is published as a web service, an endpoint interface is generated and annotated with the JAX-WS @WebService annotation. The following table describes the configuration options for the web service.
Details | Description | ||
---|---|---|---|
Publish Web Service | determines whether the Spring service will be published as a JAX-WS web service (@WebService) | ||
Service Name | maps to the serviceName parameter of the @WebService annotation | ||
Target Namespace | maps to the targetNamespace parameter of the @WebService annotation | ||
Endpoint Interface |
| ||
Port Name | maps to the portName and name parameters of the @WebService annotation | ||
WSDL Location | the location of the WSDL representing the web service | ||
Binding Type | maps to the binding type parameter of the @WebService annotation | ||
Service Mode | maps to the service mode parameter of the @WebService annotation |
The handler chain and SOAP binding can be configured at the web service level. The @HandlerChain and @SOAPBinding annotations are generated into the endpoint interface.
Details | Description | ||
---|---|---|---|
Handler Chain | determines whether this service will have a custom handler chain (@HandlerChain) | ||
Name | the name of the handler chain; maps to the name parameter of the @HandlerChain annotation | ||
File | the name of the handler chain configuration file; maps to the file parameter of the @HandlerChain annotation | ||
SOAP Binding | |||
Style | maps to the style parameter of the @SOAPBinding annotation | ||
Parameter Style | maps to the parameterStyle parameter of the @SOAPBinding annotation | ||
Use | maps to the use parameter of the @SOAPBinding annotation |
Unless otherwise excluded, each operation in a Spring DSL Service is published as a web method. The operation in the endpoint interface is generated and annotated with the JAX-WS @WebMethod annotation. The following table describes the configuration options for the web method.
Details | Description | ||
---|---|---|---|
Exclude | determines whether the current operation will be excluded from the web service; by default all operations are included in a web service | ||
Name | maps to the operationName parameter of the @WebMethod annotation; the name is defaulted to the name of the Spring DSL operation artifact | ||
Action | maps to the action parameter of the @WebMethod annotation |
While the SOAP binding can be configured at the web service level, JAX-WS allows the SOAP binding to be customized at the web method level. The custom configurations in the following table are reflected in the @SOAPBinding annotation generated for the web method. The request (@RequestWrapper) and response (@ResponseWrapper) of the web method can be also configured.
Details | Description | ||
---|---|---|---|
SOAP Binding | |||
Style | maps to the style parameter of the @SOAPBinding annotation | ||
Parameter Style | maps to the parameterStyle parameter of the @SOAPBinding annotation | ||
Use | maps to the use parameter of the @SOAPBinding annotation | ||
Request Wrapper | |||
Local Name | maps to the localName parameter of the @RequestWrapper annotation | ||
Target Namespace | maps to the targetNamespace parameter of the @RequestWrapper annotation | ||
Class Name | maps to the className parameter of the @RequestWrapper annotation | ||
Response Wrapper | |||
Local Name | maps to the localName parameter of the @RespondWrapper annotation | ||
Target Namespace | maps to the targetNamespace parameter of the @ResponseWrapper annotation | ||
Class Name | maps to the className parameter of the @ResponseWrapper annotation |
In JAX-WS the input parameters of a web method are configured using the @WebParam annotation. The following table lists the configuration options that will be generated for the @WebParam annotation.
Details | Description | ||
---|---|---|---|
Input | maps to the style parameter of the @WebParam annotation | ||
Name | maps to the name parameter of the @WebParam annotation | ||
Part Name | maps to the partName parameter of the @WebParam annotation | ||
Target Namespace | maps to the targetNamespace parameter of the @WebParam annotation | ||
Mode | maps to the mode parameter of the @WebParam annotation | ||
Header | maps to the header parameter of the @WebParam annotation |
Note: The development accelerators related to JAX-WS are implemented using CXF; however other JAX-WS implementations can be used with Spring.
2.2.6 DWR Tab
The DWR tab is for configuring the DWR (direct web remoting) options for the Service. By default a Service isn’t DWR enabled. This tab is for enabling the Service to be published as a Javascript library (that uses JSON for data transferring) using DWR.
Details | Description | ||
---|---|---|---|
Publish | Determines if the service will be published as a DWR service | ||
Javascript Name | Name of the dynamically generated JavaScript for the service |
Unless otherwise excluded, each operation in a Spring DSL Service is published as a JavaScript function. The following table describes the DWR configuration options for the operations.
Details | Description | ||
---|---|---|---|
Exclude | Determines if the current operation will be excluded from DWR; by default all operations are included in a service that is published for DWR. | ||
Method Name | Name of the dynamically generated JavaScript method; the name is defaulted to the name of the Spring DSL operation artifact |
DWR automatically generates some pages that can assist in developing with DWR. The DWR Service index page lists the classes known to DWR. It’s useful for verifying which Spring DSL services are or are not DWR enabled. The URL for the accessing the index page is http://server:port//context/dwr/index.html.
Note: There is a DWR runtime issue caused by a library version mismatch for a dependent Java library. Please see the MyEclipse for Spring Forums for a very easy solution.
2.2.7 Spring Bean Configuration Tab
The Spring Bean Configuration tab is for configuring the @scope and @Transactional annotations for the Service.
Details | Description | ||
---|---|---|---|
Enable Transaction | Specified whether the Spring transactional annotation should be emitted in this artifact’s generated code | ||
Read Only | Specifies a read-only transaction. | ||
Timeout | Specifies how long a transaction may run before timing out. | ||
Isolation | Specifies the degree of isolation this transaction has from the work of other transactions. | ||
Propagation | Specifies the transaction propagation. | ||
Rollback ClassNames | Specifies the exceptions that must cause a rollback. | ||
No Rollback ClassNames | Specifies the exceptions that must not cause a rollback. | ||
Scope | The scope for this bean. List of Available Scopes |
3. Controller
The Spring DSL Controller is used for generating annotation-based controllers for Spring MVC and managing related source code and configuration files.
The Spring DSL Controller supports the creation of Spring controllers by:
- providing a New Controller wizard.
- providing a Controller Editor for editing Spring Controllers managed bythe Spring DSL.
- generating Spring Controller implementation classes (annotated with @Controller).
- generating JUnit test classes for controller testing.
- managing the association of URLs to request handlers.
Tip:
3.1 New Web Controller Wizard
The New Web Controller wizard is for adding a controller to the application.
New Web Controller >> New Web Controller
3.1.1 New Web Controller
The New Web Controller window is for specifying the name of the web controller and the model package that will contain the web controller.
Details | Description | ||
---|---|---|---|
File Name | Name of controller file |
3.2 Web Controller Editor
The Web Controller Editor is comprised of the Overview tab, the Spring MVC tab, the Variables tab, the Code Generation tab, and the Spring Configuration tab. The following sections describe each tab in detail.
3.2.1 Overview Tab
The Overview tab is for providing a description of the Controller, navigating to the files generated from the Controller, and navigating to the other Controller configuration tabs.
Details | Description | ||
---|---|---|---|
Name | Identifies the Web Controller name. | ||
Files | Click the Views link to display the generated source code. | ||
Description | Provide a meaningful description of the Web Controller. | ||
Define URL Mappings | Click this link to jump to the URL Mapping tab. |
3.2.2 Spring MVC Tab
When Operations are added to a Controller, they are generated as Java methods in the controller. The Spring MVC framework provides a variety of annotations for specifying the behavior of the Java methods and managing data binding, and the Spring MVC tab assists in annotating the Java methods and configuring the annotations.
Here’s a summary of the Spring MVC annotations:
- @RequestMapping
- @RequestParam
- @ModelAttribute
- @InitBinder
An example might be helpful for understanding how the Spring MVC annotations are used with annotation-based controllers.
@Scope("singleton") @Controller("CustomerController") public class CustomerController { @RequestMapping(method = { RequestMethod.GET, RequestMethod.POST }, value = "/saveCustomer.html") public String saveCustomer(@ModelAttribute(value = "customer") Customer customer) { // } @RequestMapping(method = { RequestMethod.GET, RequestMethod.POST }, value = "/selectCustomer.html") public ModelAndView selectCustomer(@RequestParam(required = true, value = "customernumberKey") Integer customernumberKey { // } @InitBinder public void initBinder(WebDataBinder binder, HttpServletRequest request) { // Register static property editors. binder.registerCustomEditor(java.util.Calendar.class, new org.execution.databinding.CustomCalendarEditor()); } @ModelAttribute(value = "cities") public Set<Cities> getCities() { // } }
The `@RequestMapping` annotation specifies that the `saveCustomer()` method should handle URL requests for /saveCustomer.html. | |
The `@ModelAttribute` annotation specifies that customer form data (command object) should be bound to the customer method parameter. The `saveCustomer()` method will have access to the form data by using the command method parameter. | |
The `@RequestParam` annotation specifies that the request parameter `customernumberKey` should be converted to an Integer and bound to the `customernumberKey` variable. | |
The `@InitBinder` annotation specifies the method used by the Spring MVC framework to register any custom data binding converters for the controller. | |
The `@ModelAttribute` annotation specifies that the `getCities()` method should be run prior to any request handler in the controller. Any class variables set by this method are available to the request handlers. The method output will be also available as model data in any views (JSP) under the specified key (“cities”). |
The Spring MVC tab helps configure the Spring MVC annotations for the methods and method parameters in a controller. When clicking the controller, the controller properties are displayed for editing. When expanding the controller and clicking an operation, the operation properties are displayed for editing.
Parameter | Description | |
---|---|---|
Controller / Methods | This table shows the controller and its associated methods. Clicking the controller displays the annotation configuration panel for the controller. Clicking a controller method displays the annotation configuration panel for the controller method. | |
Request Mapping | Configures the controller to handle requests for the given URL. Furthermore, you can configure the request mapping for GET, POST, OPTIONS, PUT and DELETE. | |
Operation Request Mappings | [READ ONLY] This table shows the operations configured as request mappings. It shows the operation name and configured URL. The Launch link enables the immediate launch of the specified URL in the default Eclipse browser. |
The table below describes the Operation settings.
Parameter | Description | |
---|---|---|
Operation Details | Enables the configuration of the operation as either a request handler (@RequestMapping), model attribute (@ModelAttribute) or init binder (@InitBinder). A given operation can be only a request handler, model attribute or init binder method. | |
Request Mapping | Configures the operation to handle requests for the given URL. Furthermore, you can configure the request mapping for GET, POST, OPTIONS, PUT and DELETE. The request mapping table shows all operation parameters and enables the configuration of each parameter. The Mapped As column is for configuring whether the parameter is a Model Attribute, Request Parameter, or Unmapped. The Mapped Name can be configured. The Required column is for specifying whether the parameter is required. For new operations, the mapped name is defaulted to the parameter name, and the Mapped As is determined by the parameter type. All parameters are considered to be required. | |
Model Attribute | Configures the operation to be a @ModelAttribute using the given name. | |
InitBinder | Configures the operation to be an @InitBinder. Optionally you can specify a list of form parameters that should use the specific init binder. |
3.2.3 Variables Tab
The Variables tab is for defining Controller variables. Controller variables are available to all controller operations.
Details | Description | ||
---|---|---|---|
Name | Identify the variable name. | ||
Type | Select the data type of the variable. Click the desired row in the Type column to invoke the Select Type Picker. Select the desired data type, and click OK. | ||
Collection | Identify whether the variable is a Collection. | ||
Initial Value | (Optional) a variable can be initialized with data by populating this column with the initial value. | ||
On Request | Identify whether the variable should be annotated with the Spring @ModelAttribute.
|
3.2.4 Code Generation Tab
The Code Generation tab is for configuring the generation options for a Controller. This tab shows you all code artifacts generated and managed by the Spring DSL Controller. Each entry in this table represents a code artifact that is generated for the Controller. In addition to enabling and disabling code generation on an artifact-by-artifact basis, you can also customize the name of the artifact, the package used, and the location to which the artifact is generated.
The code generation settings can be specified at the project level, which controls the code generation settings for the entire project. The code generation settings can also be customized for each artifact using the Code Generation tab from the respective editor for the artifact.
For a description of the code generation settings available from the Service Editor, please refer the to Code Generation tab of the Project Editor.
3.2.5 Spring Bean Configuration Tab
The Spring Bean Configuration tab is for configuring the @Scope and @Transactional annotations for the Controller.
Details | Description | ||
---|---|---|---|
Enable Transaction | Specified whether the Spring transactional annotation should be emitted in this artifact’s generated code | ||
Read Only | Specifies a read-only transaction. | ||
Timeout | Specifies how long a transaction may run before timing out. | ||
Isolation | Specifies the degree of isolation this transaction has from the work of other transactions. | ||
Propagation | Specifies the transaction propagation. | ||
Rollback ClassNames | Specifies the exceptions that must cause a rollback. | ||
No Rollback ClassNames | Specifies the exceptions that must not cause a rollback. | ||
Scope | The scope for this bean. List of Available Scopes |
4. Component
The Spring DSL Component is for generating Spring @Components and managing related source code and configuration files.
The Spring DSL Component supports the creation of Spring @Components by:
- providing a New Component wizard.
- providing a Component Editor for editing Spring Controllers managed bythe Spring DSL.
- generating Spring Component implementation classes(annotated with @Component).
- generating JUnit test classes for component testing.
4.1 New Component Wizard
The New Component wizard is for adding a component to a project.
New Component >> New Component
4.1.1 New Component
The New Component window is for specifying the name of the component and the model package that will contain the component.
Details | Description | ||
---|---|---|---|
Component Name | Name for the component |
4.2 Component Editor
The Component Editor is comprised of the Overview tab, the Variables tab, the Code Generation tab, and the Spring Bean Configuration tab. The following sections describe each tab in detail.
4.2.1 Overview Tab
The Overview tab is used for providing a description of the Component, navigating to the files generated from the Component, and navigating to other Component configuration tabs.
Details | Description | ||
---|---|---|---|
Name | Identifies the name of the Component. | ||
Files | Click the Views link to display the generated source code. | ||
Description | Provide a meaningful description of the Component. | ||
Define Variables | Click this link to jump to the Variables tab. | ||
Define Constants | Click this link to jump to the Constants tab. | ||
Scope | Define the scope of the model. Valid options are Session or Request. |
4.2.2 Variables Tab
The Variables tab is for defining Component variables. Component variables are available to all component operations.
Details | Description | ||
---|---|---|---|
Name | Identify the variable name. | ||
Type | Select the data type of the variable. Click the desired row in the Type column to invoke the Select Type picker. Select the desired data type, and click OK. | ||
Initial Value | (Optional) a variable can be initialized with data by populating this column with the initial value. |
4.2.3 Code Generation Tab
The Code Generation tab is for configuring the generation options for a Component. This tab shows all code artifacts generated and managed by the Spring DSL Component. Each entry in this table represents a code artifact that is generated for the Component. In addition to enabling and disabling code generation on an artifact-by-artifact basis, you can also customize the name of the artifact, the package used, and the location to which the artifact is generated.
You can configure code generation settings at the project level to control the code generation settings for the entire project. The code generation settings can also be customized for each artifact using the Code Generation tab from the respective editor for the artifact.
For a description of the code generation settings available from the Service Editor, please refer the to Code Generation tab of the Project Editor.
4.2.4 Spring Bean Configuration Tab
The Spring Bean Configuration tab is for configuring the @scope and @Transactional annotations for the Component.
Details | Description | ||
---|---|---|---|
Enable Transaction | Specifies whether the Spring transactional annotation should be emitted in this artifact’s generated code | ||
Read Only | Specifies a read-only transaction. | ||
Timeout | Specifies how long a transaction can run before timing out. | ||
Isolation | Specifies the degree of isolation this transaction has from the work of other transactions. | ||
Propagation | Specifies the transaction propagation. | ||
Rollback ClassNames | Specifies the exceptions that must cause a rollback. | ||
No Rollback ClassNames | Specifies the exceptions that must not cause a rollback. | ||
Scope | The scope for this bean. |
5.Operation
An Operation is a Spring DSL artifact that defines methods for Services, Controllers and Components. Operations are visual representations of Java methods, and they are shown as children artifacts to the respective Service, Controller or Component in the Spring DSL explorer. Operations use inputs and outputs for exchanging data, and they are generated as methods directly into the respective class.
Service Operations – Methods in a service are typically either core methods (public; used by service clients) or helper methods, and every method in the service has an associated Operation. In a Spring application, the core methods are typically configured with transactional properties.
Controller Operations – Methods in a controller are typically either request handlers (public; used by web clients) or helper methods, and every method in the controller has an associated Operation. In a Spring application, the core methods are typically configured with request mappings.
5.1 New Operation Wizard
The New Operation wizard is for adding a new operation to either a controller, service or component. By default, all operations created with the New Operation wizard are considered a public API operation, and this can be customized from the Overview tab of the Operation editor.
New Operation >> New Operation >> Operation Options
5.1.1 New Operation
The New Operation window is for specifying the name of the operation and the controller, component or service that will contain the operation.
Details | Description | ||
---|---|---|---|
Operation Name | Name of the new Operation |
5.1.2 Operation Options (for Controllers Only)
If you are creating a new operation in a controller, the New Operation wizard automaticallys create URL mapping (@RequestMapping) for the operation. Request mappings can also be managed using the Spring MVC tab.
Details | Description | ||
---|---|---|---|
Create a URL Mapping | For Controller Operations Only: Select this checkbox to create a URL Mapping for this operation. URL Mappings can also be added at a later time using Spring MVC tab. | ||
URL | For Controller Operations Only: When “Create a URL Mapping” is enabled, the URL is for specifying the URL for the URL Mapping. A default URL mapping is derived from the controller name and operation name, but the URL is completely configurable by the developer. |
5.2 Operation Editor
The Operation Editor is comprised of the Overview tab, the Input/Outputs tab, the Code Generation tab, and the Spring Bean Configuration tab. The following sections describe each tab in detail.
5.2.1 Overview Tab
The Overview tab is for providing a description of the Operation, navigating to the files generated from the Operation, navigating to other configuration tabs, and defining operation exceptions.
Details | Description | ||
---|---|---|---|
Name | Identifies the name of the new operation. | ||
Files | Click the Views link to display the generated source code. | ||
Description | Enter a meaningful description for this Operation. | ||
Exceptions | In the Exception tab, configure exceptions thrown by the operation. | ||
Visibility | Specifies the visibility (public, private or protected) of the operation. | ||
API | Specifies if the operation should be considered part of the the public API of the service, controller, or component. You might not want some operations (i.e., getters/setters) to be reflected in secondary generation artifacts (i.e., interfaces, unit tests, web services, etc…), and the API setting specifies which operations should be considered public. Public operations are reflected in secondary artifacts. |
5.2.2 Input / Outputs Tab
The Inputs/Outputs tab defines the input and output parameters of a particular operation. When this operation is invoked, the consumer (client) or the operation is required to map variables to the input and output parameters.
Details | Description | ||
---|---|---|---|
Inputs | Define the Inputs to this operation. | ||
Name | Identify the input parameter name. | ||
Type | Select the data type of the parameter. To select a Domain Object as the variable type, choose the Domain Object option from the Type drop-down menu. Select the desired data type from the data type picker, and click OK. | ||
Collection | Identify if the parameter is a Collection | ||
Add | Click this button to add an input variable. The default is Input_1, incrementing as additional variables are added until they are renamed. | ||
Outputs | Define the Outputs to this operation. | ||
Name | Identify the input parameter name. | ||
Type | Displays the data type of the input variable selected in the Assignment column. | ||
Assignment | Select the operation variable to assign to the output variable. Any variable from the variable list on the Variables sub-tab may be mapped to an output variable. | ||
Add | Click this button to add an output variable. The default is Output_1, incrementing as additional variables are added until they are renamed. |
5.2.3 Code Generation Tab
The Code Generation tab is for configuring the generation options for an operation. The implementation of an operation is generated into the respective controller, component, or service. However, this tab shows additional code artifacts generated and managed by the Spring DSL Operation. Each entry in this table represents a code artifact generated for the Operation. In addition to enabling and disabling code generation on an artifact-by-artifact basis, you can also customize the name of the artifact, the package used, and the location to which the artifact is generated.
You can specifiy code generation settings at the project level to control code generation for the entire project. The code generation settings can also be customized for each artifact using the code generation tab from the respective editor for the artifact.
For a description of the code generation settings available from the Service Editor, please refer the to Code Generation tab of the Project Editor.
5.2.4 Spring Bean Configuration Tab
The Spring Bean Configuration tab is used to configure the @scope and @Transactional annotations for the Operation.
Details | Description | ||
---|---|---|---|
Enable Transaction | Specifies whether the Spring transactional annotation should be emitted in this artifact’s generated code | ||
Read Only | Specifies a read-only transaction. | ||
Timeout | Specifies how long a transaction can run before timing out. | ||
Isolation | Specifies the degree of isolation this transaction has from the work of other transactions. | ||
Propagation | Specifies the transaction propagation. | ||
Rollback ClassNames | Specifies the exceptions that must cause a rollback. | ||
No Rollback ClassNames | Specifies the exceptions that must not cause a rollback. | ||
Scope | The scope for this bean. List of Available Scopes |
6.Web Flow
The Spring DSL Web Flow is for generating flows for Spring Web Flow and managing related source code and configuration files.
The Spring DSL Web Flow supports the creation of flows by:
- providing a New Web Flow wizard.
- providing a Web Flow editor for editing flows.
6.1 New Web Flow Wizard
The New Web Flow wizard is for adding a new Spring flow to the project.
New Web Flow >> New Web Flow >> Web Flow Domain
6.1.1 New Web Flow
The New Web Flow window is for specifying the name of the flow and the model package that will contain the flow.
Details | Description | ||
---|---|---|---|
File Name | New web flow filename |
6.1.2 Web Flow Domain Model
Details | Description | ||
---|---|---|---|
File Name | Name of the flow .xml file. This needs to be located inside the WEB-INF directory. |
Note: When creating a Spring Web Flow diagram, you are prompted for the name and location of the flow. When using the Web Flow editor, there are two XML files involved. The first XML file is the flow itself, and it’s used by the Spring framework at runtime to execute the flow. The second XML file is the diagram file, and it’s used to store the visual layout (position, fonts, colors) of the diagram. The diagram file is not used at runtime.
6.2 Web Flow Editor
With Spring Web Flow, the group of related steps to accomplish a task are referred to as a flow. While authoring the flow of an application using XML is elegant, implementing flows using XML can be difficult and tedious because it’s hard to visualize the application flow from the XML. MyEclipse for Spring provides a custom Spring Web Flow editor for authoring flows. You start with an empty canvas, which represents a single flow, and you drop different web flow states (i.e., view, decision, action, subflow and stop) onto the canvas. State transitions are defined by drawing lines between the states and specifying the event associated with the transition. Actions can be added to flows and states.
The Web Flow editor can be used both with the Spring DSL and without the Spring DSL. When used with the Spring DSL, diagrams are stored in a model package. When used without the Spring DSL, diagrams are stored in the springwebflowDiagrams folder.
7. Domain Object
The Spring DSL Domain Object is for defining the domain layer of an application, and it’s specifically responsible for generating JPA Entities and managing related source code and configuration files.
The Spring DSL Domain Object supports the creation of JPA Entities by:
- providing a New Domain Object wizard.
- providing a Domain Object editor.
- generating JPA Entities (annotated with @Entity).
- generating JUnit test classes for component testing.
7.1 New Domain Object Wizard
The New Domain Object wizard is for creating new domain objects for a development project. New Domain Object >> Domain Object7.1.1 New Domain Object
The New Domain Object window is for specifying the name of the domain object and the model package that will contain the domain object.
Details | Description | ||
---|---|---|---|
Domain Object Name | Name of the new Domain Object |
7.2 Domain Object Editor
The Domain Object editor is comprised of the Overview tab, the Code Generation tab, and the Persistence Mapping tab. The Service editor can be used for configuring a Service in the Spring DSL or by right-clicking (Open-With) an @Service annotated java class.7.2.1 Overview Tab
The Overview tab is for configuring the domain object fields, managing relationships, and providing a description.
Details | Description | ||
---|---|---|---|
Name | Identifies the name of the new domain object. | ||
Files | Click the Views link to display the generated source code. | ||
Description | Enter a meaningful description for this domain object. | ||
Relationships | Create and manage relationships between this and other domain objects by defining the Type, Name, and Inverse Name. Click the Add button to add a domain object. | ||
Fields | Create and edit fields in this domain object by defining Display Name, Type, and if it’s a collection. Click the Add button to add a field to this domain object. |
Type | Description | ||
---|---|---|---|
One-to-One | a domain object is related to a single occurrence of the other domain object | ||
One-to-Many | a domain object is related to many occurrences of the other domain object; the opposite of a Many-to-One relationship | ||
Many-to-One | a domain object is related to a single occurrence of the other domain object; the opposite of a One-to-Many relationship | ||
Many-to-Many | a domain object is related to many occurrences of the other domain object, and vice versa |
Bidirectional Relationships
When a relationship is added to another domain object, a unidirectional relationship is implied. Two independent unidirectional relationships can be linked together to create a bidirectional relationship. If you decide to define a bidirectional relationship, the cardinality and relationship names need to match.
Relationships Names
When defining a relationship between two data objects, the domain object editor prompts you for a relationship name and a reverse name. These names are used for accessing each other’s related data. The relationship name identifies the relationship from the perspective of the current domain object. The reverse name identifies the relationship from the target data object type back to the current domain object.
Regarding relationship names, the Domain Object editor defaults to the domain object name as the relationship name, but you can very easily change the name. It’s a good idea to change these relationship names to something more meaningful. While the names have no impact on the functionality, these names are what you see as you reference these relationships in the services you create. These names should be meaningful, and it’s recommended that you name them with the appropriate plurality for the relationship type.
7.2.2 Code Generation Tab
The Code Generation tab is for configuring the generation options for a domain object. This tab shows you the code artifacts generated and managed by the domain object. Each entry in this table represents a code artifact that is generated for the domain object. In addition to enabling and disabling code generation on an artifact-by-artifact basis, you can also customize the name of the artifact, the package used, and the location to which the artifact is generated.
You can specify code generation settings at the project level to control code generation for the entire project. The code generation settings can also be customized for each artifact using the code generation tab from the respective editor for the artifact. For a description of the code generation settings available from the Service editor, please refer the to Code Generation tab of the Project editor.
7.2.3 Persistence Mapping Tab
The Persistence Mapping tab is used to control how the domain object maps into persistence in a database and how it displays throughout the rest of the project. This tab includes the Table and Field Mapping and Relationships sections. The Persistence Mapping tab lets you override the default table name and field names.
Details | Description | ||
---|---|---|---|
Table Name | Pre-populated with the name of the domain object by default. This name can be modified. | ||
Schema | Database schema from which you are mapping | ||
Catalog | Database catalog from which you are mapping | ||
Column Name | The name of the database column in which this field will be stored. If left blank, the name of the field is used. A user can override this name during deployment. | ||
Length | Length of text field. Default is 512 characters. | ||
Precision | Maximum number of digits present in a number. | ||
Scale | Maximum number of decimal places in a number. | ||
Fetch | Select the desired value of either Lazy, Eager, Unset. | ||
Option | Select the desired column option. Valid values are: Insertable, Updateable, Nullable, and Unique. |
When a domain object is configured to be persisted to a database, the database name and fields are derived from the domain object. However there are occasions where a developer might want the table names and field names to be different than the object. When a domain object is created, MyEclipse uses the following persistence mapping defaults:
- Table name = domain object name
- Table field names = domain object field names
These settings can be modified from this tab. The settings in this tab drive the configuration of the ORM framework.
8. Data Access Object
The Spring DSL Data Access Object is for generating Spring @Repository components and and managing related source code and configuration files. The Spring DSL Domain Object supports the creation of JPA Entities by:
- providing a New Data Access Object wizard.
- providing a Data Access Object editor.
- generating Spring @Repository components JPA Entities (annotated with @Entity).
- generating JUnit test classes for component testing.
8.1 Data Access Object Wizard
The New Data Access Object wizard is for creating new data access objects for a development project. New Data Access Object >> Data Access Object >> Select Domain Objects
8.1.1 New Data Access Object
The New Data Access window is for specifying the name of the data access object and the model package that will contain the data access object.
Details | Description | ||
---|---|---|---|
File Name | Enter the name of the new data access object in the File Name text box, then click Next to add a domain object. Data access objects can have duplicate names as long as they are stored in separate services or in separate folders within a service. |
8.1.2 Select Domain Objects
When you create a DAO, you can associate one or more domain objects with the DAO.
Details | Description | ||
---|---|---|---|
Domain Objects | Add domain objects managed by this data access object. A data access object must have at least one domain object. |
8.2 Data Access Object Editor
The Data Access Object editor is comprised of the Overview tab, the Code Generation tab, the Database Configuration tab, and the Spring Bean Configuration tab. The following sections describe each tab in detail.
8.2.1 Overview Tab
The Overview tab is for associating domain objects to the DAO, providing a description of the DAO, and navigating to the files generated from the DAO.
Details | Description | ||
---|---|---|---|
Name | Name of the new data access object. | ||
Files | Click the Views link to display the generated source code. | ||
Description | Enter a meaningful description for this data access object. | ||
Domain Objects | Select and add domain objects to be managed by this data access object. |
8.2.2 Code Generation Tab
The Code Generation tab is for configuring the generation options for a data access object. This tab shows the code artifacts generated and managed by the Spring DSL DAO. Each entry in this table represents a code artifact that is generated for the DAO. In addition to enabling and disabling code generation on an artifact-by-artifact basis, you can also customize the name of the artifact, the package used, and the location to which the artifact is generated.
8.2.3 Database Configuration Tab
The Database Configuration tab allows a user to select a database for this data access object.
Details | Description | ||
---|---|---|---|
Connection | Select a database connection from the list of available databases in the drop-down menu. | ||
Create New Connection | Click this link to invoke the New Connection Profile window. See the To Create a New Connection section for details on configuring a new connection. After creating a new connection, it becomes available in the Connection drop-down list. | ||
Enable Persistence Provider SQL Logging | Select this checkbox to enable SQL Logging capability. | ||
Allow Persistence Provider to create/update tables | Select this checkbox to allow the designated persistence provider to create/update tables to the database. | ||
Minimum Connection Pool Size | Default value is 1. | ||
Maximum Connection Pool Size | Default value is 10. | ||
Enable XA Data Source | Select this checkbox to specify an XA data source. | ||
XA Data Source Class Name | Enter the data source class name. |
8.2.4 Spring Bean Configuration Tab
The Spring Bean Configuration tab is for configuring the @scope and @Transactional annotations for the data access object.
Details | Description | ||
---|---|---|---|
Enable Transaction | Specifies if the Spring transactional annotation should be emitted in this artifact’s generated code | ||
Read Only | Specifies a read-only transaction. | ||
Timeout | Specifies how long a transaction may run before timing out. | ||
Isolation | Specifies the degree of isolation this transaction has from the work of other transactions. | ||
Propagation | Specifies the transaction propagation. | ||
Rollback ClassNames | Specifies the exceptions that must cause a rollback. | ||
No Rollback ClassNames | Specifies the exceptions that must not cause a rollback. | ||
Scope | The scope for this bean. |
9. Named Query
The following sections describe the Named Query wizards and editors.
9.1 Named Query Wizard
The New Named Query wizard is for adding a new named query to a data access object.
New Named Query >> Named Query
9.1.1 New Named Query
The New Named Query window is for specifying the name of the named query and the data access object that will contain the named query.
Details | Description | ||
---|---|---|---|
Named Query Name | Name of the new named query |
9.2 Named Query Editor
The Named Query editor is comprised of the Overview tab, the Input/Outputs tab, the Query Text tab, and the Spring Bean Configuration tab. The follow sections describe each tab in detail.
9.2.1 Overview Tab
The Overview tab is for providing a description of the named query, navigating to the files generated from the named query, and navigating to the other Named Query configuration tabs.
Details | Description | ||
---|---|---|---|
Name | Name of the new named query. | ||
Files | Click the Views link to display the generated source code. | ||
Description | Enter a meaningful description for this named query. | ||
Define Inputs and Outputs | Click this link to jump to the Inputs/Outputs tab. | ||
Define the Query Text | Click this link to jump to the Query Text tab. |
9.2.2 Inputs / Outputs Tab
The Inputs/Outputs tab defines the input and output parameters of a particular named query. When this query is invoked, the consumer of the named query is required to map variables to the input and output parameters.
Details | Description | ||
---|---|---|---|
Inputs | Inputs are a mechanism for exchanging data with the consumer of the named query. When a consumer calls a named query, they must provide all input variables defined by the query. | ||
Name | Input parameter name. | ||
Type | Select the data type of the parameter. In addition to primitive data types, an input parameter can have the type of a domain object. To select a domain object as the variable type, choose the domain object option from the Type drop-down list. Select the desired data type from the data type picker, and click OK. | ||
Collection | Specify if the parameter is a collection. | ||
Add | Click this button to add an input variable. The default is Input_1, incrementing as additional variables are added until they are renamed. | ||
Outputs | Outputs are another mechanism for exchanging data with the consumer of the named query. When a consumer calls a named query, they must accept all output variables defined by the named query. | ||
Name | Output parameter name. | ||
Type | Select the data type of the parameter. In addition to primitive data types, an output parameter can have the type of a domain object. To select a domain object as the variable type, choose the domain object option from the Type drop-down list. Select the desired data type from the data type picker, and click OK. | ||
Collection | Specify if the parameter is a collection. | ||
Add | Click this button to add an output variable. The default is Output_1, incrementing as additional variables are added until they are renamed. |
9.2.3 Query Text Tab
The Query Text tab defines the query in either SQL or JPQL.
Details | Description | ||
---|---|---|---|
Query Type | Specifies the query language used in the named query. The options are:
| ||
Query Text | Define the query text to execute. | ||
Insert | Click this button to invoke a variable picker and select the input or output variable to include in the expression. | ||
Edit Expression | Click this button to invoke the Expression editor and build a valid expression. |
9.2.4 Spring Bean Configuration Tab
The Spring Bean Configuration tab is used to configure the @scope and @Transaction annotations for the named query.
Details | Description | ||
---|---|---|---|
Enable Transaction | Specifies whether the Spring transactional annotation should be emitted in this artifact’s generated code | ||
Read Only | Specifies a read-only transaction. | ||
Timeout | Specifies how long a transaction may run before timing out. | ||
Isolation | Specifies the degree of isolation this transaction has from the work of other transactions. | ||
Propagation | Specifies the transaction propagation. | ||
Rollback ClassNames | Specifies the exceptions that must cause a rollback. | ||
No Rollback ClassNames | Specifies the exceptions that must not cause a rollback. |
10.Exception
The following sections describe the Exception wizards and editors.
10.1 New Exception Wizard
The New Exception wizard is for adding a custom exception to a project.
New Exception >> New Exception
10.1.1 New Exception
The New Exception window is for specifying the name of the exception and the model package that will contain the exception.
Details | Description | ||
---|---|---|---|
Exception Name | Name for the new exception |
10.2 Exception Editor
The Exception editor is comprised of the Overview tab and the Code Generation tab. The follow sections describe each tab in detail.
10.2.1 Overview Tab
The Overview tab is used for providing a description of the Exception, navigating to the files generated from the Exception, and navigating to the other Exception configuration tabs. Refer to the following figure and table for details on this tab.
Details | Description | ||
---|---|---|---|
Files | Click the View link to display the generated source code. | ||
Description | Provide a meaningful description of the exception. |
10.2.2 Code Generation Tab
The Code Generation tab is for configuring the generation options for an exception. This tab shows you all code artifacts generated and managed by the Spring DSL Exception. Each entry in this table represents a code artifact that is generated for the Exception. In addition to enabling and disabling code generation on an artifact-by-artifact basis, you can also customize the name of the artifact, the package used, and the location to which the artifact is generated.
You can specify code generation settings at the project level to control code generation for the entire project. The code generation settings can also be customized for each artifact using the code generation tab from the respective editor for the artifact. For a description of the code generation settings available from the Service editor, please refer the to Code Generation tab of the Project editor.
11. Model Package
A Model Package is a Spring DSL artifact for namespacing and grouping related Spring DSL components. A model package can contain any top-level Spring DSL elements, including other model packages. Model packages correlate directly to Java packages (and UML packages), and Spring DSL artifacts created in a model package are generated into a matching Java package. In Java application development, it is common to use packages for organizing and name spacing Java resources according to their function, and Model Packages serve the same purpose, except they group generated artifacts.
11.1 New Model Package Wizard
The New Model Package wizard is for adding a new package to a project.
New Web Flow >> New Model Package
11.1.1 New Model Package
The New Model Package window is for specifying the name of the model package.
Details | Descriptiond | ||
---|---|---|---|
Package | Name of the package to add to the project. |