spring-hessian代理、服务那点事

暴露服务:

 @SuppressWarnings("rawtypes")
    private <a target=_blank href="eclipse-open:%E2%98%82=api/C:%5C/Users%5C/Administrator%5C/.gradle%5C/caches%5C/modules-2%5C/files-2.1%5C/org.springframework%5C/spring-web%5C/3.2.8.RELEASE%5C/799ae0503da5a9f980fecd38c9e6b23a71a406c8%5C/spring-web-3.2.8.RELEASE.jar%3Corg.springframework.remoting.caucho(HessianServiceExporter.class%E2%98%83HessianServiceExporter"><img style="BORDER-BOTTOM: medium none; POSITION: absolute; BORDER-LEFT: medium none; WIDTH: 16px; HEIGHT: 16px; BORDER-TOP: medium none; BORDER-RIGHT: medium none; LEFT: -21px" alt="Open Declaration" src="file:/D:/qby/src/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/3.png" /> </a><a target=_blank class="header" href="eclipse-javadoc:%E2%98%82=api/C:%5C/Users%5C/Administrator%5C/.gradle%5C/caches%5C/modules-2%5C/files-2.1%5C/org.springframework%5C/spring-web%5C/3.2.8.RELEASE%5C/799ae0503da5a9f980fecd38c9e6b23a71a406c8%5C/spring-web-3.2.8.RELEASE.jar%3Corg">org</a>.<a target=_blank class="header" href="eclipse-javadoc:%E2%98%82=api/C:%5C/Users%5C/Administrator%5C/.gradle%5C/caches%5C/modules-2%5C/files-2.1%5C/org.springframework%5C/spring-web%5C/3.2.8.RELEASE%5C/799ae0503da5a9f980fecd38c9e6b23a71a406c8%5C/spring-web-3.2.8.RELEASE.jar%3Corg.springframework">springframework</a>.<a target=_blank class="header" href="eclipse-javadoc:%E2%98%82=api/C:%5C/Users%5C/Administrator%5C/.gradle%5C/caches%5C/modules-2%5C/files-2.1%5C/org.springframework%5C/spring-web%5C/3.2.8.RELEASE%5C/799ae0503da5a9f980fecd38c9e6b23a71a406c8%5C/spring-web-3.2.8.RELEASE.jar%3Corg.springframework.remoting">remoting</a>.<a target=_blank class="header" href="eclipse-javadoc:%E2%98%82=api/C:%5C/Users%5C/Administrator%5C/.gradle%5C/caches%5C/modules-2%5C/files-2.1%5C/org.springframework%5C/spring-web%5C/3.2.8.RELEASE%5C/799ae0503da5a9f980fecd38c9e6b23a71a406c8%5C/spring-web-3.2.8.RELEASE.jar%3Corg.springframework.remoting.caucho">caucho</a>.HessianServiceExporter buildHessianServiceExporter(
            Class serviceInterface, Object service) {
        HessianServiceExporter HessianServiceExporter = new HessianServiceExporter();
        HessianServiceExporter.setServiceInterface(serviceInterface);
        HessianServiceExporter.setService(service);
        return HessianServiceExporter;
    }
    @Bean(name = "/helloService ")
    public HessianServiceExporter helloServiceExporter() {
        return buildHessianServiceExporter(HelloService .class, helloService );
    }
    @Autowired
    private HelloService helloService ;


spring-代理hessian-bean

@Bean
    public HessianProxyFactoryBean helloService() {
        return buildHessianProxyFactoryBean(HelloService.class, "helloService");
    }

    @SuppressWarnings("rawtypes")
    private HessianProxyFactoryBean buildHessianProxyFactoryBean(
            Class serviceInterface, String serviceName) {
        HessianProxyFactoryBean factory = new HessianProxyFactoryBean();
        factory.setServiceInterface(serviceInterface);
        factory.setServiceUrl(hessianSererUrl + "/remoting/xxx/"
                + serviceName);
        return factory;
    }

纯java代码代理:

public static void main(String[] args) throws Exception {

        HessianProxyFactory factory = new HessianProxyFactory();
        xxxxx hello = (xxxxxx) factory.create(
                MgtResourceService.class,
                "http://localhost:12080/remoting/xxx/xxxxxx");

        System.out.println(hello.findAll());

    }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值