-
Open Source Java Frameworks on NonStop User's Guide HP Part Number: 576269-001 Published: August 2009 Edition: J06.03 and subsequent J-series RVUs and H06.
-
© Copyright 2009 Hewlett-Packard Development Company, L.P. Legal Notice Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor’s standard commercial license. The information contained herein is subject to change without notice.
-
Table of Contents About This Document.......................................................................................................15 Supported Release Version Updates (RVUs)........................................................................................15 Intended Audience................................................................................................................................15 New and Changed Information in This Edition...............................................
-
Windows System........................................................................................................................45 Installing Spring Framework Libraries on NonStop.......................................................................45 Downloading Spring Distribution on Windows........................................................................45 Copying Spring Runtime Libraries from Windows to NonStop...............................................
-
Defining the PlatformTransactionManager...........................................................83 Defining the Transaction Rollback (Optional).................................................................83 Programmatic Transaction Management..............................................................................84 Using the TransactionTemplate...............................................................................84 Using a PlatformTransactionManager......................................
-
Modifying the index.jsp File.....................................................................................137 Deploying EmpInfo on NonStop.............................................................................................142 Creating the Application WAR File on Windows...............................................................142 Deploying the EmpInfo WAR File in NSJSP on NonStop..................................................143 Running EmpInfo on NonStop.............................
-
6 Axis2/Java Overview...........................................................................................173 Axis2/Java Architecture.................................................................................................................173 Key Features of Axis2/Java............................................................................................................174 Components in an Axis2/Java Application on NonStop...............................................................
-
Module Configuration..............................................................................................................200 9 Getting Started with Axis2/Java.........................................................................201 Prerequisites..................................................................................................................................201 NonStop System..........................................................................................................
-
12 Configuring MyFaces Applications on NonStop Systems..............................239 NonStop Platform Configurations.................................................................................................239 Determining the Application Parameters................................................................................239 Determining the Maximum Capacity of NSJSP Instance.........................................................239 Configuring iTP WebServer for MyFaces Applications.........
-
F Installing MyFaces Tomahawk Framework Libraries on NonStop....................285 Downloading MyFaces Tomahawk Distribution on Windows.....................................................285 Copying MyFaces Tomahawk Runtime Libraries from Windows to NonStop............................285 IV Hibernate Framework...............................................................................................287 14 Hibernate Overview..............................................................................
-
Configuring httpd Processes to Handle Maximum Load................................................309 Limiting the Maximum Number of Incoming Requests....................................................311 Configuring NSJSP for Hibernate Applications.......................................................................312 Configuring SessionBasedLoadBalancing..........................................................................312 Configuring Connector Threads...........................................
-
G Customizing Sample Application.......................................................................355 Customizing Caveat Emptor.........................................................................................................355 Modified File............................................................................................................................355 Main.java ........................................................................................................................
-
Creating the Employee.hbm.xml File.................................................................................392 Removing the EmployeeRowMapper.java File...................................................................394 Adding Dependency JAR Files...........................................................................................394 Deploying EmpInfo on NonStop.............................................................................................
-
Creating the IEmployeeDao.java File..................................................................................443 Modifying the EmployeeDao.java File.........................................................................444 Creating the ServiceFinder.java File....................................................................................445 Creating the EmpBean.java File.......................................................................................445 Creating the MessageFactory.
-
About This Document This manual is a user manual and a reference manual. It provides information on using OpenSource Java Frameworks on a NonStop system, and contains instructions and guidelines on install, configure, and use the following frameworks on an HP NonStop™ system: • • • • Spring Axis2/Java MyFaces Hibernate Supported Release Version Updates (RVUs) This manual supports J06.03 and all subsequent J-series RVUs, and H06.
-
Appendix D: Installing Spring Web Flow This appendix describes the steps required to install Spring Web Flow on your NonStop system. Part II: Axis2/Java Framework Part II describes the procedure to customize the Axis2/Java framework to work on a NonStop system. Chapter 6: Axis2/Java Overview This chapter provides an overview of the Axis2/Java framework, its architecture, key features, advantages, and message flow.
-
Appendix I: Hibernate Environment Setup Script This appendix contains the ei_setenv script. Appendix J: Installing Hibernate Annotations Libraries on NonStop This appendix describes the steps required to install Hibernate Annotations Libraries on your NonStop system. Appendix K: Installing Hibernate EntityManager Libraries This appendix describes the steps required to install on NonStop Hibernate EntityManager Libraries on your NonStop system.
-
Bold Text Bold text in an example indicates user input typed at the terminal. For example: ENTER RUN CODE ?123 CODE RECEIVED: 123.00 The user must press the Return key after typing the input. [ ] Brackets Brackets enclose optional syntax items. For example: TERM [\system-name.]$terminal-name INT[ERRUPTS] A group of items enclosed in brackets is a list from which you can choose one item or none.
-
Item Spacing Spaces shown between items are required unless one of the items is a punctuation symbol such as a parenthesis or a comma. For example: CALL STEPMOM ( process-id ) ; If there is no space between two items, spaces are not permitted. In this example, no spaces are permitted between the period and any other items: $process-name.
-
Italic Text Italic text indicates variable items whose values are displayed or returned. For example: p-register process-name [ ] Brackets Brackets enclose items that are sometimes, but not always, displayed. For example: Event number = number [ Subject = first-subject-value ] A group of items enclosed in brackets is a list of all possible items that can be displayed, of which one or none might actually be displayed.
-
!r The !r notation following a token or field name indicates that the token or field is required. For example: ZCOM-TKN-OBJNAME token-type ZSPI-TYP-STRING. !r !o The !o notation following a token or field name indicates that the token or field is optional. For example: ZSPI-TKN-MANAGER token-type ZSPI-TYP-FNAME32. !o General Syntax Notation This list summarizes the notation conventions for syntax presentation in this manual. UPPERCASE LETTERS Uppercase letters indicate keywords and reserved words.
-
| Vertical Line A vertical line separates alternatives in a horizontal list that is enclosed in brackets or braces. For example: {expression | NULL} … Ellipsis An ellipsis immediately following a pair of brackets or braces indicates that you can repeat the enclosed sequence of syntax items any number of times. For example: ATTRIBUTE[S] attribute [, attribute]... {, sql-expression}... An ellipsis immediately following a single syntax item indicates that you can repeat that syntax item any number of times.
-
HP Encourages Your Comments HP encourages your comments concerning this document. We are committed to providing documentation that meets your needs. Send any errors found, suggestions for improvement, or compliments to docsfeedback@hp.com. Include the document title, part number, and any comment, error found, or suggestion for improvement you have concerning this document.
-
-
1 Introduction Java-based Web application development has been inundated by frameworks of every kind. There is a framework available for almost every application development requirement. The effort for developing an application using the framework approach is significantly less as compared to developing an application afresh. The efficiency of Java-based Web development can be increased by using the appropriate framework. Hence, the need for OpenSource frameworks arises.
-
Prerequisites Before getting started, make sure that you have the requisite software installed on your NonStop and Windows system.
-
is the version procedure of the iTP Secure WebServer release installed (for example, T8997H02_09FEB09_ADE_H028_01). For example: OSS> cd /usr/tandem/webserver/T8997H02_09FEB09_ADE_H028_01/bin NOTE: You may have more than one version of iTP Secure WebServer available on your NonStop system. Ensure that you select iTP WebServer version T8997H02 or later. 2.
-
NonStop Servlets for Java Server Pages (NSJSP) • The version of NSJSP installed on your system must be T1222H60 or later. — If you already have NSJSP installed on your system, check its version by following these instructions: 1. Go to the /usr/tandem/nsjsp//lib directory on OSS. where, is the version procedure of the NSJSP release installed (for example, T1222H60_27JUN2008_V600_AAH_1).
-
The setup script guides you through the deployment of NSJSP. For more information on setup, see the NonStop Servlets for JavaServerPages (NSJSP) 6.0 System Administrator's Guide. • Ensure the following settings in NSJSP: — The unpackWARs and autoDeploy parameters must be set to true in the /conf/server.xml file on your NonStop system. NOTE: — By default, unpackWARs and autoDeploy is set to false. The /conf/jdbc.
-
The version of JDBC Type 2 driver must be T1275H50 or later. To install JDBC Type 2 driver on your NonStop system, see the JDBC Driver for SQL/MX Programmer's Reference Manual. NonStop SQL/MX The version of SQL/MX installed on your system must be T1050H23 or later. If you already have SQL/MX installed on your NonStop system, check its version by following these instructions: 1. Go to the /bin directory on OSS.
-
Windows System The following software must be installed on your Windows system: • Java Development Kit (JDK) • Ant • JDBC Type 4 Driver for NonStop SQL/MX • Eclipse IDE Java Development Kit (JDK) The version of JDK installed on your system must be 1.5 or later. If you already have JDK installed on your Windows system, check its version using the following command: Command Prompt> java –version java version "1.5.0_05" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.
-
3. Enter the variable name as JAVA_HOME and variable value as . For example: Enter C:\Program Files\Java\jdk1.5.0_05\bin as the value of PATH and C:\Program Files\Java\jdk1.5.0_05 as the value of JAVA_HOME. 4. 5. Click OK. Click Apply Changes. If you do not have JDK installed on your Windows system, download it from the website: http://java.sun.com/javase/downloads/index.jsp NOTE: All applications have been verified using JDK version 1.5.
-
3. Enter the variable name as ANT_HOME and variable value as . For example: Enter C:\ant1.7.0RC1\bin as the value of PATH and C:\ant1.7.0RC1 as the value of ANT_HOME. 4. 5. Click OK. Click Apply Changes. If you do not have Ant 1.7.0 installed on your Windows system, download the apache-ant-1.7.0-bin.zip file from the website: http://archive.apache.
-
-
Part I Spring Framework Part I describes how a Spring framework can be customized to work on a NonStop system. It includes the following chapters: • Chapter 2: Spring Overview This chapter provides an overview of the Spring framework, its architecture, key features, advantages, and message flow. • Chapter 3: Installing Spring Framework This chapter helps you to install the Spring framework libraries and enables you to deploy and run sample Spring applications on your NonStop system.
-
-
2 Spring Overview The HP NonStop system provides a platform that makes it easy to integrate open source frameworks and build enterprise applications to cater to the ever-changing business requirements. A range of frameworks are available to build modern-day enterprise applications. One such framework is the Spring framework, which enables users to quickly and easily create high-quality enterprise applications that can be deployed on NonStop servers.
-
Figure 2-1 Core Spring Components The functionality of each component is as follows: • Spring Core The Spring Core provides the Inversion of Control (IoC) and Dependency Injection feature and is a fundamental part of the Spring framework. It is based on the concept of BeanFactory. The BeanFactory implements factory patterns, which separates the implementation of actual business logic from the dependencies configuration and specifications.
-
• Spring ORM The Spring Object Relational Mapping (ORM) module enables you to integrate several popular ORM tools, such as Hibernate and Java Persistence API (JPA). These ORM tools are conformant with the generic transaction and DAO exception hierarchies in Spring. • Java Enterprise Edition The Java Enterprise Edition (JEE) Context Package includes APIs that can be leveraged by a Spring context file.
-
For more information on PATHMON processes, see the HP NonStop Pathway/iTS System Management Manual. iTP WebServer An iTP WebServer is a NonStop web server, which provides a range of services for running an online commercial or informational enterprise on the Web. The core process of the iTP WebServer is httpd, which acts as a File server and a Message-switching facility. For more information on iTP WebServer, see the iTP Secure WebServer System Administrator's Guide.
-
Figure 2-2 Message Flow in a Spring Application A Spring message flows through all the components in the following sequence: 1. 2. 3. Web client sends Spring application request to the NonStop TCP/IP subsystem through a web browser. The NonStop TCP/IP subsystem sends the request to the httpd process of the iTP WebServer. If you are using the conventional TCP/IP, request is sent to the Distributor process of the iTP WebServer.
-
NOTE: Because JDBC Type 2 is a dynamic-link library (DLL), it is loaded as a part of the Spring application process. However, when the JDBC Type 4 driver is used, the JDBC process runs as a separate process external to the Spring application process.
-
Following are additional advantages of using the Spring Web Flow: • • • The UI flow in a web application is clearly visible by examining the corresponding web flow definition (typically in an XML file). Web Flows can be designed to be self-contained; you can view a part of your application as a module and reuse it in multiple situations. Web Flows can define any reasonable UI flow in a web application using the same consistent technique.
-
-
3 Installing Spring Framework This chapter discusses the steps required to complete the following activities: 1. 2. Installing Spring Framework Libraries on NonStop Deploying and Running Sample Spring Applications on NonStop Prerequisites Before getting started, make sure that you have the requisite software installed on your NonStop and Windows system.
-
1. 2. Register yourself. Click No thanks, take me to the download. The Spring frameworks available for download are displayed. 3. Download the spring-framework 2.5.5-with-dependencies.zip file. NOTE: • The spring-framework 2.5.5-with-dependencies.zip file includes the Spring sample applications, the Spring framework libraries, and third party libraries that are required to build the sample applications. The other distributions, spring-framework-2.5.5-with-docs.zip and spring-framework-2.5.5.
-
OSS> jar –xvf spring_dist.jar OSS> jar –xvf spring_lib.jar After extraction, must have two sub-directories: /dist and /lib. NOTE: The sub-directories on your NonStop system must contain the same list of files as those in the \dist and \lib directories on your Windows system. This completes the installation of Spring runtime libraries on a NonStop system.
-
NOTE: There are four sample applications distributed with the Spring distribution, of which three (PetClinic, JPetStore, and ImageDB) are discussed here. The modifications made in these three sample applications are discussed in the Customizing Sample Applications section. PetClinic The PetClinic sample application is an information system that is accessible using a web browser.
-
For example, if your is C:\spring-framework-2.5.5, modify spring.root to: 3. Configure the JDBC driver settings for the NonStop SQL/MX database. 1.
-
Command Prompt> ant –buildfile build_jdbct2.xml all • If you plan to use the JDBC Type 4 driver, build the PetClinic web archive using the command: Command Prompt> ant –buildfile build_jdbct4.xml all 3. If the PetClinic build is successful, a new directory named dist is created in the \spring\samples\petclinic directory. The application WAR file (petclinic.war) is created in the dist directory.
-
NOTE: By default, the petclinic_tables_script.sql file creates the database catalog name as petcliniccat and schema name as petclinicsch. If these names conflict with any of the existing catalog and schema names, modify the database catalog and schema names in the petclinic_tables_script.sql script file. If you modify the database catalog and schema names, edit the jdbc.properties file present in the \spring\samples\petclinic\src directory, present in SAMPLES.zip file. 6.
-
Figure 3-1 NSJSP Web Application Manager Login Screen 2. Enter the User name and Password and click OK. The NSJSP Web Application Manager screen appears. Figure 3-2 shows the NSJSP Web Application Manager screen.
-
3. 4. In the WAR file to deploy section, click Browse and locate the petclinic.war file on your Windows system. Click Deploy. PetClinic is listed under Applications. NOTE: If you do not have access to the NSJSP Web Application Manager screen, you can deploy PetClinic on your NonStop system by completing the following steps: 1. Ensure that you have WRITE permissions to the webapps directory in your .
-
JPetStore The intended users of the JPetStore sample application are Visitors and Shoppers. A Visitor is anyone who visits the site. A Shopper is an authenticated visitor who is signed in to the site. Visitors can browse the site for items of their interest. Shoppers can purchase items of their interest. This section describes how to build, setup, deploy, and run the JPetStore sample application.
-
2. Modify the jdbc.properties file to update the JDBC configuration. You can use either the JDBC/MX Type 2 driver or the JDBC/MX Type 4 driver. The SQL/MX settings for each of them is as follows. • If you plan to use the JDBC/MX Type 2 driver, uncomment the SQL/MX settings for the JDBC Type 2 driver in the jdbc.properties file, so that the SQL/MX settings for the JDBC Type 2 driver appear as: #------------------------------------------------------------# SQL/MX Settings for JDBC Type 2 Driver jdbc.
-
1. Edit the jpetstore_tables_script.sql file to add the following: • <$datavol>: specify the Guardian volume for the primary partition of the table. For example: $data01 • : specify the owner of the schema. For example: super.sashusr • : specify the location of the metadata tables for the catalog. For example: \NSK01.$data01 • : specify the designated subvolume name for the schema. For example: SASH2 NOTE: 2. The subvolume name must only be five characters long.
-
Deploying JPetStore on NonStop To deploy JPetStore on your NonStop system, complete the following steps: 1. Go to http://:/servlet_jsp /manager/html. The NSJSP Web Application Manager Login screen appears. Figure 3-3 shows the NSJSP Web Application Manager Login screen. Figure 3-3 NSJSP Web Application Manager: Login Screen 2. Enter the User name and Password and click OK. The NSJSP Web Application Manager screen appears.
-
Figure 3-4 NSJSP Web Application Manager Screen 3. 4. In the WAR file to deploy section, click Browse and locate the jpetstore.war file on your Windows system. Click Deploy. JPetStore is listed under Applications. NOTE: If you do not have access to the NSJSP Web Application Manager screen, you can deploy JPetStore on your NonStop system by completing the following steps: 1. Ensure that you have WRITE permissions to the webapps directory in your .
-
NOTE: If you do not have access to the NSJSP Web Application Manager screen, you can run JPetStore on your NonStop system by completing the following steps: 1. Go to the /conf directory using the command: OSS> cd /conf For example: OSS> cd /home/sash_usr/webserver/conf 2. Start your iTP WebServer using the command: OSS> ./start 3.
-
\src includes the customized source for ImageDB. \war includes all the necessary configuration files required to build the application WAR file. 2. Modify the ImageDB build file. • If you plan to use the JDBC Type 2 driver, set the spring.root property in the \spring\samples\imagedb\build_jdbct2.xml file as:
-
NOTE: Because JDBC Type 2 driver resides on the NonStop system, you need not mention the username and password in the jdbc.username and jdbc.password fields. • If you plan to use the JDBC/MX Type 4 driver, uncomment the SQL/MX settings for the JDBC Type 4 driver in the jdbc.properties file and enter the values of the JDBC URL (NonStop system IP Address and port number of JDBC data source), NonStop system username, and password. The SQL/MX settings for the JDBC Type 4 driver in the jdbc.
-
NOTE: 2. The subvolume name must only be five characters long. Create a directory in OSS to place the database script files, using the command: OSS> mkdir –p /spring/samples/imagedb/dbconfig For example: OSS> mkdir –p /home/sash_usr/sash/spring/samples/imagedb/dbconfig NOTE: can be any working directory. It is suggested that you create the spring/samples/imagedb/dbconfig directory structure in . 3. Copy the imagedb_tables_script.
-
Figure 3-5 NSJSP Web Application Manager Login Screen 2. Enter the User name and Password and click OK. The NSJSP Web Application Manager screen appears. Figure 3-6 shows the NSJSP Web Application Manager screen.
-
3. 4. In the WAR file to deploy section, click Browse and locate the ImageDB.war file on your Windows system. Click Deploy. ImageDB is listed under Applications. NOTE: If you do not have access to the NSJSP Web Application Manager screen, you can run ImageDB on your NonStop system by completing the following steps: 1. Go to the /conf directory using the command: OSS> cd /conf For example: OSS> cd /home/sash_usr/webserver/conf 2.
-
4 Configuring Spring Applications on NonStop Systems This chapter provides information about configuring Spring applications on NonStop systems. This chapter includes the following sections: • • • NonStop Platform Configurations Spring Framework Configurations Module File Caching Configurations NonStop Platform Configurations On a NonStop system, an application developed using the Spring framework is deployed as a web application under the NSJSP container.
-
4. 5. Set the value of TANDEM_RECEIVE_DEPTH to 250 (because the values of Maxlinks and TANDEM_RECEIVE_DEPTH should be equal). A value of 250 means that the NSJSP process is able to read a maximum of 250 messages simultaneously from its $RECEIVE file. Configure the Executor element in the /conf/server.xml file on OSS. The Executor is used by the Connector as a thread pool. Set maxThreads = 300, minSpareThreads = 10 and maxIdleTime = 30000.
-
Configuring httpd Processes to Handle Maximum Load The httpd processes are configured using the Server configuration directive in the /conf/httpd.config file on OSS. The Server directive controls the creation of the PATHMON environment, where the webserver runs.
-
of the five static processes can handle 100 requests. In this example, the capacity of the iTP WebServer environment can be summarized as follows: — The static capacity of iTP WebServer is [Numstatic X TANDEM_RECEIVE_DEPTH]= 500. — The dynamic capacity is [(Maxservers – Numstatic) X TANDEM_RECEIVE_DEPTH]= 4500. — The total capacity of iTP WebServer is [Maxservers X TANDEM_RECEIVE_DEPTH]= 5000. Using this configuration, the iTP WebServer can handle 500 simultaneous requests statically.
-
After determining the values, you can use any the following approaches to make necessary configurations for the TS/MP parameters of the httpd processes: — — Using the default value of TANDEM_RECEIVE_DEPTH Modifying the value of TANDEM_RECEIVE_DEPTH Using the default value of TANDEM_RECEIVE_DEPTH With TANDEM_RECEIVE_DEPTH set to the default value of 50, the static processes can be configured on the basis of Average Load and dynamic processes can be configured on the basis of Peak Load on your system.
-
Maximum connections reached: The server reached its maximum configured capacity. with HTTP response code: 200 OK To customize the error message, create a new message ID error-maximum-connection. This customized message is displayed if the message configuration directive is used in the /conf/httpd.config file with the new message ID.
-
NOTE: • The default value of -DSaveSessionOnCreation is false. -DSessionBasedLoadBalancing Enables or disables SessionBasedLoadBalancing. Syntax: -DSessionBasedLoadBalancing=[ true | false ] NOTE: The default value of -DSessionBasedLoadBalancing is set to true.
-
NOTE: When the SessionBasedLoadBalancing feature is turned ON, messages are delivered to NSJSP not only through TS/MP but also through file system calls. Hence, there could be a situation that all messages delivered to a particular dynamic process are through file system calls and none through TS/MP. Therefore, TS/MP might assume that a particular dynamic process is not required any more and will shut down the process.
-
connectionTimeout="0" acceptCount="25" maxThreads="75"/> … … Configuring the Executor Element You can configure the Executor element as a child element of the Service element in the /conf/server.xml file on OSS. The following snippet of the server.xml configuration file shows the configuration of the Executor element and how a Connector element can be configured to use an Executor element: … …
-
• • TANDEM_RECEIVE_DEPTH must be twice the value of Maxlinks. Normally, to handle n number of messages, you need n number of threads. In extreme cases, all the n requests may timeout. While the same number of threads processing the timeout requests could still be busy, you need the same n number of threads to process the new incoming requests. Therefore, the number of threads that must be configured is (n + n = 2n).
-
to NSJSP through TS/MP and there will not be any file system call. After the 25 requests are serviced, subsequent requests on those 25 web dialogs are delivered to NSJSP through file system I/O operations. At this stage, all 25 links to the NSJSP instance are free to process more incoming requests delivered through TS/MP. Therefore, the NSJSP instance should now be able to handle 25 more concurrent requests all being the first requests of web dialogs.
-
-Xnoclassgc Is an optional argument to stop the Java class garbage collection. Syntax: -Xnoclassgc By default, the Java runtime reclaims space for unused Java classes. Including this optional argument may prevent any memory-leak problems.
-
the connection URL, specify the connection URL as jdbc:sqlmx:// for the SQL/MX database in the jdbc.properties file: jdbc.properties file: jdbc.url=jdbc:sqlmx:// Establishing the Connection Specify the username and password with no values in the jdbc.properties file: jdbc.username= jdbc.password= Configurations in the applicationContext.xml File For making necessary JDBC configurations, complete the following activities: 1. 2. 3. 4.
-
PropertyPlaceholderConfigurer class provided by the Spring framework substitutes all the database properties specified in the applicationContext.xml file with the values specified in the jdbc.properties file during runtime. Modify the applicationContext.xml file for wiring the jdbc.properties file as shown below: classpath:jdbc.
-
jdbc.username= jdbc.password= Configurations in the applicationContext.xml File For making necessary JDBC configurations, you need to create the applicationContext.xml file and complete the following activities: 1. 2. 3. 4.
-
classpath:jdbc.properties
NOTE: For information on the complete configuration snippet of the applicationContext.xml file and the jdbc.properties file, see JDBC Configuration.
-
} public MyObject getMyObject(String myObjectName, String myObjectDesc) { throw new UnsupportedOperationException(); } public void insertMyObject(MyObject myobject) { throw new UnsupportedOperationException(); } public void updateMyObject(MyObject myobject) { throw new UnsupportedOperationException(); } To make the DefaultMyService service object as transactional, the configuration in the applicationContext.
-
Defining the Transactional Execution Point To ensure that the transactional advice defined in the above step is executed at the appropriate point in the program, you must define the transactional execution point. This is done using the definition in the applicationContext.xml file. Define a pointcut that matches the execution of any operation defined in the Transactional Service interface. Associate the pointcut with the advisor.
-
NOTE: Here org.apache.commons.dbcp.BasicDataSource is used as the datasource. Defining the PlatformTransactionManager The PlatformTransactionManager is an interface; it is not tied to a lookup strategy such as JNDI, thereby making it abstract while working with JTA. The PlatformTransactionManager interface implementations normally require knowledge of the environment in which they work, such as JDBC, or JTA or Hibernate and so on. For JDBC, the implementation of PlatformTransactionManager is org.
-
Programmatic Transaction Management The Spring framework provides two means of programmatic transaction management: • • Using the TransactionTemplate Using a PlatformTransactionManager Using the TransactionTemplate The TransactionTemplate handles the transaction lifecycle and possible exceptions so that the calling code does not explicitly handle transactions.
-
2. Use the TransactionDefinition and TransactionStatus objects to initiate transactions, rollback, and commit. DefaultTransactionDefinition def = new DefaultTransactionDefinition(); // explicitly setting the transaction name is something that can only be done programmatically def.setName("SomeTxName"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); TransactionStatus status = txManager.
-
NOTE: C3P0 is tunable and offers a number of configuration parameters. For more information on C3P0 configuration, see http://sourceforge.net/projects/c3p0. For the complete list of parameters, see http://www.mchange.com/projects/c3p0/ index.html#appendix_a Recommendations Connection Pooling mechanism should be used when your application: • • • Cannot handle the overhead of obtaining and releasing connections frequently.
-
Module File Caching Configurations The Module File Caching (MFC) feature shares the prepared statement plans among the NonStop SQL/MX database connections and helps in reducing resource consumption. MFC is disabled by default; therefore, it must be configured to enable it. To use the MFC feature, you must perform the following activities: • • Configuring NonStop SQL/MX DataSource for MFC Modifying the Spring Application NOTE: JDBC Type 4 driver offers MFC feature.
-
Modifying the Spring Application NOTE: If the default datasource is configured for MFC, do not modify the Spring application. To use the MFC feature, modify the Spring application by using the following steps: 1. Modify the applicationContext.xml file as follows: • To set serverDataSource to the datasource name on which MFC is configured, add the following under connectionProperties tag.
-
5 Getting Started with Spring This chapter explains how to develop a web application using Spring. It describes the steps to build a basic employee management system on your Windows system and deploy it on your NonStop system. Prerequisites Before getting started, make sure that you have the requisite software installed on your NonStop and Windows system.
-
Developing EmpInfo on Windows using the Eclipse IDE NOTE: • This section describes the steps to develop EmpInfo using the Eclipse Integrated Development Environment (IDE). It is not mandatory to use the Eclipse IDE; you can choose any IDE that supports Java. • The Eclipse version used in this example is 3.3.1.1. The sample screen shots provided in this section are based on Eclipse IDE version 3.3.1.1. If you are using a different version of Eclipse, the screen shots may look different.
-
Figure 5-2 Eclipse SDK Welcome Screen Close the welcome screen. The workspace is created. After the workspace is created, complete the following activities to develop the EmpInfo application using the Eclipse IDE: 1. 2. 3. 4. 5.
-
1. Click File> New> Project. The New Project dialog box appears. 2. From the list of folders, select Web > Dynamic Web Project and click Next. Figure 5-3 shows the New Project Wizard dialog box. Figure 5-3 New Project Wizard Dialog Box The New Dynamic Web Project dialog box appears. 3. In the Project name field, enter EmpInfo and click Next. NOTE: The other fields in the New Dynamic Web Project dialog box are selected by default. Figure 5-4 shows the New Dynamic Web Project dialog box.
-
Figure 5-4 New Dynamic Web Project Dialog Box 4. Confirm that the Java version set for your project is 5.0 or later. If the version is not set to 5.0 or later, select Java from the Project Facet list. Then select 5.0 or later from the version list and click Finish. NOTE: The Java version used in this example is 5.0. Figure 5-5 shows the New Dynamic Web Project: Project Facets.
-
Figure 5-5 New Dynamic Web: Project Facets When prompted, change the perspective to Java EE and click Yes to open the new perspective. NOTE: The perspective should be changed to Java EE because the Dynamic Web Project is associated with the Java EE perspective. The Project Structure appears. 5. In the Project Structure, confirm that the JRE System Library is set to JRE version 1.5 or later, as shown in Figure 5-6. If the JRE version is not set to 1.5, right-click JRE System Library to select JRE 1.
-
Figure 5-6 Project Explorer View Creating the index.jsp File Create the index.jsp file in the EmpInfo/WebContent directory. This JSP page is the entry point EmpInfo. To create the index.jsp file, complete the following steps: 1. On the Project Explorer frame, right-click EmpInfo and select New > Other. The New File dialog box appears. 2. From the list of folders, select Web > JSP and click Next. Figure 5-7 shows the New File dialog box.
-
Figure 5-7 New File Dialog Box The New JavaServer Page dialog box appears. 3. In the File name field, enter index and ensure that the parent folder is set to EmpInfo/WebContent. Click Next. Figure 5-8 shows the New JavaServer Page dialog box.
-
Figure 5-8 New JavaServer Page Dialog Box The New JavaServer Page: JSP Template dialog box appears. 4. From the Select JSP Template dialog box, select New JSP File (html) and click Finish. NOTE: The Use JSP Template check box is selected by default. Figure 5-9 shows the New JavaServer Page: JSP Template dialog box.
-
Figure 5-9 New JavaServer Page: JSP Template Dialog Box The template for the index.jsp file is generated. Modifying the index.jsp File To modify the index.jsp file, complete the following step: • Modify the EmpInfo/WebContent/index.jsp file to add a header item. Add as the title tag, as the header item and within the body tag of the EmpInfo/WebContent/index.
-
This is EmpInfo Test Page.