Examples of JAXBDSContext


Examples of org.apache.axis2.datasource.jaxb.JAXBDSContext

        if (info == null) {
            return;
        }
       
        // Crate a JAXBCustomBuilder and register it on the Axiom StAXOMBuilder
        JAXBDSContext jaxbDSC = new JAXBDSContext(info.getPackages(), info.getPackagesKey());
        jaxbDSC.setMessageContext(mc);
        JAXBCustomBuilder jcb = new JAXBCustomBuilder(jaxbDSC);
        ((StAXOMBuilder) envelope.getBuilder()).registerCustomBuilderForPayload(jcb);
        if (log.isDebugEnabled()) {
            log.debug("Registering JAXBCustomBuilder: " + jcb + " for AxisOperation: " + axisOp.getName());
        }
View Full Code Here

Examples of org.apache.axis2.datasource.jaxb.JAXBDSContext

        // Read the sample text using OM backed by StAX.
        XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
        StAXOMBuilder builder = new StAXOMBuilder(inputReader);
       
        // Create the JAXBCustomBuilder
        JAXBDSContext jdsContext = new JAXBDSContext(contextPackages);
        JAXBCustomBuilder jcb = new JAXBCustomBuilder(jdsContext);
       
        // Register the JAXBCustomBuilder...this will intercept the payload
        // and build a jaxb element
        builder.registerCustomBuilderForPayload(jcb);
View Full Code Here

Examples of org.apache.axis2.datasource.jaxb.JAXBDSContext

        // On inbound, there will already be a probably be an OM
        // which represents the message.  In this scenario, the OM contains
        // a OMSourcedElement that is backed by EchoString.
        OMFactory omFactory = OMAbstractFactory.getOMFactory();
        JAXBDSContext dsContext = new JAXBDSContext(jaxbContext);
        JAXBDataSource ds = new JAXBDataSource(jaxb, dsContext);
        OMNamespace ns = omFactory.createOMNamespace(expectedQName.getNamespaceURI(), "pre");
        OMElement om = omFactory.createOMElement(ds, expectedQName.getLocalPart(), ns);
       
View Full Code Here

Examples of org.apache.axis2.datasource.jaxb.JAXBDSContext

        if (info == null) {
            return;
        }
       
        // Crate a JAXBCustomBuilder and register it on the Axiom StAXOMBuilder
        JAXBDSContext jaxbDSC = new JAXBDSContext(info.getPackages(), info.getPackagesKey());
        jaxbDSC.setMessageContext(mc);
        JAXBCustomBuilder jcb = new JAXBCustomBuilder(jaxbDSC);
        ((StAXOMBuilder) envelope.getBuilder()).registerCustomBuilderForPayload(jcb);
        if (log.isDebugEnabled()) {
            log.debug("Registering JAXBCustomBuilder: " + jcb + " for AxisOperation: " + axisOp.getName());
        }
View Full Code Here

Examples of org.apache.axis2.datasource.jaxb.JAXBDSContext

            OMDataSource ds = ((OMSourcedElement) omElement).getDataSource();
            if (ds instanceof JAXBDataSource) {
                // Update the business context to use the one provided
                // by the datasource
                try {
                    JAXBDSContext dsContext = ((JAXBDataSource) ds).getContext();
                    busContext = new JAXBBlockContext(dsContext.getJAXBContext());
                } catch (JAXBException e) {
                    throw ExceptionFactory.makeWebServiceException(e);
                }
                return ((JAXBDataSource) ds).getObject();
            } else if (ds instanceof JAXBBlockImpl) {
View Full Code Here

Examples of org.apache.axis2.datasource.jaxb.JAXBDSContext

        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
        OMElement omElement = builder.getSOAPEnvelope();
       
        if (installJAXBCustomBuilder) {
            JAXBDSContext jds = new JAXBDSContext(EchoStringResponse.class.getPackage().getName());
            JAXBCustomBuilder jcb = new JAXBCustomBuilder(jds);
            builder.registerCustomBuilderForPayload(jcb);
        }
       
        // Create a SOAP 1.1 Message from the sample incoming XML
View Full Code Here

Examples of org.apache.axis2.datasource.jaxb.JAXBDSContext

        StringReader sr = new StringReader(sampleJAXBEnvelope);
        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
        OMElement omElement = builder.getSOAPEnvelope();
       
        JAXBDSContext jds = null;
        if (installJAXBCustomBuilder) {
            jds = new JAXBDSContext(EchoStringResponse.class.getPackage().getName());
            JAXBCustomBuilder jcb = new JAXBCustomBuilder(jds);
            builder.registerCustomBuilderForPayload(jcb);
        }
       
        // Create a SOAP 1.1 Message from the sample incoming XML
        MessageFactory mf = (MessageFactory)
            FactoryRegistry.getFactory(MessageFactory.class);
        Message m = mf.createFrom(omElement, null);
       
        // Check to see if the message is a fault.  The client/server will always call this method.
        // The Message must respond appropriately without doing a conversion.
        boolean isFault = m.isFault();
        assertTrue(!isFault);
        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
                    "OM".equals(m.getXMLPartContentType()));
       
        if (installJAXBCustomBuilder) {
            // The JAXBDSContext and the JAXBUtils access the JAXBContext
            // for the "test" package.
            // The JAXBContext creation is very expensive.
            // However the JAXBContext can also be very large.
            //
            // For these reasons, the JAXBUtils code caches the JAXBContext values.
            // And, the JAXBDSContext and JAXBUtils code use WeakReferences to refer
            // to the JAXBContext (so that it is easily gc'd).
           
            // The following code checks makes sure that the caching and gc is correct.
           
            // Get the JAXBContext
            JAXBContext context = jds.getJAXBContext();
           
            // Get the identity hash code.  This is an indicator of the unique memory pointer
            // for the context.
            int contextPointer = System.identityHashCode(context);
           
View Full Code Here

Examples of org.apache.axis2.datasource.jaxb.JAXBDSContext

        // Read the sample text using OM backed by StAX.
        XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
        StAXOMBuilder builder = new StAXOMBuilder(inputReader);
       
        // Create the JAXBCustomBuilder
        JAXBDSContext jdsContext = new JAXBDSContext(contextPackages);
        JAXBCustomBuilder jcb = new JAXBCustomBuilder(jdsContext);
       
        // Register the JAXBCustomBuilder...this will intercept the payload
        // and build a jaxb element
        builder.registerCustomBuilderForPayload(jcb);
View Full Code Here

Examples of org.apache.axis2.datasource.jaxb.JAXBDSContext

        // Read the sample text using OM backed by StAX.
        XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
        StAXOMBuilder builder = new StAXOMBuilder(inputReader);
       
        // Create the JAXBCustomBuilder
        JAXBDSContext jdsContext = new JAXBDSContext(contextPackages);
        JAXBCustomBuilder jcb = new JAXBCustomBuilder(jdsContext);
       
        // Register the JAXBCustomBuilder...this will intercept the payload
        // and build a jaxb element
        builder.registerCustomBuilderForPayload(jcb);
View Full Code Here

Examples of org.apache.axis2.datasource.jaxb.JAXBDSContext

    public void testMarshal() throws Exception {
       
        // Create a JAXBDSContext for the package containing Data
        TreeSet<String> packages = new TreeSet<String>();
        packages.add(Data.class.getPackage().getName());
        JAXBDSContext context = new JAXBDSContext(packages);
       
        TestLogger.logger.debug(context.getJAXBContext().toString());
       
        // Force marshal by type
        context.setProcessType(Data.class);
       
        // Create an Data value
        ObjectFactory factory = new ObjectFactory();
        Data value = factory.createData();
        value.setInput("Hello World");
       
        // Create a JAXBElement
        QName qName = new QName("urn://sample", "data");
        JAXBElement jaxbElement = new JAXBElement(qName, Data.class, value);

        // Create a writer
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        OMOutputFormat format = new OMOutputFormat();
        format.setDoOptimize(true);
        MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(baos, format);
       
        // Marshal the value
        writer.writeStartDocument();
        writer.writeStartElement("root");
        context.marshal(jaxbElement, writer);
        writer.writeEndElement();
        writer.writeEndDocument();
        writer.flush();
       
        assertTrue(baos.toString().indexOf("Hello World") > 0);
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.