Package org.kie.api.marshalling

Examples of org.kie.api.marshalling.Marshaller


    public void writeExternal(ObjectOutput out) throws IOException {
        // all we do is create marshall to a byte[] and write to the stream
        StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) getKnowledgeRuntime();

        Marshaller marshaller = MarshallerFactory.newMarshaller(ksession.getKieBase(), new ObjectMarshallingStrategy[]{MarshallerFactory.newSerializeMarshallingStrategy()});

        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        marshaller.marshall( stream, (StatefulKnowledgeSession) getKnowledgeRuntime() );
        stream.close();

        byte[] bytes = stream.toByteArray();
        out.writeInt( bytes.length );
        out.write(bytes);
View Full Code Here


       
        ksession.fireAllRules(); // insertLogical Person(Bob)
       
        // Serialize and Deserialize
        try {
          Marshaller marshaller = MarshallerFactory.newMarshaller(kbase);
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          marshaller.marshall(baos, ksession);
          marshaller = MarshallerFactory.newMarshaller(kbase);
          ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
          baos.close();
          ksession = (StatefulKnowledgeSession)marshaller.unmarshall(bais);
          bais.close();
        } catch (Exception e) {
          e.printStackTrace();
          fail("unexpected exception :" + e.getMessage());
        }
View Full Code Here

       
        ksession.fireAllRules(); // insertLogical Person(Bob)
       
        // Serialize and Deserialize
        try {
          Marshaller marshaller = MarshallerFactory.newMarshaller(kbase);
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          marshaller.marshall(baos, ksession);
          marshaller = MarshallerFactory.newMarshaller(kbase);
          ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
          baos.close();
          ksession = (StatefulKnowledgeSession)marshaller.unmarshall(bais);
          bais.close();
        } catch (Exception e) {
          e.printStackTrace();
          fail("unexpected exception :" + e.getMessage());
        }
View Full Code Here

            kbase = KnowledgeBaseFactory.newKnowledgeBase();
        }
        ObjectMarshallingStrategy [] strategies
            = new ObjectMarshallingStrategy[] { MarshallerFactory.newSerializeMarshallingStrategy() };
        strategies = addProcessInstanceResolverStrategyIfAvailable(strategies);
        Marshaller marshaller = MarshallerFactory.newMarshaller( kbase, strategies );
   
        // Prepare input for marshaller
        ByteArrayInputStream bais = new ByteArrayInputStream( marshalledData.byteArray );
        SessionConfiguration conf = SessionConfiguration.getDefaultInstance();
        Environment env = EnvironmentFactory.newEnvironment();
   
        // Unmarshall
        KieSession ksession = marshaller.unmarshall( bais, conf, env );
       
        return ksession;
    }
View Full Code Here

        ksession.fireAllRules(); // insertLogical Person(Bob)

        // Serialize and Deserialize
        try {
            Marshaller marshaller = MarshallerFactory.newMarshaller( kbase );
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            marshaller.marshall(baos, ksession);
            marshaller = MarshallerFactory.newMarshaller(kbase);
            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            baos.close();
            ksession = (StatefulKnowledgeSession)marshaller.unmarshall(bais);
            bais.close();
        } catch (Exception e) {
            e.printStackTrace();
            fail("unexpected exception :" + e.getMessage());
        }
View Full Code Here

   
    public void writeExternal(ObjectOutput out) throws IOException {
        // all we do is create marshall to a byte[] and write to the stream
        StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) getKnowledgeRuntime();
       
        Marshaller marshaller = MarshallerFactory.newMarshaller( ksession.getKieBase(), new ObjectMarshallingStrategy[] { MarshallerFactory.newSerializeMarshallingStrategy() }   );
       
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        marshaller.marshall( stream, (StatefulKnowledgeSession) getKnowledgeRuntime() );
        stream.close();
       
        byte[] bytes = stream.toByteArray();
        out.writeInt( bytes.length );
        out.write( bytes );
View Full Code Here

                // so we read it, but we don't need it, so just ignore.
                ReteooStatefulSession rsession = (ReteooStatefulSession) ois.readObject();
   
                // now unmarshall that byte[]
                ByteArrayInputStream bais = new ByteArrayInputStream( rsession.bytes );
                Marshaller marshaller = MarshallerFactory.newMarshaller( new KnowledgeBaseImpl( this )new ObjectMarshallingStrategy[] { MarshallerFactory.newSerializeMarshallingStrategy() }   );
               
                Environment environment = EnvironmentFactory.newEnvironment();
                KieSession ksession = marshaller.unmarshall( bais,
                                                             conf,
                                                             environment );
                session = (StatefulSession) ((StatefulKnowledgeSessionImpl) ksession).session;
   
                if ( keepReference ) {
View Full Code Here

       
        ksession.fireAllRules(); // insertLogical Person(Bob)
       
        // Serialize and Deserialize
        try {
          Marshaller marshaller = MarshallerFactory.newMarshaller(kbase);
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          marshaller.marshall(baos, ksession);
          marshaller = MarshallerFactory.newMarshaller(kbase);
          ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
          baos.close();
          ksession = (StatefulKnowledgeSession)marshaller.unmarshall(bais);
          bais.close();
        } catch (Exception e) {
          e.printStackTrace();
          fail("unexpected exception :" + e.getMessage());
        }
View Full Code Here

                // so we read it, but we don't need it, so just ignore.
                ReteooStatefulSession rsession = (ReteooStatefulSession) ois.readObject();
   
                // now unmarshall that byte[]
                ByteArrayInputStream bais = new ByteArrayInputStream( rsession.bytes );
                Marshaller marshaller = MarshallerFactory.newMarshaller( new KnowledgeBaseImpl( this )new ObjectMarshallingStrategy[] { MarshallerFactory.newSerializeMarshallingStrategy() }   );
               
                Environment environment = EnvironmentFactory.newEnvironment();
                KieSession ksession = marshaller.unmarshall( bais,
                                                                           conf,
                                                                           environment );
                session = (StatefulSession) ((StatefulKnowledgeSessionImpl) ksession).session;
   
                if ( keepReference ) {
View Full Code Here

                      results.get( 0 ) );

        // serialize session and rulebase out
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        StatefulKnowledgeSessionImpl ksession = new StatefulKnowledgeSessionImpl( (AbstractWorkingMemory) session );
        Marshaller marshaller = MarshallerFactory.newMarshaller( ksession.getKieBase() );
        marshaller.marshall( baos,
                             ksession );
        baos.close();

        GlobalResolver resolver = session.getGlobalResolver();
        byte[] serializedRulebase = DroolsStreamUtils.streamOut( ruleBase );
        session.dispose();

        // now deserialize the rulebase, deserialize the session and test it
        ruleBase = (RuleBase) DroolsStreamUtils.streamIn( serializedRulebase );

        marshaller = MarshallerFactory.newMarshaller( new KnowledgeBaseImpl( ruleBase ) );
        ksession = (StatefulKnowledgeSessionImpl) marshaller.unmarshall( new ByteArrayInputStream( baos.toByteArray() ),
                                                                         KnowledgeBaseFactory.newKnowledgeSessionConfiguration(),
                                                                         EnvironmentFactory.newEnvironment() );
        session = (AbstractWorkingMemory) ksession.session;
        session.setGlobalResolver( resolver );
View Full Code Here

TOP

Related Classes of org.kie.api.marshalling.Marshaller

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.