Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
55 changed files
with
2,556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -20,3 +20,4 @@ target | ||
codecov.json | ||
.DS_Store | ||
doc | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
## Start | ||
|
||
#### Step1 | ||
|
||
Generate Java facade | ||
|
||
``` | ||
cd dubboservice | ||
mvn install | ||
``` | ||
|
||
#### Step2 | ||
|
||
Generate Erlang lib by erlanalysis tool. | ||
|
||
``` | ||
java -cp erlanalysis-1.0.jar com.ifcoder.dubboerl.analysis.ParserStart com.ifcoder.demo dubbo-service 1.2 | ||
``` | ||
|
||
#### Step3 | ||
|
||
cp dubbo-service erlang lib to dubboerl_demo | ||
|
||
#### Stpe4 | ||
|
||
``` | ||
cd dubboerl_demo | ||
rebar3 shell --apps "dubboerl_demo" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?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.apache.dubbo.erlang</groupId> | ||
<artifactId>dubbo-sample-service</artifactId> | ||
<version>1.3</version> | ||
|
||
<name>dubbo-sample-service</name> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.11</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
<version>1.1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>dubbo</artifactId> | ||
<version>2.5.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.javassist</groupId> | ||
<artifactId>javassist</artifactId> | ||
<version>3.18.1-GA</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
<version>1.2.15</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>com.sun.jdmk</groupId> | ||
<artifactId>jmxtools</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>com.sun.jmx</groupId> | ||
<artifactId>jmxri</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>jms</artifactId> | ||
<groupId>javax.jms</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>mail</artifactId> | ||
<groupId>javax.mail</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring</artifactId> | ||
<version>2.5.6.SEC03</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>1.7.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
<version>1.2.9</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<version>1.6.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.101tec</groupId> | ||
<artifactId>zkclient</artifactId> | ||
<version>0.4</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</plugin> | ||
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.7.0</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.20.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-install-plugin</artifactId> | ||
<version>2.5.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>2.8.2</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.apache.dubbo.erlang.sample.service; | ||
|
||
import org.apache.dubbo.erlang.sample.service.bean.UserInfo; | ||
import org.apache.dubbo.erlang.sample.service.facade.UserOperator; | ||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Hello world! | ||
* | ||
*/ | ||
public class App | ||
{ | ||
public static void main( String[] args ) throws IOException { | ||
System.out.println("将要监听服务"); | ||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( | ||
new String[] { "applicationProvider.xml" }); | ||
context.start(); | ||
UserOperator userOperator = (UserOperator) context.getBean("userInterface"); | ||
UserInfo result = userOperator.getUserInfo("hh-bb"); | ||
System.out.println("result:" + result.getUserName()); | ||
|
||
System.out.println("按任意键退出"); | ||
System.in.read(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.apache.dubbo.erlang.sample.service; | ||
|
||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Created by dlive on 2018/9/12. | ||
*/ | ||
public class AppListMain { | ||
|
||
public static void main( String[] args ) throws IOException { | ||
System.out.println("将要监听服务"); | ||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( | ||
new String[] { "applicationProvider.xml" }); | ||
context.start(); | ||
// UserOperator user = (UserOperator) context.getBean("userInterface"); | ||
// UserRes result = user.queryUserList("listquery"); | ||
// System.out.println("result:" + result.getUserlist().get(0).getUserName()); | ||
|
||
System.out.println("按任意键退出"); | ||
System.in.read(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.apache.dubbo.erlang.sample.service.bean; | ||
|
||
import java.io.Serializable; | ||
|
||
public class UserInfo implements Serializable { | ||
|
||
private String userId; | ||
private String userName; | ||
private Integer userAge; | ||
|
||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
public void setUserId(String userId) { | ||
this.userId = userId; | ||
} | ||
|
||
public String getUserName() { | ||
return userName; | ||
} | ||
|
||
public void setUserName(String userName) { | ||
this.userName = userName; | ||
} | ||
|
||
public Integer getUserAge() { | ||
return userAge; | ||
} | ||
|
||
public void setUserAge(Integer userAge) { | ||
this.userAge = userAge; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.apache.dubbo.erlang.sample.service.bean; | ||
|
||
/** | ||
* Created by dlive on 2018/9/12. | ||
*/ | ||
public class UserInfoRequest { | ||
public String requestId; | ||
public String username; | ||
|
||
public void setRequestId(String requestId) { | ||
this.requestId = requestId; | ||
} | ||
|
||
public String getRequestId() { | ||
return requestId; | ||
} | ||
|
||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.apache.dubbo.erlang.sample.service.bean; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by dlive on 2018/9/12. | ||
*/ | ||
public class UserRes { | ||
private String message; | ||
private Integer code; | ||
private List<UserInfo> userlist; | ||
|
||
public List<UserInfo> getUserlist() { | ||
return userlist; | ||
} | ||
|
||
public void setUserlist(List<UserInfo> userlist) { | ||
this.userlist = userlist; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.apache.dubbo.erlang.sample.service.facade; | ||
|
||
import org.apache.dubbo.erlang.sample.service.bean.UserInfo; | ||
import org.apache.dubbo.erlang.sample.service.bean.UserInfoRequest; | ||
import org.apache.dubbo.erlang.sample.service.bean.UserRes; | ||
|
||
public interface UserOperator { | ||
public String genUserId(); | ||
public UserInfo getUserInfo(String userid); | ||
public UserInfo queryUserInfo(UserInfoRequest request); | ||
public UserRes queryUserList(String info); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.apache.dubbo.erlang.sample.service.impl; | ||
|
||
import org.apache.dubbo.erlang.sample.service.bean.UserInfo; | ||
import org.apache.dubbo.erlang.sample.service.bean.UserInfoRequest; | ||
import org.apache.dubbo.erlang.sample.service.bean.UserRes; | ||
import org.apache.dubbo.erlang.sample.service.facade.UserOperator; | ||
|
||
public class UserOperatorImpl implements UserOperator { | ||
|
||
@Override | ||
public String genUserId() { | ||
return "userid-123"; | ||
} | ||
|
||
@Override | ||
public UserInfo getUserInfo(String userid) { | ||
UserInfo info = new UserInfo(); | ||
info.setUserAge(10); | ||
info.setUserId("1"); | ||
info.setUserName("testname"); | ||
return info; | ||
} | ||
|
||
@Override | ||
public UserInfo queryUserInfo(UserInfoRequest request) { | ||
|
||
System.out.println("request:"+request.getRequestId()); | ||
UserInfo info = new UserInfo(); | ||
info.setUserAge(99); | ||
info.setUserId("id123"); | ||
info.setUserName("中文姓名"); | ||
return info; | ||
} | ||
|
||
@Override | ||
public UserRes queryUserList(String info) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?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:application name="hello-world" /><!-- 注册地址 --> | ||
<dubbo:registry address="zookeeper://127.0.0.1:2181" /> | ||
<dubbo:protocol name="dubbo" port="20880" /> | ||
|
||
|
||
|
||
<dubbo:consumer check="false" timeout="300000" id="dubboConsumerConfig" retries="0"/> | ||
|
||
<bean id="userService" class="org.apache.dubbo.erlang.sample.service.impl.UserOperatorImpl" /> | ||
<dubbo:service interface="org.apache.dubbo.erlang.sample.service.facade.UserOperator" ref="userService"/> | ||
|
||
<!-- <dubbo:reference id="userInterface" interface="UserOperator" retries="0" />--> | ||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
log4j.rootLogger=DEBUG,console | ||
|
||
log4j.appender.console=org.apache.log4j.ConsoleAppender | ||
log4j.appender.console.Threshold=DEBUG | ||
#log4j.appender.console.ImmediateFlush=true | ||
#log4j.appender.console.Target=System.err | ||
log4j.appender.console.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.console.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} [%c]-[%p] %m%n |
Oops, something went wrong.