本文整理汇总了Java中com.alibaba.dubbo.demolite.user.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
User类属于com.alibaba.dubbo.demolite.user包,在下文中一共展示了User类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerUser
import com.alibaba.dubbo.demolite.user.User; //导入依赖的package包/类
private static void registerUser(String url, MediaType mediaType) {
System.out.println("Registering user via " + url);
User user = new User(1L, "larrypage");
Client client = ClientBuilder.newClient();
WebTarget target = client.target(url);
Response response = target.request().post(Entity.entity(user, mediaType));
try {
if (response.getStatus() != 200) {
throw new RuntimeException("Failed with HTTP error code : " + response.getStatus());
}
System.out.println("Successfully got result: " + response.readEntity(String.class));
} finally {
response.close();
client.close();
}
}
示例2: getUser
import com.alibaba.dubbo.demolite.user.User; //导入依赖的package包/类
@Override
public User getUser(@Min(value = 1L, message = "User ID must be greater than 1") @PathParam("id") Long id) {
// test context injection
// System.out.println("Client address from @Context injection: " + (request != null ? request.getRemoteAddr() : ""));
// System.out.println("Client address from RpcContext: " + RpcContext.getContext().getRemoteAddressString());
if (RpcContext.getContext().getRequest(HttpServletRequest.class) != null) {
System.out.println("Client IP address from RpcContext: " + RpcContext.getContext().getRequest(HttpServletRequest.class).getRemoteAddr());
}
if (RpcContext.getContext().getResponse(HttpServletResponse.class) != null) {
System.out.println("Response object from RpcContext: " + RpcContext.getContext().getResponse(HttpServletResponse.class));
}
return userService.getUser(id);
}
示例3: registerUser
import com.alibaba.dubbo.demolite.user.User; //导入依赖的package包/类
@Override
public RegistrationResult registerUser(User user) {
return new RegistrationResult(userService.registerUser(user));
}
示例4: getUser
import com.alibaba.dubbo.demolite.user.User; //导入依赖的package包/类
@GET
@Path("{id : \\d+}")
public User getUser(@Min(value=1L, message="User ID must be greater than 1") @PathParam("id") Long id/*, @Context HttpServletRequest request*/) ;
示例5: registerUser
import com.alibaba.dubbo.demolite.user.User; //导入依赖的package包/类
@POST
@Path("register")
RegistrationResult registerUser(User user);
示例6: getSerializableClasses
import com.alibaba.dubbo.demolite.user.User; //导入依赖的package包/类
public Collection<Class> getSerializableClasses() {
List<Class> classes = new LinkedList<Class>();
classes.add(User.class);
return classes;
}
示例7: start
import com.alibaba.dubbo.demolite.user.User; //导入依赖的package包/类
public void start() throws Exception {
User user = new User(1L, "larrypage");
System.out.println("SUCESS: registered user with id " + userRestService.registerUser(user).getId());
System.out.println("SUCESS: got user " + userService.getUser(1L));
}