当前位置: 首页>>代码示例>>Java>>正文


Java User类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:18,代码来源:RestClient.java

示例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);
    }
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:14,代码来源:UserRestServiceImpl.java

示例3: registerUser

import com.alibaba.dubbo.demolite.user.User; //导入依赖的package包/类
@Override
public RegistrationResult registerUser(User user) {
    return new RegistrationResult(userService.registerUser(user));
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:5,代码来源:UserRestServiceImpl.java

示例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*/) ;
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:4,代码来源:UserRestService.java

示例5: registerUser

import com.alibaba.dubbo.demolite.user.User; //导入依赖的package包/类
@POST
@Path("register")
RegistrationResult registerUser(User user);
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:4,代码来源:UserRestService.java

示例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;
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:6,代码来源:SerializationOptimizerImpl.java

示例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));
    }
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:9,代码来源:DemoAction.java


注:本文中的com.alibaba.dubbo.demolite.user.User类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。