Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
springCat committed May 8, 2016
0 parents commit 946ae65
Show file tree
Hide file tree
Showing 11 changed files with 351 additions and 0 deletions.
51 changes: 51 additions & 0 deletions dubbo_customer/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.springcat</groupId>
<artifactId>dubbo_customer</artifactId>
<version>1.0-SNAPSHOT</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RELEASE</version>
</parent>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!--dubbo-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<artifactId>spring</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>

<!--zkclient-->
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>0.1</version>
</dependency>

<dependency>
<groupId>org.springcat</groupId>
<artifactId>dubbo_interface</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.springcat.cutomer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
* Created by springcat on 16/5/6.
*/
@EnableWebMvc
@SpringBootApplication
@ImportResource("classpath:/spring/dubbo.xml")
public class Application extends WebMvcConfigurerAdapter {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.springcat.cutomer;

import com.alibaba.dubbo.config.annotation.Reference;
import org.springcat.api.DemoService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* Created by springcat on 16/5/6.
*/
@RestController
@RequestMapping(value = "/")
public class DemoController {

@Reference
private DemoService demoService;

@RequestMapping(value = "hello")
public String hello(){
return demoService.sayHello("111");
}

@RequestMapping(value = "users")
public List users(){
return demoService.getUsers();
}

}
27 changes: 27 additions & 0 deletions dubbo_customer/src/main/resources/spring/dubbo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
">


<!-- 配置注解 end -->

<!-- 提供方应用信息,用于计算依赖关系 -->
<dubbo:application name="customer" />

<!-- 使用multicast广播注册中心暴露服务地址 -->
<dubbo:registry address="zookeeper://127.0.0.1:2181" client="zkclient" />

<!-- 配置注解 -->
<dubbo:annotation package="org.springcat.cutomer" />


</beans>
12 changes: 12 additions & 0 deletions dubbo_interface/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.springcat</groupId>
<artifactId>dubbo_interface</artifactId>
<version>1.0-SNAPSHOT</version>


</project>
11 changes: 11 additions & 0 deletions dubbo_interface/src/main/java/org/springcat/api/DemoService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.springcat.api;

import java.util.List;

public interface DemoService {

String sayHello(String name);

public List getUsers();

}
36 changes: 36 additions & 0 deletions dubbo_interface/src/main/java/org/springcat/api/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.springcat.api;

import java.io.Serializable;

/**
* Created by springcat on 16/3/16.
*/
public class User implements Serializable{
private String name;
private int age;
private String sex;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public String getSex() {
return sex;
}

public void setSex(String sex) {
this.sex = sex;
}
}
74 changes: 74 additions & 0 deletions dubbo_provider/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.springcat</groupId>
<artifactId>dubbo_provider</artifactId>
<version>1.0-SNAPSHOT</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RELEASE</version>
</parent>

<dependencies>

<!--<dependency>-->
<!--<groupId>com.wacai</groupId>-->
<!--<artifactId>spring-boot-starter-dubbo</artifactId>-->
<!--<version>1.0.3-SNAPSHOT</version>-->
<!--</dependency>-->

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!--dubbo-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<artifactId>spring</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>

<!--zkclient-->
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>0.1</version>
</dependency>

<!-- Netty -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>4.0.0.Alpha8</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.0.0.Alpha8</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
<version>4.0.0.Alpha8</version>
</dependency>

<dependency>
<groupId>org.springcat</groupId>
<artifactId>dubbo_interface</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.springcat.provider;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;

/**
* Created by springcat on 16/5/6.
*/
@SpringBootApplication
@ImportResource("classpath:spring/dubbo.xml")
public class Application {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
while(true){

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.springcat.provider;

import com.alibaba.dubbo.config.annotation.Service;
import org.springcat.api.DemoService;
import org.springcat.api.User;

import java.util.ArrayList;
import java.util.List;

/**
* Created by springcat on 16/5/6.
*/
@Service
public class DemoServiceImpl implements DemoService {

@Override
public String sayHello(String s) {
return "hello " + s;
}

@Override
public List getUsers() {
List<User> userList = new ArrayList<User>();

User u1 = new User();
u1.setAge(11);
u1.setName("11");
u1.setSex("男");


User u2 = new User();
u2.setAge(22);
u2.setName("22");
u2.setSex("女");

userList.add(u1);
userList.add(u2);

return userList;
}
}
28 changes: 28 additions & 0 deletions dubbo_provider/src/main/resources/spring/dubbo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"
default-lazy-init="true">
<!-- 提供方应用信息,用于计算依赖关系 -->
<dubbo:application name="provider" />

<!-- 扫描注解包路径,多个包用逗号分隔,不填pacakge表示扫描当前ApplicationContext中所有的类 -->
<dubbo:annotation package="org.springcat.provider" />


<!-- 使用multicast广播注册中心暴露服务地址 -->
<dubbo:registry address="zookeeper://127.0.0.1:2181" />

<!-- 用dubbo协议在20880端口暴露服务 -->
<dubbo:protocol name="dubbo" port="20880" />


</beans>

0 comments on commit 946ae65

Please sign in to comment.