HP Integrity NonStop J-Series User Manual
Page 82
![background image](/manuals/397993/82/background.png)
Creating Test class to Test the RMI service
1.
Create a com.hp.empinfo.domain package and an RmiClientTest class under it, as
described in
“Creating the Controller for EmpInfo” (page 54)
2.
Modify the RmiClientTest.java file to invoke the RMI service by adding the following
code:
package com.hp.empinfo.domain;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.hp.empinfo.service.EmployeeInfo;
public class RmiClientTest {
public static String [] configFileNames = new String [] {"applicationContext.xml","clientContext.xml"};
private static ApplicationContext applicationContext = null;
public static void main(String[] args) {
applicationContext = new ClassPathXmlApplicationContext(configFileNames);
EmployeeInfo empInfo = (EmployeeInfo)applicationContext.getBean("rmiProxy");
Employee employee = empInfo.getEmployee(2);
System.out.println("Employee First Name : "+employee.getFirstname());
System.out.println("Employee Last Name : "+employee.getLastname());
System.out.println("Employee Email : "+employee.getEmail());
System.out.println("Employee Id : "+employee.getEmpid());
}
}
Creating the clientContext.xml file
1.
Create the clientContext.xml file in the EmpInfo/WebContent/WEB-INF/ directory,
as described in
“Creating the EmpInfo-servlet.xml File” (page 48)
2.
Modify the clientContext.xml file to add the RMI client bean. After modification, the
clientContext.xml
file must appear as follows:
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
Creating the client.properties file
1.
Create the client.properties file in the EmpInfo/WebContent/WEB-INF/ directory,
as described in
“Creating the jdbc.properties File” (page 66)
.
2.
Modify the client.properties file to add the NonStop System IP address (where your
RMI service is running) and the RMI port number.
serverName=
rmiPort=
Adding Dependency JARs
Add the following dependency jars to the EmpInfo project library:
82
Spring Framework