Skip to content

Commit

Permalink
dubbo泛化测试
Browse files Browse the repository at this point in the history
  • Loading branch information
goodluckwgw committed Dec 29, 2015
1 parent 4ab20ed commit d243773
Show file tree
Hide file tree
Showing 20 changed files with 416 additions and 0 deletions.
22 changes: 22 additions & 0 deletions boot-api/src/main/java/com/github/bootapi/api/DemoService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
*
*/
package com.github.bootapi.api;

import java.util.List;

import com.github.bootapi.dto.UserDto;

/** <p>Title: DemoService</p>
* <p>Description: </p>
* <p>Company: chinasi</p>
* @author wgw
* @date 2015-12-29 下午5:07:27
*/
public interface DemoService {

String sayName(String name);

List<UserDto> getUsers(List<UserDto> users);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.github.bootapi.common;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

/**
* Created with IntelliJ IDEA.
*
* @author <a href="mailto:[email protected]">Xie Gengcai</a>
* @version 1.0
* @date Jan 6, 2015
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "response")
public class CommonRopResponse {
@XmlAttribute
private boolean successful = false;

public static final CommonRopResponse SUCCESSFUL_RESPONSE = new CommonRopResponse(true);
public static final CommonRopResponse FAILURE_RESPONSE = new CommonRopResponse(false);

public CommonRopResponse() {
}

private CommonRopResponse(boolean successful) {
this.successful = successful;
}

public boolean isSuccessful() {
return successful;
}
}
49 changes: 49 additions & 0 deletions boot-api/src/main/java/com/github/bootapi/common/IceResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.github.bootapi.common;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "response")
public class IceResponse<T>
{

@XmlElement
private T result;

@XmlElement
private String code;

public IceResponse()
{
super();
}

public IceResponse(T result, String code)
{
super();
this.result = result;
this.code = code;
}

public Object getResult()
{
return result;
}

public void setResult(T result)
{
this.result = result;
}

public String getCode() {
return code;
}

public void setCode(String code) {
this.code = code;
}

}
50 changes: 50 additions & 0 deletions boot-api/src/main/java/com/github/bootapi/dto/UserDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.github.bootapi.dto;

import java.io.Serializable;

/**
* User
*
*/
public class UserDto implements Serializable {

private static final long serialVersionUID = 1L;

private String name;

public UserDto() {
}

public UserDto(String name) {
this.name = name;
}

public String getName() {
return name;
}

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

@Override
public int hashCode() {
return name == null ? -1 : name.hashCode();
}

@Override
public boolean equals(Object obj) {
if (!(obj instanceof UserDto)) {
return false;
}
UserDto other = (UserDto) obj;
if (this == other) {
return true;
}
if (name != null && other.name != null) {
return name.equals(other.name);
}
return false;
}

}
46 changes: 46 additions & 0 deletions boot-api/src/main/java/com/github/bootapi/exception/ErrorType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.github.bootapi.exception;

/**
* 错误类型,暂时先这么干了
* @date 2014-06-01
*/
public abstract class ErrorType {

public final static String noError = "0";
/**方法或版本找不到*/
public final static String methodError = "1";

/**时间戳错误*/
public final static String timestampError = "2";

/**方法已经被废弃*/
public final static String obsoletedError = "3";

/**post get 不支持*/
public final static String actionError = "4";

/**appKey不存在*/
public final static String appKeyError = "5";

/**会话超时*/
public final static String sessionError = "6";

/**签名错误*/
public final static String signError = "7";

/**参数不合法*/
public final static String parametersError = "8";

/**超出资源最大服务*/
public final static String maxSourcesError = "9";

/**执行超时*/
public final static String timeoutError = "10";

/**执行错误*/
public final static String executeError = "11";

/**异步执行错误*/
public final static String AsyncError="12";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

package com.github.bootapi.exception;

import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

/**
* <pre>
* 功能说明:
* </pre>
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "response")
public class IceErrorResponse {

@XmlElement
private String code;

@XmlElement
private String message;

@XmlElementWrapper(name = "solutions")
@XmlElement(name = "solution")
private List<String> solutions;

public String getCode() {
return code;
}

public void setCode(String code) {
this.code = code;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public List<String> getSolutions() {
return solutions;
}

public void setSolutions(List<String> solutions) {
this.solutions = solutions;
}





}

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.bootapi.exception;

/**
* ice异常
*
* @author <a href="mailto:[email protected]">Xie Gengcai</a>
* @version 1.0
*/
public class IceException extends RuntimeException {

private static final long serialVersionUID = 4380345178425283103L;

public IceException() {
}

public IceException(String message) {
super(message);
}

public IceException(String message, Throwable cause) {
super(message, cause);
}

public IceException(Throwable cause) {
super(cause);
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.github.bootimpl.manager;

import java.util.List;

import com.github.bootapi.api.DemoService;
import com.github.bootapi.dto.UserDto;



/**
* DemoServiceImpl
*
*/
public class DemoServiceImpl implements DemoService {

public String sayName(String name) {
return "say:" + name;
}

@Override
public List<UserDto> getUsers(List<UserDto> users) {
return users;
}


}
45 changes: 45 additions & 0 deletions boot-impl/src/test/java/com/github/bootimpl/test/TestGeneric.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
*
*/
package com.github.bootimpl.test;

import java.io.IOException;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.ServiceConfig;
import com.github.bootapi.api.DemoService;
import com.github.bootimpl.manager.DemoServiceImpl;

/** <p>Title: TestGeneric</p>
* <p>Description: </p>
* <p>Company: chinasi</p>
* @author wgw
* @date 2015-12-29 下午5:10:04
*/
public class TestGeneric {

/**
* TODO
* @param args
* void
*/
public static void main(String[] args) {

ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
service.setApplication(new ApplicationConfig("generic-provider"));
service.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));
service.setProtocol(new ProtocolConfig("dubbo", 29581));
service.setInterface(DemoService.class.getName());
service.setRef(new DemoServiceImpl());
service.export();
try {
System.in.read();
} catch (IOException e) {
e.printStackTrace();
}

}

}
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit d243773

Please sign in to comment.