Skip to content

Commit

Permalink
Merge pull request #12 from fingki/master
Browse files Browse the repository at this point in the history
Update quickstart
  • Loading branch information
qdaxb committed Apr 25, 2016
2 parents ec06ff0 + c1f172b commit cfe21bb
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 63 deletions.
52 changes: 30 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The quick start gives very basic example of running client and server on the sam
> * JDK 1.7 or above
> * A java-based project management software like [Maven][maven] or [Gradle][gradle]
1. Add dependency to pom
1. Add dependencies to pom.

```xml
<dependency>
Expand All @@ -33,7 +33,7 @@ The quick start gives very basic example of running client and server on the sam
<artifactId>motan-transport-netty</artifactId>
<version>0.0.1</version>
</dependency>

<!-- dependencies blow were only needed for spring-based features -->
<dependency>
<groupId>com.weibo</groupId>
Expand All @@ -59,31 +59,22 @@ The quick start gives very basic example of running client and server on the sam
}
```

3. Implement service provider.


`src/main/java/quickstart/FooServiceImpl.java`
3. Write an implementation, create and start RPC Server.

`src/main/java/quickstart/FooServiceImpl.java`

```java
package quickstart;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class FooServiceImpl implements FooService {
public String hello(String name) {

public String hello(String name) {
System.out.println(name + " invoked rpc service");
return "hello " + name;
}

public static void main(String[] args) throws InterruptedException {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:motan_server.xml");
System.out.println("server start...");
}
}
}
```

`src/main/resources/motan_server.xml`

```xml
Expand All @@ -101,9 +92,26 @@ The quick start gives very basic example of running client and server on the sam
</beans>
```

Execute main function in FooServiceImpl will start a motan server listening on port 8002.
`src/main/java/quickstart/Server.java`

```java
package quickstart;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Server {

public static void main(String[] args) throws InterruptedException {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:motan_server.xml");
System.out.println("server start...");
}
}
```

Execute main function in Server will start a motan server listening on port 8002.

4. The service consumer
4. Create and start RPC Client.

`src/main/resources/motan_client.xml`

Expand Down Expand Up @@ -140,7 +148,7 @@ The quick start gives very basic example of running client and server on the sam
```

Execute main function in Client will invoke the remote service and print response.


# Documents

Expand Down
54 changes: 31 additions & 23 deletions docs/wiki/en_quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ The quick start gives very basic example of running server and client on the sam
## <a id="peer-to-peer"></a>Using Motan in single machine environment

1. Add dependency to pom.

1. Add dependencies to pom.

```xml
<dependency>
Expand All @@ -26,7 +27,7 @@ The quick start gives very basic example of running server and client on the sam
<version>0.0.1</version>
</dependency>

<!-- only needed for spring-based features -->
<!-- dependencies blow were only needed for spring-based features -->
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-springsupport</artifactId>
Expand All @@ -51,31 +52,22 @@ The quick start gives very basic example of running server and client on the sam
}
```

3. Implement the service provider.


`src/main/java/quickstart/FooServiceImpl.java`
3. Write an implementation, create and start RPC Server.

`src/main/java/quickstart/FooServiceImpl.java`

```java
package quickstart;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class FooServiceImpl implements FooService {
public String hello(String name) {

public String hello(String name) {
System.out.println(name + " invoked rpc service");
return "hello " + name;
}

public static void main(String[] args) throws InterruptedException {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:motan_server.xml");
System.out.println("server start...");
}
}
}
```

`src/main/resources/motan_server.xml`

```xml
Expand All @@ -93,9 +85,26 @@ The quick start gives very basic example of running server and client on the sam
</beans>
```

Executing main function in FooServiceImpl will start a motan server listening on port 8002.
`src/main/java/quickstart/Server.java`

```java
package quickstart;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Server {

public static void main(String[] args) throws InterruptedException {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:motan_server.xml");
System.out.println("server start...");
}
}
```

Execute main function in Server will start a motan server listening on port 8002.

4. Implement the service consumer.
4. Create and start RPC Client.

`src/main/resources/motan_client.xml`

Expand Down Expand Up @@ -131,8 +140,7 @@ The quick start gives very basic example of running server and client on the sam
}
```

Executing main function in Client will invoke the remote service and print response.

Execute main function in Client will invoke the remote service and print response.

## <a id="cluster"></a>Using Motan in cluster environment

Expand Down
44 changes: 26 additions & 18 deletions docs/wiki/zh_quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
## <a id="peer-to-peer"></a>简单调用示例

1. 在pom中增加依赖
1. 在pom中添加依赖

```xml
<dependency>
Expand All @@ -39,7 +39,7 @@
</dependency>
```

2. 为调用方和服务方创建接口
2. 为调用方和服务方创建公共接口

`src/main/java/quickstart/FooService.java`

Expand All @@ -51,31 +51,22 @@
}
```

3. 实现服务方逻辑。


`src/main/java/quickstart/FooServiceImpl.java`
3. 编写业务接口逻辑、创建并启动RPC Server。

`src/main/java/quickstart/FooServiceImpl.java`

```java
package quickstart;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class FooServiceImpl implements FooService {

public String hello(String name) {
System.out.println(name + " invoked rpc service");
return "hello " + name;
}

public static void main(String[] args) throws InterruptedException {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:motan_server.xml");
System.out.println("server start...");
}
}
```

`src/main/resources/motan_server.xml`

```xml
Expand All @@ -92,10 +83,27 @@
<motan:service interface="quickstart.FooService" ref="serviceImpl" export="8002" />
</beans>
```

`src/main/java/quickstart/Server.java`

```java
package quickstart;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

执行FooServiceImpl类中的main函数将会启动motan服务,并监听8002端口.
public class Server {

public static void main(String[] args) throws InterruptedException {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:motan_server.xml");
System.out.println("server start...");
}
}
```

执行Server类中的main函数将会启动motan服务,并监听8002端口.

4. 实现服务调用方
4. 创建并执行RPC Client

`src/main/resources/motan_client.xml`

Expand Down

0 comments on commit cfe21bb

Please sign in to comment.