Package org.drools.common

Examples of org.drools.common.DroolsObjectInputStream


    public Object unmarshal(Context context,
                            ObjectInputStream ois,
                            byte[] object,
                            ClassLoader classloader) throws IOException,
                                                    ClassNotFoundException {
        DroolsObjectInputStream is = new DroolsObjectInputStream( new ByteArrayInputStream( object ), classloader );
        String canonicalName = is.readUTF();
        Object id = is.readObject();
        EntityManagerFactory emf = (EntityManagerFactory) env.get(EnvironmentName.ENTITY_MANAGER_FACTORY);
        EntityManager em = emf.createEntityManager();
        return em.find(Class.forName(canonicalName), id);
    }
View Full Code Here


        HttpURLConnection httpCon = (HttpURLConnection) con;
        try {
            httpCon.setRequestMethod( "GET" );
            InputStream in = httpCon.getInputStream();

            DroolsObjectInputStream oin = new DroolsObjectInputStream(in);
                return (Package) oin.readObject();

        } finally {
            httpCon.disconnect();
        }
    }
View Full Code Here

      } else {

          Package p1_ = null;
          ObjectInputStream in;
          try {
              in = new DroolsObjectInputStream( new FileInputStream( pkgFile ) );
              p1_ = (Package) in.readObject();
              in.close();

          } catch ( FileNotFoundException e ) {
              this.listener.exception( e );
View Full Code Here

                                                       IOException,
                                                       Exception {
        //always perform the default de-serialization first
        is.defaultReadObject();
        if ( is instanceof DroolsObjectInputStream ) {
            DroolsObjectInputStream dois = (DroolsObjectInputStream) is;
            this.extractor = dois.getExtractorFactory().getExtractor( this.clazz,
                                                                      this.fieldName,
                                                                      dois.getClassLoader() );
        } else {
            this.extractor = ClassFieldExtractorCache.getInstance().getExtractor( this.clazz,
                                                                                  this.fieldName,
                                                                                  this.clazz.getClassLoader() );
View Full Code Here

        if ( classLoader == null ) {
            classLoader = this.classLoader;
        }
       
        try {
            ObjectInputStream oin = new DroolsObjectInputStream( in, classLoader);
            Object opkg = oin.readObject();
            if ( !(opkg instanceof Package) ) {
                throw new IllegalArgumentException( "Can only add instances of org.drools.rule.Package to a rulebase instance." );
            }
            Package binPkg = (Package) opkg;
View Full Code Here

        stream.writeObject( this.variableResolvers != null ? new HashSet( this.variableResolvers.keySet() ) : null );
    }

    public void readExternal(final ObjectInput stream) throws IOException,
                                                      ClassNotFoundException {
        DroolsObjectInputStream droolsInputStream = (DroolsObjectInputStream) stream;

        this.previousDeclarations = (Map) droolsInputStream.readObject();
        this.localDeclarations = (Map) droolsInputStream.readObject();
        this.globals = (Map) droolsInputStream.readObject();
        this.localVariables = (Map) droolsInputStream.readObject();

        // restore resolvers
        Set resolvers = (Set) droolsInputStream.readObject();
        if ( resolvers != null ) {
            for ( Iterator it = resolvers.iterator(); it.hasNext(); ) {
                String name = (String) it.next();
                if ( !isResolveable( name ) ) {
                    addResolver( name,
View Full Code Here

        // Return the rules stored as a byte[]
        final byte[] bytes = (byte[]) stream.readObject();

        //  Use a custom ObjectInputStream that can resolve against a given classLoader
        final DroolsObjectInputStream streamWithLoader = new DroolsObjectInputStream( new ByteArrayInputStream( bytes ),
                                                                                      this.packageCompilationData.getClassLoader() );
       

        this.rules = (Map) streamWithLoader.readObject();
    }
View Full Code Here

     *
     */
    public void readExternal(final ObjectInput stream) throws IOException,
                                                      ClassNotFoundException {
        if ( stream instanceof DroolsObjectInputStream ) {
            DroolsObjectInputStream droolsStream = (DroolsObjectInputStream) stream;
            initClassLoader( droolsStream.getClassLoader() );
        } else {
            initClassLoader( Thread.currentThread().getContextClassLoader() );
        }

        this.store = (Map) stream.readObject();
        this.AST = stream.readObject();

        // Return the rules stored as a byte[]
        final byte[] bytes = (byte[]) stream.readObject();

        //  Use a custom ObjectInputStream that can resolve against a given classLoader
        final DroolsObjectInputStream streamWithLoader = new DroolsObjectInputStream( new ByteArrayInputStream( bytes ),
                                                                                      this.classLoader );
        this.invokerLookups = (Map) streamWithLoader.readObject();
    }
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

    }

    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

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.