Package org.apache.tuscany.sca.databinding.jaxb

Examples of org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper


                for (Annotation a : m.getAnnotations()) {
                    System.out.println(a);
                }
            }
        }
        JAXBContext context = new JAXBContextHelper(new DefaultExtensionPointRegistry()).createJAXBContext(classes.toArray(new Class<?>[classes.size()]));
        for (Class<?> cls : classes) {
            Object obj = cls.newInstance();
            StringWriter sw = new StringWriter();
            context.createMarshaller().marshal(obj, sw);
            // System.out.println(sw.toString());
View Full Code Here


    }

    @Test
    public void testGenerateSchema() throws Exception {
        List<Class<?>> classes = new WrapperBeanGenerator().generateWrapperBeans(TestInterface.class);
        JAXBContext context = new JAXBContextHelper(new DefaultExtensionPointRegistry()).createJAXBContext(classes.toArray(new Class<?>[classes.size()]));
        Map<String, String> results = JAXBTypeHelper.generateSchema(context);
        for (String xsd : results.values()) {
            System.out.println(xsd);
        }
    }
View Full Code Here

            System.out.println(a);
        }
        //        XmlType xmlType = cls.getAnnotation(XmlType.class);
        //        System.out.println(xmlType);
        Object bean = cls.newInstance();
        JAXBContext context = new JAXBContextHelper(new DefaultExtensionPointRegistry()).createJAXBContext(cls);
        StringWriter sw = new StringWriter();
        context.createMarshaller().marshal(bean, sw);
        System.out.println(sw.toString());

    }
View Full Code Here

            System.out.println(a);
        }
        //        XmlType xmlType = cls.getAnnotation(XmlType.class);
        //        System.out.println(xmlType);
        Object bean = cls.newInstance();
        JAXBContext context = new JAXBContextHelper(new DefaultExtensionPointRegistry()).createJAXBContext(cls);
        StringWriter sw = new StringWriter();
        context.createMarshaller().marshal(bean, sw);
        System.out.println(sw.toString());

    }
View Full Code Here

        TransformationContext tContext = new TransformationContextImpl();
        tContext.setSourceDataType(sourceDataType);
        tContext.setTargetDataType(targetDataType);

        ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
        JAXBContextHelper contextHelper = JAXBContextHelper.getInstance(registry);
        // Force the JAXBContext to be cached
        contextHelper.createJAXBContext(tContext, true);

        long start = System.currentTimeMillis();
        JAXB2OMElement t1 = new JAXB2OMElement(registry);
        OMElement om = t1.transform(po, tContext);
        long duration1 = System.currentTimeMillis() - start;
View Full Code Here

                for (Annotation a : m.getAnnotations()) {
                    System.out.println(a);
                }
            }
        }
        JAXBContext context = new JAXBContextHelper(new DefaultExtensionPointRegistry()).createJAXBContext(classes.toArray(new Class<?>[classes.size()]));
        for (Class<?> cls : classes) {
            Object obj = cls.newInstance();
            StringWriter sw = new StringWriter();
            context.createMarshaller().marshal(obj, sw);
            // System.out.println(sw.toString());
View Full Code Here

    }

    @Test
    public void testGenerateSchema() throws Exception {
        List<Class<?>> classes = new WrapperBeanGenerator().generateWrapperBeans(TestInterface.class);
        JAXBContext context = new JAXBContextHelper(new DefaultExtensionPointRegistry()).createJAXBContext(classes.toArray(new Class<?>[classes.size()]));
        Map<String, String> results = JAXBTypeHelper.generateSchema(context);
        for (String xsd : results.values()) {
            System.out.println(xsd);
        }
    }
View Full Code Here

        dumpHeapEnd("TestCall_postStop");
    }
   
    public void checkCacheStatus(){
        UtilityExtensionPoint utilityExtensionPoint = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class);
        JAXBContextHelper jaxbContextHelper = utilityExtensionPoint.getUtility(JAXBContextHelper.class);
       
        Assert.assertEquals("JAXBContextCache > 1", 1, jaxbContextHelper.getJAXBContextCache().getCache().keySet().size());
       
        FactoryExtensionPoint factoryExtensionPoint = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
        JavaInterfaceFactory javaInterfaceFactory = factoryExtensionPoint.getFactory(JavaInterfaceFactory.class);
        Assert.assertEquals("JavaInterfaceFactoryImpl.normalCache > 1", 1, ((JavaInterfaceFactoryImpl)javaInterfaceFactory).getNormalCache().keySet().size());
       
View Full Code Here

   
    @Test
    public void testSchemaGen() throws JAXBException, IOException, TransformerException, Exception {                 
        ExtensionPointRegistry extensionPointRegistry = ((NodeImpl)node).getExtensionPointRegistry();
        JAXBTypeHelper typeHelper = new JAXBTypeHelper(extensionPointRegistry);
        JAXBContextHelper contextHelper = new JAXBContextHelper(extensionPointRegistry);
       
        //typeHelper.getSchemaDefinitions(factory, resolver, intf);
       
        Package pkg = CBean.class.getPackage();
        String pkgName = pkg.getName();
        Annotation[] pkgAnnotations = pkg.getAnnotations();
        boolean genPkgInfo = true;
       
        for (Annotation annotation : pkgAnnotations){
            if (annotation instanceof XmlSchema){
                XmlSchema schemaAnnotation = (XmlSchema)annotation;
                if (schemaAnnotation.namespace() != null){
                    genPkgInfo = false;
                    break;
                }
            }
        }
       
        JAXBContext context = null;
           
        if (genPkgInfo){
            System.out.println("There is no package info so generate one");
/*  Can gen the annotation but then what?            
            Class<?> genClass = generatePackageInfo(pkgName, "http://sometestsnamespace");
           
            Package pkgGen = aClass.getPackage();
            String pkgGenName = pkg.getName();
            Annotation[] pkgGenAnnotations = pkg.getAnnotations();
            XmlSchema schemaAnnotation = null;
           
            for (Annotation annotation : pkgGenAnnotations){
                if (annotation instanceof XmlSchema){
                    schemaAnnotation = (XmlSchema)annotation;
                }
            }
           
            pkgAnnotations = pkgGenAnnotations;
*/           
           
/*   Can't pass the generarted package into JAXB. It has to
*   be properly referenced as a package of a class you're trying
*   generate.         
            Class<?>[] classes = {aClass, genClass};
            context = contextHelper.createJAXBContext(classes);
*/        
        } else {
            System.out.println("There is package info");
        }
       
        Class<?>[] classes = {ABean.class, BBean.class, CBean.class, DBean.class};
        context = contextHelper.createJAXBContext(classes);
  
        DOMResolverImpl resolver = new DOMResolverImpl();
        context.generateSchema(resolver);    
       
        String toNamespace = null;
View Full Code Here

        }
       
        UtilityExtensionPoint utilityExtensionPoint = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class);
        FactoryExtensionPoint factoryExtensionPoint = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);

        JAXBContextHelper jaxbContextHelper = utilityExtensionPoint.getUtility(JAXBContextHelper.class);
        jaxbContextHelper.removeJAXBContextForContribution(contributionClassloader);
       
        JavaInterfaceFactory javaInterfaceFactory = factoryExtensionPoint.getFactory(JavaInterfaceFactory.class);
        javaInterfaceFactory.removeInterfacesForContribution(contributionClassloader);
       
        ProxyFactoryExtensionPoint proxyFactoryExtensionPoint = extensionPointRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper

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.