Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update quickstart #12

Merged
merged 1 commit into from
Apr 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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