Package org.drools.runtime

Examples of org.drools.runtime.Environment


        //        List< ? > result = emf.createEntityManager().createQuery( "select i from VariableInstanceInfo i" ).getResultList();
        //        assertEquals( 5,
        //                      result.size() );
        log.info( "### Retrieving process instance ###" );

        Environment env = KnowledgeBaseFactory.newEnvironment();
        env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
                 emf );
        env.set( EnvironmentName.TRANSACTION_MANAGER,
                 ctx.getBean( "txManager" ) );
        env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,
                 new ObjectMarshallingStrategy[]{
                                                                  //  new JPAPlaceholderResolverStrategy(env),
                                                                  new SerializablePlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT )
                                                                } );
View Full Code Here


        }
        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        Collection<KnowledgePackage> kpkgs = SerializationHelper.serializeObject( kbuilder.getKnowledgePackages() );
        kbase.addKnowledgePackages( kpkgs );
        kbase = SerializationHelper.serializeObject( kbase );
         Environment env = EnvironmentFactory.newEnvironment();
        env.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, new ObjectMarshallingStrategy[]{
                    new IdentityPlaceholderResolverStrategy(ClassObjectMarshallingStrategyAcceptor.DEFAULT)});
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(null, env);
        List results = new ArrayList();
        ksession.setGlobal( "results",
                            results );
View Full Code Here

            map.putAll( getWorkItems() );
        }

        if ( jpaConfiguration != null ) {

            Environment env = KnowledgeBaseFactory.newEnvironment();
            env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
                     jpaConfiguration.getEntityManagerFactory() );
            env.set( EnvironmentName.TRANSACTION_MANAGER,
                     jpaConfiguration.getPlatformTransactionManager() );
            env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,
                     new ObjectMarshallingStrategy[]{new SerializablePlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT )} );

            if ( jpaConfiguration.getId() >= 0 ) {
                ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( jpaConfiguration.getId(),
                                                                             getKbase(),
View Full Code Here

    return kbase;
  }
 
  private StatefulKnowledgeSession createKnowledgeSession(KnowledgeBase kbase) {
//    return kbase.newStatefulKnowledgeSession();
      Environment env = KnowledgeBaseFactory.newEnvironment();
      env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
      env.set(EnvironmentName.TRANSACTION_MANAGER,
          TransactionManagerServices.getTransactionManager());
    return JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
  }
View Full Code Here

 
  private StatefulKnowledgeSession restoreSession(StatefulKnowledgeSession ksession) {
//    return ksession;
    int id = ksession.getId();
    KnowledgeBase kbase = ksession.getKnowledgeBase();
    Environment env = ksession.getEnvironment();
    return JPAKnowledgeService.loadStatefulKnowledgeSession(id, kbase, null, env);
  }
View Full Code Here

        final Package pkg = builder.getPackage();

        RuleBase ruleBase = getRuleBase();
        ruleBase.addPackage( pkg );
        ruleBase = SerializationHelper.serializeObject( ruleBase );
        Environment env = EnvironmentFactory.newEnvironment();
        env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,
                 new ObjectMarshallingStrategy[]{
                        new IdentityPlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT )} );
        StatefulSession session = ruleBase.newStatefulSession( null,
                                                               env );
View Full Code Here

        RuleBase ruleBase = getRuleBase();
        Package pkg = builder.getPackage();
        ruleBase.addPackage( pkg );
        ruleBase = SerializationHelper.serializeObject( ruleBase );
        Environment env = EnvironmentFactory.newEnvironment();
        env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,
                 new ObjectMarshallingStrategy[]{
                        new IdentityPlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT )} );
        StatefulSession session = ruleBase.newStatefulSession( null,
                                                               env );
        session.insert( cell1 );
View Full Code Here

                      ResourceType.DRL );

        if ( kbuilder.hasErrors() ) {
            fail( kbuilder.getErrors().toString() );
        }
        Environment env = EnvironmentFactory.newEnvironment();
        env.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, new ObjectMarshallingStrategy[]{
                    new IdentityPlaceholderResolverStrategy(ClassObjectMarshallingStrategyAcceptor.DEFAULT)});
        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(null, env);
View Full Code Here

                      ResourceType.DRL );

        if ( kbuilder.hasErrors() ) {
            fail( kbuilder.getErrors().toString() );
        }
         Environment env = EnvironmentFactory.newEnvironment();
        env.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, new ObjectMarshallingStrategy[]{
                    new IdentityPlaceholderResolverStrategy(ClassObjectMarshallingStrategyAcceptor.DEFAULT)});
       
        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
View Full Code Here

   
                // 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();
                StatefulKnowledgeSession ksession = marshaller.unmarshall( bais,
                                                                           conf,
                                                                           environment );
                session = (StatefulSession) ((StatefulKnowledgeSessionImpl) ksession).session;
   
View Full Code Here

TOP

Related Classes of org.drools.runtime.Environment

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.