Examples of JaxbDataFormat


Examples of org.apache.camel.model.dataformat.JaxbDataFormat

        return session;
    }

    public JAXBContext getJaxbContext() {
        if ( this.jaxbContext == null ) {
            JaxbDataFormat def = new JaxbDataFormat();
            def.setPrettyPrint( true );
            // TODO does not work: def.setContextPath( "org.drools.camel.testdomain:org.drools.pipeline.camel" );
            def.setContextPath( "org.drools.pipeline.camel" );

            // create a jaxbContext for the test to use outside of Camel.
            StatefulKnowledgeSession ksession1 = (StatefulKnowledgeSession) node.get( "ksession1",
                                                                                      CommandExecutor.class );
            KnowledgeBase kbase = ksession1.getKieBase();
            ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader( ((KnowledgeBaseImpl) kbase).getRootClassLoader() );
                def = DroolsPolicy.augmentJaxbDataFormatDefinition( def );

                org.apache.camel.converter.jaxb.JaxbDataFormat jaxbDataformat = (org.apache.camel.converter.jaxb.JaxbDataFormat) def.getDataFormat( this.context.getRoutes().get( 0 ).getRouteContext() );

                jaxbDataformat.setCamelContext(routeBuilder.getContext());
                try {
                    jaxbDataformat.start();
                } catch (Exception e) {
View Full Code Here

Examples of org.apache.camel.model.dataformat.JaxbDataFormat

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        routeBuilder = new RouteBuilder() {
            public void configure() throws Exception {
                JaxbDataFormat def = new JaxbDataFormat();
                def.setPrettyPrint(true);
                // TODO does not work: def.setContextPath( "org.drools.camel.testdomain:org.drools.pipeline.camel" );
                def.setContextPath("org.drools.pipeline.camel");

                from("direct:test-with-session").policy(new DroolsPolicy()).
                        unmarshal(def).to("drools:node/ksession1").marshal(def);
            }
        };
View Full Code Here

Examples of org.apache.camel.model.dataformat.JaxbDataFormat

                dformatDefinition = new XStreamDataFormat();
                ((XStreamDataFormat) dformatDefinition).setDriver( "json" );
            } else if ( "xstream".equals( ref ) ) {
                dformatDefinition = new XStreamDataFormat();
            } else if ( "jaxb".equals( ref ) ) {
                dformatDefinition = new JaxbDataFormat();
            } else {
                dformatDefinition = routeContext.getCamelContext().resolveDataFormatDefinition( ref );
            }
        }
View Full Code Here

Examples of org.apache.camel.model.dataformat.JaxbDataFormat

    /**
     * Uses the JAXB data format
     */
    public T jaxb() {
        return dataFormat(new JaxbDataFormat());
    }
View Full Code Here

Examples of org.apache.camel.model.dataformat.JaxbDataFormat

    /**
     * Uses the JAXB data format turning pretty printing on or off
     */
    public T jaxb(boolean prettyPrint) {
        return dataFormat(new JaxbDataFormat(prettyPrint));
    }
View Full Code Here

Examples of org.apache.camel.model.dataformat.JaxbDataFormat

    /**
     * Uses the JAXB data format
     */
    public T jaxb() {
        return dataFormat(new JaxbDataFormat());
    }
View Full Code Here

Examples of org.apache.camel.model.dataformat.JaxbDataFormat

    /**
     * Uses the JAXB data format with context path
     */
    public T jaxb(String contextPath) {
        JaxbDataFormat dataFormat = new JaxbDataFormat();
        dataFormat.setContextPath(contextPath);
        return dataFormat(dataFormat);
    }
View Full Code Here

Examples of org.apache.camel.model.dataformat.JaxbDataFormat

    /**
     * Uses the JAXB data format turning pretty printing on or off
     */
    public T jaxb(boolean prettyPrint) {
        return dataFormat(new JaxbDataFormat(prettyPrint));
    }
View Full Code Here

Examples of org.apache.camel.model.dataformat.JaxbDataFormat

                            dformatDefinition = new XStreamDataFormat();
                            ((XStreamDataFormat)dformatDefinition).setDriver( "json" );                           
                        } else if ( "xstream".equals( ref ) ) {
                            dformatDefinition = new XStreamDataFormat();
                        } else if ( "jaxb".equals( ref ) ) {
                            dformatDefinition = new JaxbDataFormat();
                        } else {
                            dformatDefinition = routeContext.getCamelContext().resolveDataFormatDefinition(ref);
                        }
                    }
                   
                    // always clone before changing
                    dformatDefinition = new FastCloner().deepClone( dformatDefinition );                   
                   
                    if ( dformatDefinition instanceof JaxbDataFormat ) {
                        dformatDefinition = augmentJaxbDataFormatDefinition( (JaxbDataFormat) dformatDefinition );                   
                    } else if ( dformatDefinition instanceof XStreamDataFormat ) {
                        XStreamDataFormat xstreamDataFormat = ( XStreamDataFormat )dformatDefinition;
                        if ( "json".equals( xstreamDataFormat.getDriver() )) {
                            dformatDefinition =  XStreamJson.newJSonMarshaller( xstreamDataFormat );;   
                        } else {
                            dformatDefinition = XStreamXml.newXStreamMarshaller( (XStreamDataFormat) dformatDefinition );   
                        }
                       
                    }
                    m.setDataFormatType( dformatDefinition ); // repoint the marshaller, if it was cloned
                   
                   
                } else if ( child instanceof UnmarshalDefinition ) {
                    UnmarshalDefinition m = (UnmarshalDefinition) child;
                   
                    DataFormatDefinition dformatDefinition = m.getDataFormatType();
                   
                    if ( dformatDefinition == null ) {
                        String ref = m.getRef();
                        if ( "json".equals( ref ) ) {
                            dformatDefinition = new XStreamDataFormat();
                            ((XStreamDataFormat)dformatDefinition).setDriver( "json" );
                        } else if ( "xstream".equals( ref ) ) {
                            dformatDefinition = new XStreamDataFormat();
                        } else if ( "jaxb".equals( ref ) ) {
                            dformatDefinition = new JaxbDataFormat();
                        } else {
                            dformatDefinition = routeContext.getCamelContext().resolveDataFormatDefinition(ref);
                        }
                    }
                   
View Full Code Here

Examples of org.apache.camel.model.dataformat.JaxbDataFormat

        assertNotNull( resp.getFactHandle( "baunax" ) );
    }

    public JAXBContext getJaxbContext() {
        if ( this.jaxbContext == null ) {
            JaxbDataFormat def = new JaxbDataFormat();
            def.setPrettyPrint( true );
            def.setContextPath( "org.drools.model:org.drools.pipeline.camel" );

            // create a jaxbContext for the test to use outside of Camel.
            StatefulKnowledgeSession ksession1 = (StatefulKnowledgeSession) node.get( "ksession1",
                                                                                      CommandExecutor.class );
            KnowledgeBase kbase = ksession1.getKieBase();
            ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader( ((ReteooRuleBase) ((KnowledgeBaseImpl) kbase).getRuleBase()).getRootClassLoader() );
                def = DroolsPolicy.augmentJaxbDataFormatDefinition( def );

                org.apache.camel.converter.jaxb.JaxbDataFormat jaxbDataformat = (org.apache.camel.converter.jaxb.JaxbDataFormat) def.getDataFormat( this.context.getRoutes().get( 0 ).getRouteContext() );

                jaxbDataformat.setCamelContext(routeBuilder.getContext());
                try {
                    jaxbDataformat.start();
                } catch (Exception e) {
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.