Package org.codehaus.jackson.jaxrs

Examples of org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider


    //todo: test element refs of attachment elements.
  }


  protected <T> T processThroughJson(T object) throws Exception {
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();

    File in = File.createTempFile(object.getClass().getName() + "In", ".json", this.tempDir);
    File out = File.createTempFile(object.getClass().getName() + "Out", ".json", this.tempDir);
    FileOutputStream fos = new FileOutputStream(in);
    provider.writeTo(object, null, null, null, null, null, fos);
    fos.close();
    Process process = new ProcessBuilder(this.phpExe, this.exe.getAbsolutePath(), packageToModule(object.getClass().getName()), in.getAbsolutePath(), out.getAbsolutePath())
      .directory(this.exe.getParentFile())
      .redirectErrorStream(true)
      .start();
    BufferedReader procReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
    String line = procReader.readLine();
    while (line != null) {
      System.out.println(line);
      line = procReader.readLine();
    }
    int exitStatus = process.waitFor();
    assertEquals("php process json failed.", 0, exitStatus);

    FileInputStream fis = new FileInputStream(out);
    return (T) provider.readFrom((Class<Object>) object.getClass(), object.getClass(), null, null, null, fis);
  }
View Full Code Here


    //todo: test element refs of attachment elements.
  }


  protected <T> T processThroughJson(T object) throws Exception {
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();

    File in = File.createTempFile(object.getClass().getName() + "In", ".json", this.tempDir);
    File out = File.createTempFile(object.getClass().getName() + "Out", ".json", this.tempDir);
    FileOutputStream fos = new FileOutputStream(in);
    provider.writeTo(object, null, null, null, null, null, fos);
    fos.close();
    Process process = new ProcessBuilder(this.rubyExe, this.exe.getAbsolutePath(), packageToModule(object.getClass().getName()), in.getAbsolutePath(), out.getAbsolutePath())
      .directory(this.exe.getParentFile())
      .redirectErrorStream(true)
      .start();
    BufferedReader procReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
    String line = procReader.readLine();
    while (line != null) {
      System.out.println(line);
      line = procReader.readLine();
    }
    int exitStatus = process.waitFor();
    assertEquals("ruby process json failed.", 0, exitStatus);

    FileInputStream fis = new FileInputStream(out);
    return (T) provider.readFrom((Class<Object>) object.getClass(), object.getClass(), null, null, null, fis);
  }
View Full Code Here

    circle.setLineStyle(LineStyle.solid);
    circle.setPositionX(8);
    circle.setPositionY(9);
    circle.setRadius(10);

    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    ObjectMapper circleMapper = provider.locateMapper(Circle.class, MediaType.APPLICATION_JSON_TYPE);
    ObjectMapper clientMapper = new ObjectMapper();

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    circleMapper.writeValue(out, circle);
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());

    shapes.json.Circle clientCircle = clientMapper.readValue(in, shapes.json.Circle.class);
    assertSame(shapes.json.Color.BLUE, clientCircle.getColor());
    assertEquals("someid", clientCircle.getId());
    assertEquals(shapes.json.LineStyle.solid, clientCircle.getLineStyle());
    assertEquals(8, clientCircle.getPositionX());
    assertEquals(9, clientCircle.getPositionY());
    assertEquals(10, clientCircle.getRadius());

    out = new ByteArrayOutputStream();
    clientMapper.writeValue(out, clientCircle);
    in = new ByteArrayInputStream(out.toByteArray());

    circle = circleMapper.readValue(in, Circle.class);
    assertSame(Color.BLUE, circle.getColor());
    assertEquals("someid", circle.getId());
    assertEquals(LineStyle.solid, circle.getLineStyle());
    assertEquals(8, circle.getPositionX());
    assertEquals(9, circle.getPositionY());
    assertEquals(10, circle.getRadius());

    ObjectMapper rectangleMapper = provider.locateMapper(Rectangle.class, MediaType.APPLICATION_JSON_TYPE);

    Rectangle rectangle = new Rectangle();
    rectangle.setColor(Color.GREEN);
    rectangle.setId("rectid");
    rectangle.setHeight(500);
    rectangle.setWidth(1000);
    rectangle.setLineStyle(LineStyle.dotted);
    rectangle.setPositionX(-100);
    rectangle.setPositionY(-300);

    out = new ByteArrayOutputStream();
    rectangleMapper.writeValue(out, rectangle);
    in = new ByteArrayInputStream(out.toByteArray());

    shapes.json.Rectangle clientRect = clientMapper.readValue(in, shapes.json.Rectangle.class);
    assertSame(shapes.json.Color.GREEN, clientRect.getColor());
    assertEquals("rectid", clientRect.getId());
    assertEquals(shapes.json.LineStyle.dotted, clientRect.getLineStyle());
    assertEquals(500, clientRect.getHeight());
    assertEquals(1000, clientRect.getWidth());
    assertEquals(-100, clientRect.getPositionX());
    assertEquals(-300, clientRect.getPositionY());

    out = new ByteArrayOutputStream();
    clientMapper.writeValue(out, clientRect);
    in = new ByteArrayInputStream(out.toByteArray());

    rectangle = rectangleMapper.readValue(in, Rectangle.class);
    assertSame(Color.GREEN, rectangle.getColor());
    assertEquals("rectid", rectangle.getId());
    assertEquals(LineStyle.dotted, rectangle.getLineStyle());
    assertEquals(500, rectangle.getHeight());
    assertEquals(1000, rectangle.getWidth());
    assertEquals(-100, rectangle.getPositionX());
    assertEquals(-300, rectangle.getPositionY());

    ObjectMapper triangleMapper = provider.locateMapper(Triangle.class, MediaType.APPLICATION_JSON_TYPE);

    Triangle triangle = new Triangle();
    triangle.setBase(90);
    triangle.setColor(Color.RED);
    triangle.setHeight(100);
View Full Code Here

    Circle rider4 = new Circle();
    rider4.setRadius(4);
    riders.put(4, rider4);
    bus.setType(XmlQNameEnumUtil.toQName(BusType.charter));

    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    ObjectMapper busMapper = provider.locateMapper(Bus.class, MediaType.APPLICATION_JSON_TYPE);
    ObjectMapper clientMapper = new ObjectMapper();

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    busMapper.writeValue(out, bus);
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
View Full Code Here

    house.setConstructedDate(new DateTime(3L));
    house.setType(XmlQNameEnumUtil.toQName(HouseType.brick));
    house.setStyle(XmlQNameEnumUtil.toQName(HouseStyle.latin));
    house.setColor(XmlQNameEnumUtil.toURI(HouseColor.blue));

    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    ObjectMapper houseMapper = provider.locateMapper(House.class, MediaType.APPLICATION_JSON_TYPE);
    ObjectMapper clientMapper = new ObjectMapper();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    houseMapper.writeValue(out, house);
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    shapes.json.structures.House clientHouse = clientMapper.readValue(in, shapes.json.structures.House.class);
View Full Code Here

    cat.setNose(noseLine);
    cat.setMouth(mouthLine);
    cat.setWhiskers(Arrays.asList(noseLine, mouthLine));

    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    ObjectMapper catMapper = provider.locateMapper(Cat.class, MediaType.APPLICATION_JSON_TYPE);
    ObjectMapper clientMapper = new ObjectMapper();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    catMapper.writeValue(out, cat);
    shapes.json.animals.Cat clientCat = clientMapper.readValue(new ByteArrayInputStream(out.toByteArray()), shapes.json.animals.Cat.class);
View Full Code Here

    //todo: uncomment when JAXB bug is fixed
//    canvas.setBackgroundImage(new DataHandler(dataSource));
    canvas.setExplicitBase64Attachment(explicitBase64Bytes);
    canvas.setOtherAttachments(Arrays.asList(attachment1, attachment2, attachment3));

    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    ObjectMapper canvasMapper = provider.locateMapper(Canvas.class, MediaType.APPLICATION_JSON_TYPE);
    ObjectMapper clientMapper = new ObjectMapper();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    canvasMapper.writeValue(out, canvas);
    //set up the attachments that were written
View Full Code Here

    }

    protected <T> T getService( Class<T> clazz, String authzHeader )
    {
        T service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", clazz,
                                               Collections.singletonList( new JacksonJaxbJsonProvider() ) );

        if ( authzHeader != null )
        {
            WebClient.client( service ).header( "Authorization", authzHeader );
        }
View Full Code Here

    protected RepositoryGroupService getRepositoryGroupService()
    {
        return JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
                                          RepositoryGroupService.class,
                                          Collections.singletonList( new JacksonJaxbJsonProvider() ) );
    }
View Full Code Here

    protected ProxyConnectorService getProxyConnectorService()
    {
        ProxyConnectorService service =
            JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
                                       ProxyConnectorService.class,
                                       Collections.singletonList( new JacksonJaxbJsonProvider() ) );

        WebClient.client( service ).header( "Authorization", authorizationHeader );
        WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
        WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
        WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.