Package javax.xml.bind

Examples of javax.xml.bind.JAXBContext.generateSchema()


    }

    JAXBContext jaxbContext = JAXBContext.newInstance(javaClasses.toArray(new Class<?>[javaClasses.size()]));

    MemorySchemaOutputResolver schemaOutputResolver = new MemorySchemaOutputResolver();
    jaxbContext.generateSchema(schemaOutputResolver);

    Map<String, StringWriter> writers = schemaOutputResolver.getWriters();
    StringWriter writer = writers.get(namespace);
    if (writer == null) {
      throw new IllegalArgumentException();
View Full Code Here


     */
    public <T> String generateSchema(Class<T> type) {
        try {
            JAXBContext context = this.getJaxbContext(type);
            SchemaResolver resolver = new SchemaResolver();
            context.generateSchema(resolver);
            return resolver.getWriter().toString();
        } catch (IOException e) {
            throw new CedarRuntimeException("Error generating schema: " + e.getMessage(), e);
        }
    }
View Full Code Here

         }
      }
      JAXBContext context = JAXBContext.newInstance(InfinispanConfiguration.class);
      if (!baseDir.exists()) {
         if (baseDir.mkdirs()) {
            context.generateSchema(new InfinispanSchemaOutputResolver(baseDir));
         }
      }
   }
}
View Full Code Here

                baseDir.mkdirs();

            System.out.println("Generating schema file in " + baseDir.getAbsolutePath());
            try {
                JAXBContext context = JAXBContext.newInstance(InfinispanConfiguration.class);
                context.generateSchema(new InfinispanSchemaOutputResolver(baseDir));
                System.out.println("Generated schema file successfully");
            } catch (Exception e) {
                System.err.println("Failed generating schema file " + e);
                e.printStackTrace(System.err);
            }
View Full Code Here

public class JAXBReflectionTestCase extends TestCase {

    public void testGenerateSchema() throws Exception {
        JAXBContext context = JAXBContext.newInstance("com.example.ipo.jaxb");
        SchemaOutputResolverImpl resolver = new SchemaOutputResolverImpl();
        context.generateSchema(resolver);
        System.out.println(new Node2String().transform(resolver.getSchema(), null));
    }

    public static class SchemaOutputResolverImpl extends SchemaOutputResolver {
        private DOMResult result = new DOMResult();
View Full Code Here

                baseDir.mkdirs();

            System.out.println("Generating schema file in " + baseDir.getAbsolutePath());
            try {
                JAXBContext context = JAXBContext.newInstance(InfinispanConfiguration.class);
                context.generateSchema(new InfinispanSchemaOutputResolver(baseDir));
                System.out.println("Generated schema file successfully");
            } catch (Exception e) {
                System.err.println("Failed generating schema file " + e);
                e.printStackTrace(System.err);
            }
View Full Code Here

public class JAXBReflectionTestCase extends TestCase {

    public void testGenerateSchema() throws Exception {
        JAXBContext context = JAXBContext.newInstance("com.example.ipo.jaxb");
        SchemaOutputResolverImpl resolver = new SchemaOutputResolverImpl();
        context.generateSchema(resolver);
        System.out.println(new Node2String().transform(resolver.getSchema(), null));
    }

    public static class SchemaOutputResolverImpl extends SchemaOutputResolver {
        private DOMResult result = new DOMResult();
View Full Code Here

       
        Class<?>[] classes = {ABean.class, BBean.class, CBean.class, DBean.class};
        context = contextHelper.createJAXBContext(classes);
  
        DOMResolverImpl resolver = new DOMResolverImpl();
        context.generateSchema(resolver);    
       
        String toNamespace = null;
        String fromNamespace = null;
        Document toDocument = null;
        Document fromDocument = null;
View Full Code Here

                RestLogging.restLogger.log(Level.WARNING, null, ex);
            }
        }
        JAXBContext jc = JAXBContext.newInstance(classes.toArray(new Class<?>[classes.size()]));
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        jc.generateSchema(new MySchemaOutputResolver(baos));
        return new String(baos.toByteArray());
    }

    @GET
    @Path("test1")
View Full Code Here

        } catch (ClassNotFoundException ex) {
            RestLogging.restLogger.log(Level.WARNING, null, ex);
        }
        JAXBContext jc = JAXBContext.newInstance(classes.toArray(new Class<?>[classes.size()]));
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        jc.generateSchema(new MySchemaOutputResolver(baos));
        return new String(baos.toByteArray());
    }

    @GET
    public String getSchemaManually() {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.