Package org.drools.common

Examples of org.drools.common.DroolsObjectInputStream


    }

    public void readExternal(ObjectInput in) throws IOException,
                                            ClassNotFoundException {
        boolean isDrools = in instanceof DroolsObjectInputStream;
        DroolsObjectInputStream droolsStream;
        ByteArrayInputStream bytes;

        if ( isDrools ) {
            bytes = null;
            droolsStream = (DroolsObjectInputStream) in;
        } else {
            bytes = new ByteArrayInputStream( (byte[]) in.readObject() );
            droolsStream = new DroolsObjectInputStream( bytes );
        }
       
        this.rules = (Map<Rule, BaseNode[]>) droolsStream.readObject();
        this.idGenerator = (IdGenerator) droolsStream.readObject();
        this.ordered = droolsStream.readBoolean();
        if ( !isDrools ) {
            droolsStream.close();
            bytes.close();
        }

        this.ruleBuilder = new ReteooRuleBuilder();
    }
View Full Code Here


       
        if ( wasDrools ) {
            droolsStream = (DroolsObjectInput) stream;
        } else {
            bytes = new ByteArrayInputStream( (byte[]) stream.readObject() );
            droolsStream = new DroolsObjectInputStream( bytes );
        }
       
        super.readExternal( droolsStream );
        this.reteooBuilder = (ReteooBuilder) droolsStream.readObject();
        this.reteooBuilder.setRuleBase( this );
View Full Code Here

     *            InputStream
     */
    public void readExternal(ObjectInput stream) throws IOException,
                                                ClassNotFoundException {
        boolean isDroolsStream = stream instanceof DroolsObjectInputStream;
        DroolsObjectInputStream in = isDroolsStream ? (DroolsObjectInputStream) stream : new DroolsObjectInputStream( new ByteArrayInputStream( (byte[]) stream.readObject() ) );

        // setting parent classloader for dialect datas
        this.dialectRuntimeRegistry = (DialectRuntimeRegistry) in.readObject();

        this.typeDeclarations = (Map) in.readObject();
        this.name = (String) in.readObject();
        this.imports = (Map<String, ImportDeclaration>) in.readObject();
        this.staticImports = (Set) in.readObject();
        this.functions = (Map<String, Function>) in.readObject();
        this.factTemplates = (Map) in.readObject();
        this.ruleFlows = (Map) in.readObject();
        this.globals = (Map<String, String>) in.readObject();
        this.valid = in.readBoolean();
        this.rules = (Map<String, Rule>) in.readObject();
        this.classFieldAccessorStore = (ClassFieldAccessorStore) in.readObject();
        if ( !isDroolsStream ) {
            in.close();
        }
    }
View Full Code Here

            baos.close();

            byte[] serializedKb = baos.toByteArray();

            ByteArrayInputStream bais = new ByteArrayInputStream( serializedKb );
            DroolsObjectInputStream ois = new DroolsObjectInputStream( bais );

            KnowledgeBase kb2 = (KnowledgeBase) ois.readObject();
        } catch ( OptionalDataException ode ) {
            ode.printStackTrace();
            fail( "EOF? " + ode.eof );
        } catch ( Exception e ) {
            e.printStackTrace();
View Full Code Here

        return MarshallerFactory.newMarshaller( kbase, new ObjectMarshallingStrategy[] { strategy } );
    }

    public StatefulKnowledgeSession loadSession( FileInputStream input ) throws IOException, ClassNotFoundException {
        StatefulKnowledgeSession ksession = null;
        DroolsObjectInputStream droolsIn = new DroolsObjectInputStream( input, this.getClass().getClassLoader() );
        try {
            KnowledgeBase kbase = (KnowledgeBase) droolsIn.readObject();
            Marshaller mas = createMarshaller( kbase );
            ksession = mas.unmarshall(droolsIn);
        } catch ( EOFException e ) {
            e.printStackTrace();
            fail( e.getMessage() );
        } finally {
            droolsIn.close();
        }
        return ksession;
    }
View Full Code Here

    }

    public void readExternal(ObjectInput in) throws IOException,
                                            ClassNotFoundException {
        boolean isDrools = in instanceof DroolsObjectInputStream;
        DroolsObjectInputStream droolsStream;
        ByteArrayInputStream bytes;

        if ( isDrools ) {
            bytes = null;
            droolsStream = (DroolsObjectInputStream) in;
        } else {
            bytes = new ByteArrayInputStream( (byte[]) in.readObject() );
            droolsStream = new DroolsObjectInputStream( bytes );
        }
       
        this.rules = (Map<Rule, BaseNode[]>) droolsStream.readObject();
        this.namedWindows = (Map<String, WindowNode>) droolsStream.readObject();
        this.idGenerator = (IdGenerator) droolsStream.readObject();
        this.ordered = droolsStream.readBoolean();
        if ( !isDrools ) {
            droolsStream.close();
            bytes.close();
        }

        this.ruleBuilder = new ReteooRuleBuilder();
    }
View Full Code Here

     *            InputStream
     */
    public void readExternal( ObjectInput stream ) throws IOException,
            ClassNotFoundException {
        boolean isDroolsStream = stream instanceof DroolsObjectInputStream;
        DroolsObjectInputStream in = isDroolsStream ? (DroolsObjectInputStream) stream
                                                   : new DroolsObjectInputStream(
                                                                                  new ByteArrayInputStream(
                                                                                                            (byte[]) stream.readObject() ) );

        // setting parent classloader for dialect datas
        this.dialectRuntimeRegistry = (DialectRuntimeRegistry) in.readObject();

        this.typeDeclarations = (Map) in.readObject();
        this.name = (String) in.readObject();
        this.imports = (Map<String, ImportDeclaration>) in.readObject();
        this.staticImports = (Set) in.readObject();
        this.functions = (Map<String, Function>) in.readObject();
        this.factTemplates = (Map) in.readObject();
        this.ruleFlows = (Map) in.readObject();
        this.globals = (Map<String, String>) in.readObject();
        this.valid = in.readBoolean();
        this.rules = (Map<String, Rule>) in.readObject();
        this.classFieldAccessorStore = (ClassFieldAccessorStore) in.readObject();
        this.entryPointsIds = (Set<String>) in.readObject();
        this.windowDeclarations = (Map<String, WindowDeclaration>) in.readObject();
        if (!isDroolsStream) {
            in.close();
        }
    }
View Full Code Here

        Package p = new Package( "x" );

        RuleBaseAssemblerTest.writePackage( p,
                                            f );

        DroolsObjectInputStream in = new DroolsObjectInputStream( new FileInputStream( f ) );
        Package p_ = (Package) in.readObject();
        in.close();
        assertEquals( "x",
                      p_.getName() );

    }
View Full Code Here

        KnowledgePackage kpackage = new KnowledgePackageImp( new Package( "x" ) );

        RuleBaseAssemblerTest.writePackage( kpackage,
                                            f );

        DroolsObjectInputStream in = new DroolsObjectInputStream( new FileInputStream( f ) );
        KnowledgePackage p_ = (KnowledgePackage) in.readObject();
        in.close();
        assertEquals( "x",
                      p_.getName() );

    }
View Full Code Here

                      map.get( "value" ) );
    }

    private Object serializeIn(final byte[] bytes) throws IOException,
                                                  ClassNotFoundException {
        final ObjectInput in = new DroolsObjectInputStream( new ByteArrayInputStream( bytes ) );
        final Object obj = in.readObject();
        in.close();
        return obj;
    }
View Full Code Here

TOP

Related Classes of org.drools.common.DroolsObjectInputStream

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.