1. 程式人生 > >Dubbo中Consumer應用介面配置檔案

Dubbo中Consumer應用介面配置檔案

配置檔案

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans 
		http://www.springframework.org/schema/beans/spring-beans.xsd 
		http://code.alibabatech.com/schema/dubbo 
		http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

	<!-- 使用dubbo標籤描述要釋出的服務. -->
	<!-- 任意定義的一個應用名稱. 為dubbo應用命名 -->
	<dubbo:application name="dubbo-consumer"></dubbo:application>
	
	<!-- 提供註冊中心資訊 -->
	<dubbo:registry address="192.168.232.130:2181" protocol="zookeeper" />
	
	<dubbo:reference interface="com.bjsxt.service.FlowerService" id="flowerProvider" />
	
	<bean id="flowerConsumerService" class="com.bjsxt.service.iml.FlowerConsumerServiceImpl">
	
		<property name="flowerService" ref="flowerProvider"></property>
	
	</bean>
	
	
</beans>

業務實現類

package com.bjsxt.service.iml;

import com.bjsxt.pojo.Flower;
import com.bjsxt.service.FlowerConsumerService;
import com.bjsxt.service.FlowerService;


public class FlowerConsumerServiceImpl implements FlowerConsumerService{
	
	private FlowerService flowerService;

	@Override
	public Flower queryFlower(int id) {
		
		Flower haveFlower = flowerService.haveFlower(id);
		return haveFlower;
	}

	public FlowerService getFlowerService() {
		return flowerService;
	}

	public void setFlowerService(FlowerService flowerService) {
		this.flowerService = flowerService;
	}

}