HP Integrity NonStop J-Series User Manual
Page 125

<property name="serviceInterface" value="com.hp.empinfo.service.EmployeeInfo"/>
<property name="serviceName" value="empDetail"/>
<property name="registryPort" value="1099"/>
</bean>
Creating Test class to Test the RMI service
To create the test class that can be used to test the RMI Service, complete the following steps:
1.
Create a com.hp.empinfo.domain package and an RmiClientTest class under the
com.hp.empinfo.domain
package, as described in
“Creating the Controller for EmpInfo”
.
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
To create the clientContext.xml file, complete the following steps:
1.
Create the clientContext.xml file in the EmpInfo/WebContent/WEB-INF/ directory,
as described in
“Creating the EmpInfo-servlet.xml File” (page 86)
2.
Modify the clientContext.xml file to add the RMI client bean. After modification, the
clientContext.xml
file must appear as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<!-- Resolves ${...} placeholders from client.properties -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location"><value>classpath:client.properties</value></property>
</bean>
<bean id="rmiProxy" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl">
<value>rmi://${serverName}:${rmiPort}/empDetail</value>
</property>
<property name="serviceInterface">
<value>com.hp.empinfo.service.EmployeeInfo</value>
</property>
</bean>
</beans>
Creating the client.properties file
To create the client.properties file, complete the following steps:
1.
Create the client.properties file in the EmpInfo/WebContent/WEB-INF/ directory,
as described in
“Creating the jdbc.properties File” (page 107)
.
Overview of EmpInfo
125