Package org.kie.api.persistence.jpa

Examples of org.kie.api.persistence.jpa.KieStoreServices


       
        env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,
                 new ObjectMarshallingStrategy[]{new JPAPlaceholderResolverStrategy( env ),
                                                                    new SerializablePlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT )} );

        final KieStoreServices kstore = (KieStoreServices) ctx.getBean( "kstore1" );
        final KieBase kbRollback = (KieBase) ctx.getBean( "kbRollback" );

        TransactionTemplate txTemplate = new TransactionTemplate( txManager );
        final KieSession ksession = (KieSession) txTemplate.execute( new TransactionCallback() {

            public Object doInTransaction(TransactionStatus status) {
                KieSession kNewSession = kstore.newKieSession( kbRollback,
                                                               null,
                                                               env );
                kNewSession.setGlobal( "list",
                                       list );
                kNewSession.insert( 1 );
View Full Code Here


                 new ObjectMarshallingStrategy[]{
                                                                  //  new JPAPlaceholderResolverStrategy(env),
                                                                  new SerializablePlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT )
                                                                } );

        KieStoreServices kstore = (KieStoreServices) ctx.getBean( "kstore1" );
        KieBase kbase1 = (KieBase) ctx.getBean( "kbase1" );
        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );

        processInstance = (WorkflowProcessInstance) service.getProcessInstance( processInstance.getId() );
View Full Code Here

    private KieSession getPersistentKieSession(Map<String, Object> environmentOverrides, Integer sessionId) {
        if (_containerModel != null) {
            String baseName = _containerModel.getBaseName();
            KieBase base = baseName != null ? _kieContainer.getKieBase(baseName) : _kieContainer.getKieBase();
            KieStoreServices kieStoreServices = KieServices.Factory.get().getStoreServices();
            Environment environment = Environments.getEnvironment(environmentOverrides);
            KieSession session = null;
            if (sessionId != null) {
                session = kieStoreServices.loadKieSession(sessionId, base, _sessionConfiguration, environment);
            }
            if (session == null) {
                session = kieStoreServices.newKieSession(base, _sessionConfiguration, environment);
            }
            return session;
        }
        throw CommonKnowledgeMessages.MESSAGES.manifestContainerRequiredInConfigurationForPersistentSessions();
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public KnowledgeSession getPersistentSession(Map<String, Object> environmentOverrides, Integer sessionId) {
        KieStoreServices kieStoreServices = KieServices.Factory.get().getStoreServices();
        Environment env = Environments.getEnvironment(environmentOverrides);
        KieSession stateful = null;
        if (sessionId != null) {
            stateful = kieStoreServices.loadKieSession(sessionId, _base, _sessionConfiguration, env);
        }
        if (stateful == null) {
            stateful = kieStoreServices.newKieSession(_base, _sessionConfiguration, env);
        }
        KnowledgeDisposal loggersDisposal = Loggers.registerLoggersForDisposal(getModel(), getLoader(), stateful);
        Listeners.registerListeners(getModel(), getLoader(), stateful);
        Channels.registerChannels(getModel(), getLoader(), getDomain(), stateful);
        return new KnowledgeSession(stateful, false, true, loggersDisposal);
View Full Code Here

        env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
                 ctx.getBean( "myEmf" ) );
        env.set( EnvironmentName.TRANSACTION_MANAGER,
                 ctx.getBean( "txManager" ) );
        */
        KieStoreServices kstore = (KieStoreServices) ctx.getBean( "kstore1" );
        KieBase kbase1 = (KieBase) ctx.getBean( "kbProcessWorkItems" );
        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );
        processInstance = service.getProcessInstance( processInstance.getId() );
        assertNotNull( processInstance );
        service.dispose();

        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );
        service.getWorkItemManager().completeWorkItem( workItem.getId(),
                                                       null );

        workItem = handler.getWorkItem();
        assertNotNull( workItem );
        service.dispose();

        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );
        processInstance = service.getProcessInstance( processInstance.getId() );
        assertNotNull( processInstance );
        service.dispose();

        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );
        service.getWorkItemManager().completeWorkItem( workItem.getId(),
                                                       null );

        workItem = handler.getWorkItem();
        assertNotNull( workItem );
        service.dispose();

        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );
        processInstance = service.getProcessInstance( processInstance.getId() );
        service.dispose();

        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );
        service.getWorkItemManager().completeWorkItem( workItem.getId(),
                                                       null );

        workItem = handler.getWorkItem();
        assertNull( workItem );
        service.dispose();

        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );
        processInstance = service.getProcessInstance( processInstance.getId() );
        service.dispose();
View Full Code Here

        env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
                 ctx.getBean( "myEmf" ) );
        env.set( EnvironmentName.TRANSACTION_MANAGER,
                 ctx.getBean( "txManager" ) );
        */
        KieStoreServices kstore = (KieStoreServices) ctx.getBean( "kstore1" );
        KieBase kbase1 = (KieBase) ctx.getBean( "kbProcessWorkItems" );
        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );

        processInstance = service.getProcessInstance( processInstance.getId() );
        assertNotNull( processInstance );
        service.dispose();

        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );
        service.getWorkItemManager().completeWorkItem( workItem.getId(),
                                                       null );

        workItem = handler.getWorkItem();
        assertNotNull( workItem );
        service.dispose();

        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );
        processInstance = service.getProcessInstance( processInstance.getId() );
        assertNotNull( processInstance );
        service.dispose();

        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );
        service.getWorkItemManager().abortWorkItem( workItem.getId() );

        workItem = handler.getWorkItem();
        assertNotNull( workItem );
        service.dispose();

        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );
        processInstance = service.getProcessInstance( processInstance.getId() );
        assertNotNull( processInstance );
        service.dispose();

        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );
        service.getWorkItemManager().completeWorkItem( workItem.getId(),
                                                       null );
        workItem = handler.getWorkItem();
        assertNull( workItem );
        service.dispose();

        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );
        processInstance = service.getProcessInstance( processInstance.getId() );
        assertNull( processInstance );
View Full Code Here

        env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
                 ctx.getBean( "myEmf" ) );
        env.set( EnvironmentName.TRANSACTION_MANAGER,
                 ctx.getBean( "txManager" ) );
        */
        KieStoreServices kstore = (KieStoreServices) ctx.getBean("kstore1");
        KieBase kbase1 = (KieBase) ctx.getBean("kb_persistence");
        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        processInstance = service.getProcessInstance(processInstance.getId());
        assertNotNull(processInstance);
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        service.getWorkItemManager().completeWorkItem(workItem.getId(),
                null);

        workItem = handler.getWorkItem();
        assertNotNull(workItem);
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        processInstance = service.getProcessInstance(processInstance.getId());
        assertNotNull(processInstance);
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        service.getWorkItemManager().completeWorkItem(workItem.getId(),
                null);

        workItem = handler.getWorkItem();
        assertNotNull(workItem);
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        processInstance = service.getProcessInstance(processInstance.getId());
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        service.getWorkItemManager().completeWorkItem(workItem.getId(),
                null);

        workItem = handler.getWorkItem();
        assertNull(workItem);
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        processInstance = service.getProcessInstance(processInstance.getId());
        service.dispose();
View Full Code Here

        env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
                 ctx.getBean( "myEmf" ) );
        env.set( EnvironmentName.TRANSACTION_MANAGER,
                 ctx.getBean( "txManager" ) );
        */
        KieStoreServices kstore = (KieStoreServices) ctx.getBean("kstore1");
        KieBase kbase1 = (KieBase) ctx.getBean("kb_persistence");
        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);

        processInstance = service.getProcessInstance(processInstance.getId());
        assertNotNull(processInstance);
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        service.getWorkItemManager().completeWorkItem(workItem.getId(),
                null);

        workItem = handler.getWorkItem();
        assertNotNull(workItem);
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        processInstance = service.getProcessInstance(processInstance.getId());
        assertNotNull(processInstance);
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        service.getWorkItemManager().abortWorkItem(workItem.getId());

        workItem = handler.getWorkItem();
        assertNotNull(workItem);
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        processInstance = service.getProcessInstance(processInstance.getId());
        assertNotNull(processInstance);
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        service.getWorkItemManager().completeWorkItem(workItem.getId(),
                null);
        workItem = handler.getWorkItem();
        assertNull(workItem);
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        processInstance = service.getProcessInstance(processInstance.getId());
        assertNull(processInstance);
View Full Code Here

        env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
                 ctx.getBean( "myEmf" ) );
        env.set( EnvironmentName.TRANSACTION_MANAGER,
                 ctx.getBean( "txManager" ) );
        */
        KieStoreServices kstore = (KieStoreServices) ctx.getBean("kstore1");
        KieBase kbase1 = (KieBase) ctx.getBean("kb_persistence");
        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);

        processInstance = (RuleFlowProcessInstance) service.getProcessInstance(processInstanceId);
        assertNotNull(processInstance);

        Collection<NodeInstance> nodeInstances = processInstance.getNodeInstances();
        assertEquals(1,
                nodeInstances.size());
        SubProcessNodeInstance subProcessNodeInstance = (SubProcessNodeInstance) nodeInstances.iterator().next();
        long subProcessInstanceId = subProcessNodeInstance.getProcessInstanceId();
        RuleFlowProcessInstance subProcessInstance = (RuleFlowProcessInstance) service.getProcessInstance(subProcessInstanceId);
        assertNotNull(subProcessInstance);
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        service.getWorkItemManager().completeWorkItem(workItem.getId(),
                null);
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        subProcessInstance = (RuleFlowProcessInstance) service.getProcessInstance(subProcessInstanceId);
        assertNull(subProcessInstance);
View Full Code Here

        env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
                 ctx.getBean( "myEmf" ) );
        env.set( EnvironmentName.TRANSACTION_MANAGER,
                 ctx.getBean( "txManager" ) );
        */
        KieStoreServices kstore = (KieStoreServices) ctx.getBean("kstore1");
        KieBase kbase1 = (KieBase) ctx.getBean("kb_persistence");
        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);

        log.info("---> load session: " + sessionId);
        processInstance = service.getProcessInstance(procId);
        log.info("---> GetProcessInstanceCommand id: " + procId);
        assertNotNull(processInstance);

        Thread.sleep(1000);
        log.info("---> session disposed");
        service.dispose();

        service = kstore.loadKieSession(sessionId,
                kbase1,
                null,
                env);
        log.info("---> load session: " + sessionId);
        Thread.sleep(3000);
View Full Code Here

TOP

Related Classes of org.kie.api.persistence.jpa.KieStoreServices

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.