コード例 #1
0
  public List<Device> getDevices() {
    try {

      Builder obj =
          service
              .path(pathString)
              .path(labBookPath + "/device")
              .accept(MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON);
      IndexBean indexBean =
          FacesContext.getCurrentInstance()
              .getApplication()
              .evaluateExpressionGet(
                  FacesContext.getCurrentInstance(), "#{indexBean}", IndexBean.class);
      Object username = indexBean.getLoginUserName();
      obj.header("username", username);
      DeviceListServiceBean result = obj.get(new GenericType<DeviceListServiceBean>() {});
      List<Device> itemList = result.getDeviceList();
      for (Item it : itemList) {
        string = it.getName();
        System.out.println(string);
      }
      return itemList;
    } catch (Exception e) {
      Logger.getLogger(this.getClass())
          .log(Level.SEVERE, "LabBookToolClient.getDevices() exception occured", e);
    }
    return null;
  }
コード例 #2
0
  public List<Laptop> getLaptops() {
    try {

      Builder obj =
          service
              .path(pathString)
              .path(labBookPath + "/laptop")
              .accept(MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON);
      LaptopListServiceBean result = obj.get(new GenericType<LaptopListServiceBean>() {});

      List<Laptop> laptopList = result.getLaptopList();
      for (Item it : laptopList) {
        string = it.getName();
        System.out.println(string);
      }
      return laptopList;
    } catch (Exception e) {
      Logger.getLogger(this.getClass())
          .log(Level.SEVERE, "LabBookToolClient.getDevices() exception occured", e);
    }
    return new ArrayList<Laptop>();
  }