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


Java User类代码示例

本文整理汇总了Java中com.alibaba.dubbo.demo.user.User的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


User类属于com.alibaba.dubbo.demo.user包,在下文中一共展示了User类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerUser

import com.alibaba.dubbo.demo.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:zhuxiaolei,项目名称:dubbo2,代码行数:18,代码来源:RestClient.java

示例2: registerUser

import com.alibaba.dubbo.demo.user.User; //导入依赖的package包/类
private static void registerUser(String url, MediaType mediaType) {
    System.out.println("Registering user via " + url);
    User user = new User(1L, "dang");
    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:lsjiguang,项目名称:dangdangdotcom,代码行数:18,代码来源:RestClient.java

示例3: getUser

import com.alibaba.dubbo.demo.user.User; //导入依赖的package包/类
@GET
    @Path("{id : \\d+}")
    public User getUser(@PathParam("id") Long id/*, @Context HttpServletRequest request*/) {
        // 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,代码行数:15,代码来源:UserRestServiceImpl.java

示例4: getUser

import com.alibaba.dubbo.demo.user.User; //导入依赖的package包/类
@GET
    @Path("{id : \\d+}")
    public User getUser(@PathParam("id") Long id/*, @Context HttpServletRequest request*/) {
        // 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());
        return userService.getUser(id);
    }
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:9,代码来源:AnnotationDrivenUserRestServiceImpl.java

示例5: getSerializableClasses

import com.alibaba.dubbo.demo.user.User; //导入依赖的package包/类
public Collection<Class> getSerializableClasses() {
    List<Class> classes = new LinkedList<Class>();
    classes.add(BidRequest.class);
    classes.add(BidResponse.class);
    classes.add(Device.class);
    classes.add(Geo.class);
    classes.add(Impression.class);
    classes.add(SeatBid.class);
    classes.add(User.class);
    return classes;
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:12,代码来源:SerializationOptimizerImpl.java

示例6: getSerializableClasses

import com.alibaba.dubbo.demo.user.User; //导入依赖的package包/类
public Collection<Class> getSerializableClasses() {
    List<Class> classes = new LinkedList<Class>();
    classes.add(BidRequest.class);
    classes.add(BidResponse.class);
    classes.add(Device.class);
    classes.add(Geo.class);
    classes.add(Impression.class);
    classes.add(SeatBid.class);
    classes.add(User.class);
    classes.add(ResultJSON.class);
    return classes;
}
 
开发者ID:KevinMyDing,项目名称:LetUsGo-Server,代码行数:13,代码来源:SerializationOptimizerImpl.java

示例7: getUser

import com.alibaba.dubbo.demo.user.User; //导入依赖的package包/类
public User getUser(Long id) {
    System.out.println("Client name is " + RpcContext.getContext().getAttachment("clientName"));
    System.out.println("Client impl is " + RpcContext.getContext().getAttachment("clientImpl"));
    return userService.getUser(id);
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:6,代码来源:AnotherUserRestServiceImpl.java

示例8: registerUser

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

示例9: registerUser

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

示例10: getUser

import com.alibaba.dubbo.demo.user.User; //导入依赖的package包/类
@GET
@Path("{id : \\d+}")
User getUser(@PathParam("id") @Min(1L) Long id);
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:4,代码来源:AnotherUserRestService.java

示例11: registerUser

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

示例12: start

import com.alibaba.dubbo.demo.user.User; //导入依赖的package包/类
public void start() throws Exception {
        BidRequest request = new BidRequest();

        Impression imp = new Impression();
        imp.setBidFloor(1.1);
        imp.setId("abc");
        List<Impression> imps = new ArrayList<Impression>(1);
        imps.add(imp);
        request.setImpressions(imps);

        Geo geo = new Geo();
        geo.setCity("beijing");
        geo.setCountry("china");
        geo.setLat(100.1f);
        geo.setLon(100.1f);

        Device device = new Device();
        device.setMake("apple");
        device.setOs("ios");
        device.setVersion("7.0");
        device.setLang("zh_CN");
        device.setModel("iphone");
        device.setGeo(geo);
        request.setDevice(device);

//        long start = System.currentTimeMillis();

//        for (int i = 0; i < 10000; i ++) {
//        System.out.println(bidService.bid(request).getId());
        System.out.println("SUCCESS: got bid response id: " + bidService.bid(request).getId());
//        }

//        System.out.println(">>>>> Total time consumed:" + (System.currentTimeMillis() - start));

        try {
            bidService.throwNPE();
            System.out.println("ERROR: no exception found");
        } catch (NullPointerException e) {
            System.out.println("SUCCESS: caught exception " + e.getClass());
        }

        User user = new User(1L, "larrypage");
        System.out.println("SUCCESS: registered user with id " + anotherUserRestService.registerUser(user).getId());

        RpcContext.getContext().setAttachment("clientName", "demo");
        RpcContext.getContext().setAttachment("clientImpl", "dubbox");
        System.out.println("SUCCESS: got user " + anotherUserRestService.getUser(1L));
    }
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:49,代码来源:DemoAction.java

示例13: start

import com.alibaba.dubbo.demo.user.User; //导入依赖的package包/类
@PostConstruct
    public void start() throws Exception {
        BidRequest request = new BidRequest();

        Impression imp = new Impression();
        imp.setBidFloor(1.1);
        imp.setId("abc");
        List<Impression> imps = new ArrayList<Impression>(1);
        imps.add(imp);
        request.setImpressions(imps);

        Geo geo = new Geo();
        geo.setCity("beijing");
        geo.setCountry("china");
        geo.setLat(100.1f);
        geo.setLon(100.1f);

        Device device = new Device();
        device.setMake("apple");
        device.setOs("ios");
        device.setVersion("7.0");
        device.setLang("zh_CN");
        device.setModel("iphone");
        device.setGeo(geo);
        request.setDevice(device);

//        long start = System.currentTimeMillis();

//        for (int i = 0; i < 10000; i ++) {
//        System.out.println(bidService.bid(request).getId());
        System.out.println("SUCESS: got bid response id: " + bidService.bid(request).getId());
//        }

//        System.out.println(">>>>> Total time consumed:" + (System.currentTimeMillis() - start));

        try {
            bidService.throwNPE();
            System.out.println("ERROR: no exception found");
        } catch (NullPointerException e) {
            System.out.println("SUCCESS: caught exception " + e.getClass());
        }

        User user = new User(1L, "larrypage");
        System.out.println("SUCESS: registered user with id " + anotherUserRestService.registerUser(user).getId());

        System.out.println("SUCESS: got user " + anotherUserRestService.getUser(1L));
    }
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:48,代码来源:DemoJavaConfigAction.java


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