public JAXBContextResolver() throws Exception {

    JAXBContext context;
    JAXBContext unWrappedRootContext;

    // you have to specify all the dao classes here
    final Class[] cTypes = {
      AppInfo.class,
      AppAttemptInfo.class,
      AppAttemptsInfo.class,
      ClusterInfo.class,
      CapacitySchedulerQueueInfo.class,
      FifoSchedulerInfo.class,
      SchedulerTypeInfo.class,
      NodeInfo.class,
      UserMetricsInfo.class,
      CapacitySchedulerInfo.class,
      ClusterMetricsInfo.class,
      SchedulerInfo.class,
      AppsInfo.class,
      NodesInfo.class,
      RemoteExceptionData.class,
      CapacitySchedulerQueueInfoList.class,
      ResourceInfo.class,
      UsersInfo.class,
      UserInfo.class,
      ApplicationStatisticsInfo.class,
      StatisticsItemInfo.class,
      CapacitySchedulerHealthInfo.class,
      FairSchedulerQueueInfoList.class
    };
    // these dao classes need root unwrapping
    final Class[] rootUnwrappedTypes = {
      NewApplication.class,
      ApplicationSubmissionContextInfo.class,
      ContainerLaunchContextInfo.class,
      LocalResourceInfo.class,
      DelegationToken.class,
      AppQueue.class
    };

    this.typesContextMap = new HashMap<Class, JAXBContext>();
    context =
        new JSONJAXBContext(JSONConfiguration.natural().rootUnwrapping(false).build(), cTypes);
    unWrappedRootContext =
        new JSONJAXBContext(
            JSONConfiguration.natural().rootUnwrapping(true).build(), rootUnwrappedTypes);
    for (Class type : cTypes) {
      typesContextMap.put(type, context);
    }
    for (Class type : rootUnwrappedTypes) {
      typesContextMap.put(type, unWrappedRootContext);
    }
  }
 /**
  * @param s the JSON representation of the filter
  * @return the filter
  * @throws Exception
  */
 public static Filter buildFilter(String s) throws Exception {
   JSONJAXBContext context =
       new JSONJAXBContext(JSONConfiguration.natural().build(), FilterModel.class);
   JSONUnmarshaller unmarshaller = context.createJSONUnmarshaller();
   FilterModel model = unmarshaller.unmarshalFromJSON(new StringReader(s), FilterModel.class);
   return model.build();
 }
 /**
  * @param filter the filter
  * @return the JSON representation of the filter
  * @throws Exception
  */
 public static String stringifyFilter(final Filter filter) throws Exception {
   JSONJAXBContext context =
       new JSONJAXBContext(JSONConfiguration.natural().build(), FilterModel.class);
   JSONMarshaller marshaller = context.createJSONMarshaller();
   StringWriter writer = new StringWriter();
   marshaller.marshallToJSON(new FilterModel(filter), writer);
   return writer.toString();
 }
 public void testNatural() throws Exception {
   System.out.println("\nTesting Natural: -------------------------");
   // TODO: a patch applied at jaxb trunk to add a new utility method on UnmarshallingContext
   //            after this gets tested and make it to a release of jaxb, we can uncomment
   // appropriate
   //            stuff on Jersey side, and the following should work
   // tryListWithConfiguration(JSONConfiguration.natural().build());
   tryIndividualsWithConfiguration(JSONConfiguration.natural().rootUnwrapping(false).build());
 }
  public void testNewLineAdded() throws Exception {

    final JSONJAXBContext ctx =
        new JSONJAXBContext(
            JSONConfiguration.natural().rootUnwrapping(false).humanReadableFormatting(true).build(),
            User.class);
    final JSONMarshaller jm = ctx.createJSONMarshaller();
    final StringWriter sw = new StringWriter();

    final User one = JSONTestHelper.createTestInstance(User.class);
    jm.marshallToJSON(one, sw);

    assertTrue(sw.toString().contains("\n"));
  }
 public JAXBContextResolver() throws Exception {
   this.context = new JSONJAXBContext(JSONConfiguration.natural().build(), types);
 }