您的位置:首页 > 运维架构 > Linux

CentOS5.5下DNS配置(初级篇)

2011-12-15 21:13 225 查看
hessian和burlap使用同一公司的产品实现机制不同,但是他们的配置一样所以在仅仅提供代码参考,

具体上一节spring和burlap的远程服务的整合的应用
 
服务端接口
package cn.com.huawei.hessian.service;
import java.util.List;
public interface IUserService {
  public List getUsernames();
}
服务端接口的实现
package cn.com.huawei.hessian.service.impl;
import java.util.ArrayList;
import java.util.List;
import cn.com.huawei.hessian.service.IUserService;
public class UserService  implements  IUserService{
   public List getUsernames()
   {
     List<String> usernames=new ArrayList<String>();
     usernames.add("xiaobai");
     usernames.add("xiaoli");
     return usernames;
   }
}
 
服务端的web。xml的配置信息
 
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext.xml</param-value>
 </context-param>
 <listener>
  <listener-class>
   org.springframework.web.context.ContextLoaderListener
  </listener-class>
 </listener>
 <servlet>
  <servlet-name>remoting</servlet-name>
  <servlet-class>
   org.springframework.web.servlet.DispatcherServlet
  </servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>remoting</servlet-name>
  <url-pattern>/remoting/*</url-pattern>
 </servlet-mapping>
 <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
</web-app>
applicationContext。xml的配置信息
<?xml version="1.0" encoding="UTF-8"?>
<beans
 xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
     
       <bean id="userservicetarget" class="cn.com.huawei.hessian.service.impl.UserService"/>
</beans>
 
 
remoting-servlet。xml的配置信息如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans
 xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
  
   
  
 
  <bean name="/Userservice-hessina" class="org.springframework.remoting.caucho.HessianServiceExporter">
    <property name="service">
      <ref bean="userservicetarget"/>
    </property>
    <property name="serviceInterface">
      <value>cn.com.huawei.hessian.service.IUserService</value>
    </property>
  </bean>
</beans>
 
关于客户端信息如下:
 
 
client.properties属性文件的信息
# Properties file with server URL settings for remote access.
# Applied by PropertyPlaceholderConfigurer from "clientContext.xml".
serverName=localhost
httpPort=8080
rmiPort=1099
serverPath=SpringHessian
contextPath=remoting/Userservice-hessina
 
spring和hessian的配置信息
<?xml version="1.0" encoding="UTF-8"?>
<beans
 xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      <property name="location"><value>client.properties</value></property>
 </bean>
    <bean id="hessinaclient" class="cn.com.huawei.hessian.client.HessinaClient">
      <property name="userservice">
         <ref local="proxyuserservice" />
      </property>
    </bean>
   <bean id="proxyuserservice" class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
        <property name="serviceUrl">
          <value>http://${serverName}:${httpPort}/${serverPath}/${contextPath}</value>
        </property>
    <property name="serviceInterface">
      <value>cn.com.huawei.hessian.service.IUserService</value>
    </property>
  </bean>
</beans>
 
客户端测试代码应用
package cn.com.huawei.hessian.client;
import java.util.List;
import cn.com.huawei.hessian.service.IUserService;
public class HessinaClient {
 private IUserService userservice;
 public IUserService getUserservice() {
  return userservice;
 }
 public void setUserservice(IUserService userservice) {
  this.userservice = userservice;
 }
 public List getUsernames() {
  return this.userservice.getUsernames();
 }
}
 
package cn.com.huawei.hessian.client;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class HessianTest {
 public static void main(String[] args) {
  ApplicationContext ctx = new ClassPathXmlApplicationContext(
    "applicationContext.xml");
  HessinaClient hessina = (HessinaClient) ctx.getBean("hessinaclient");
  System.out.println("hessinaclient:" + hessina.getUsernames());
 }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: