Package org.drools.compiler.kie.builder.impl

Examples of org.drools.compiler.kie.builder.impl.KieProject


                kModule.addKieDependency(kmoduleDep);
            }

            KieContainerImpl kContainer = (KieContainerImpl) ks.newKieContainer(kModule.getReleaseId());

            KieProject kieProject = kContainer.getKieProject();
            ResultsImpl messages = kieProject.verify();

            List<Message> errors = messages.filterMessages(Message.Level.ERROR);
            if (!errors.isEmpty()) {
                for (Message error : errors) {
                    getLog().error(error.toString());
View Full Code Here


                           entry.getValue(),
                           releaseId.toString() );
                return;
            }
        }
        KieProject kProject = kieContainer.getKieProject();

        KieBaseModel kBaseModel = null;
        String kBaseQName = entry.getValue();
        if ( StringUtils.isEmpty( kBaseQName  )) {
            kBaseModel = kProject.getDefaultKieBaseModel();
        } else {
            kBaseModel = kProject.getKieBaseModel( kBaseQName );  
        }       
        if ( kBaseModel == null ) {
            log.error( "Annotation @KBase({}) found, but no KieBaseModel exist.\nEither the required kproject.xml does not exist, was corrupted, or mising the KieBase entry",
                       kBaseQName );
            return;
        }
        if ( !kBaseModel.getScope().trim().equals( entry.getScope().getClass().getName() ) ) {
            try {
                if ( kBaseModel.getScope().indexOf( '.' ) >= 0 ) {
                    entry.setScope( (Class< ? extends Annotation>) Class.forName( kBaseModel.getScope() ) );
                } else {
                    entry.setScope( (Class< ? extends Annotation>) Class.forName( "javax.enterprise.context." + kBaseModel.getScope() ) );
                }
            } catch ( ClassNotFoundException e ) {
                log.error( "KieBaseModule {} overrides default annotation, but it was not able to find it {}\n{}",
                           new String[]{kBaseQName, kBaseModel.getScope(), e.getMessage()} );
            }
        }
        KBaseBean bean = new KBaseBean( kBaseModel,
                                        kieContainer,
                                        entry.getKReleaseId(),
                                        entry.getScope(),
                                        entry.getName(),
                                        entry.getInjectionPoints() );
        if ( log.isDebugEnabled() ) {
            InternalKieModule kModule = kProject.getKieModuleForKBase( kBaseQName );
            log.debug( "Added Bean for @KBase({})",
                       kBaseQName,
                       kModule );
        }
        abd.addBean( bean );
View Full Code Here

                           entry.getValue(),
                           releaseId.toString() );
                return;
            }
        }
        KieProject kProject = kieContainer.getKieProject();

        String kSessionName = entry.getValue();
        KieSessionModel kSessionModel = null;
        if ( StringUtils.isEmpty( kSessionName  )) {
            kSessionModel = ( entry.getType() == KieSession.class ) ? kProject.getDefaultKieSession() : kProject.getDefaultStatelessKieSession();
        } else {
            kSessionModel =  kProject.getKieSessionModel(kSessionName);
        }        
        if ( kSessionModel == null ) {
            log.error( "Annotation @KSession({}) found, but no KieSessioneModel exist.\nEither the required kproject.xml does not exist, was corrupted, or mising the KieBase entry",
                       kSessionName );
            return;
        }

        if ( !kSessionModel.getScope().trim().equals( entry.getScope().getClass().getName() ) ) {
            try {
                if ( kSessionModel.getScope().indexOf( '.' ) >= 0 ) {
                    entry.setScope( (Class< ? extends Annotation>) Class.forName( kSessionModel.getScope() ) );
                } else {
                    entry.setScope( (Class< ? extends Annotation>) Class.forName( "javax.enterprise.context." + kSessionModel.getScope() ) );
                }
            } catch ( ClassNotFoundException e ) {
                log.error( "KieBaseModule {} overrides default annotation, but it was not able to find it {}\n{}",
                           new String[]{kSessionName, kSessionModel.getScope(), e.getMessage()} );
            }
        }

        if ( KieSessionType.STATELESS.equals( kSessionModel.getType() ) ) {
            if ( log.isDebugEnabled() ) {
                InternalKieModule kModule = kProject.getKieModuleForKBase( ((KieSessionModelImpl) kSessionModel).getKieBaseModel().getName() );
                log.debug( "Added Bean for Stateless @KSession({}) from: {}",
                           kSessionName,
                           kModule );
            }
            abd.addBean( new StatelessKSessionBean( kSessionModel,
                                                    kieContainer,
                                                    entry.getKReleaseId(),
                                                    entry.getScope(),
                                                    entry.getName(),
                                                    entry.getInjectionPoints() ) );
        } else {
            InternalKieModule kModule = kProject.getKieModuleForKBase( ((KieSessionModelImpl) kSessionModel).getKieBaseModel().getName() );
            log.debug( "Added Bean for Stateful @KSession({})  from: {}",
                       kSessionName,
                       kModule );
            abd.addBean( new StatefulKSessionBean( kSessionModel,
                                                   kieContainer,
View Full Code Here

    public Object resolveKSession(String id, ReleaseId releaseId) {
        KieContainer kieContainer = resolveKContainer(releaseId);

        // KieBase kbase = resolveKBase(kbaseName, releaseId);
        KieProject kProject = ((KieContainerImpl) kieContainer).getKieProject();
        KieSessionModel kieSessionModel = kProject.getKieSessionModel(id);
        if ( kieSessionModel == null) {
            return null;
        }
        if (kieSessionModel.getType() == KieSessionModel.KieSessionType.STATEFUL) {
            return ((KieContainerImpl) kieContainer).getKieSession(id);
View Full Code Here

        KieContainer kieContainer = resolveKContainer(releaseId);
        return resolveKSession(kieContainer, id);
    }

    public Object resolveKSession(KieContainer kieContainer, String id) {
        KieProject kProject = ((KieContainerImpl) kieContainer).getKieProject();
        KieSessionModel kieSessionModel = kProject.getKieSessionModel(id);
        if (kieSessionModel.getType() == KieSessionModel.KieSessionType.STATEFUL) {
            return ((KieContainerImpl) kieContainer).getKieSession(id);
        } else if (kieSessionModel.getType() == KieSessionModel.KieSessionType.STATELESS) {
            return ((KieContainerImpl) kieContainer).getStatelessKieSession(id);
        }
View Full Code Here

                           entry.getValue(),
                           releaseId.toString() );
                return;
            }
        }
        KieProject kProject = kieContainer.getKieProject();

        KieBaseModel kBaseModel = null;
        String kBaseQName = entry.getValue();
        if ( StringUtils.isEmpty( kBaseQName  )) {
            kBaseModel = kProject.getDefaultKieBaseModel();
        } else {
            kBaseModel = kProject.getKieBaseModel( kBaseQName );  
        }       
        if ( kBaseModel == null ) {
            log.error( "Annotation @KBase({}) found, but no KieBaseModel exist.\nEither the required kproject.xml does not exist, was corrupted, or mising the KieBase entry",
                       kBaseQName );
            return;
        }
        if ( !kBaseModel.getScope().trim().equals( entry.getScope().getClass().getName() ) ) {
            try {
                if ( kBaseModel.getScope().indexOf( '.' ) >= 0 ) {
                    entry.setScope( (Class< ? extends Annotation>) Class.forName( kBaseModel.getScope() ) );
                } else {
                    entry.setScope( (Class< ? extends Annotation>) Class.forName( "javax.enterprise.context." + kBaseModel.getScope() ) );
                }
            } catch ( ClassNotFoundException e ) {
                log.error( "KieBaseModule {} overrides default annotation, but it was not able to find it {}\n{}",
                           new String[]{kBaseQName, kBaseModel.getScope(), e.getMessage()} );
            }
        }
        KBaseBean bean = new KBaseBean( kBaseModel,
                                        kieContainer,
                                        entry.getKReleaseId(),
                                        entry.getScope(),
                                        entry.getName(),
                                        entry.getInjectionPoints() );
        if ( log.isDebugEnabled() ) {
            InternalKieModule kModule = kProject.getKieModuleForKBase( kBaseQName );
            log.debug( "Added Bean for @KBase({})",
                       kBaseQName,
                       kModule );
        }
        abd.addBean( bean );
View Full Code Here

                           entry.getValue(),
                           releaseId.toString() );
                return;
            }
        }
        KieProject kProject = kieContainer.getKieProject();

        String kSessionName = entry.getValue();
        KieSessionModel kSessionModel = null;
        if ( StringUtils.isEmpty( kSessionName  )) {
            kSessionModel = ( entry.getType() == KieSession.class ) ? kProject.getDefaultKieSession() : kProject.getDefaultStatelessKieSession();
        } else {
            kSessionModel =  kProject.getKieSessionModel( kSessionName );  
        }        
        if ( kSessionModel == null ) {
            log.error( "Annotation @KSession({}) found, but no KieSessioneModel exist.\nEither the required kproject.xml does not exist, was corrupted, or mising the KieBase entry",
                       kSessionName );
            return;
        }

        if ( !kSessionModel.getScope().trim().equals( entry.getScope().getClass().getName() ) ) {
            try {
                if ( kSessionModel.getScope().indexOf( '.' ) >= 0 ) {
                    entry.setScope( (Class< ? extends Annotation>) Class.forName( kSessionModel.getScope() ) );
                } else {
                    entry.setScope( (Class< ? extends Annotation>) Class.forName( "javax.enterprise.context." + kSessionModel.getScope() ) );
                }
            } catch ( ClassNotFoundException e ) {
                log.error( "KieBaseModule {} overrides default annotation, but it was not able to find it {}\n{}",
                           new String[]{kSessionName, kSessionModel.getScope(), e.getMessage()} );
            }
        }

        if ( KieSessionType.STATELESS.equals( kSessionModel.getType() ) ) {
            if ( log.isDebugEnabled() ) {
                InternalKieModule kModule = kProject.getKieModuleForKBase( ((KieSessionModelImpl) kSessionModel).getKieBaseModel().getName() );
                log.debug( "Added Bean for Stateless @KSession({}) from: {}",
                           kSessionName,
                           kModule );
            }
            abd.addBean( new StatelessKSessionBean( kSessionModel,
                                                    kieContainer,
                                                    entry.getKReleaseId(),
                                                    entry.getScope(),
                                                    entry.getName(),
                                                    entry.getInjectionPoints() ) );
        } else {
            InternalKieModule kModule = kProject.getKieModuleForKBase( ((KieSessionModelImpl) kSessionModel).getKieBaseModel().getName() );
            log.debug( "Added Bean for Stateful @KSession({})  from: {}",
                       kSessionName,
                       kModule );
            abd.addBean( new StatefulKSessionBean( kSessionModel,
                                                   kieContainer,
View Full Code Here

                           entry.getValue(),
                           releaseId.toString() );
                return;
            }
        }
        KieProject kProject = kieContainer.getKieProject();

        KieBaseModel kBaseModel = null;
        String kBaseQName = entry.getValue();
        if ( StringUtils.isEmpty( kBaseQName  )) {
            kBaseModel = kProject.getDefaultKieBaseModel();
        } else {
            kBaseModel = kProject.getKieBaseModel( kBaseQName );  
        }       
        if ( kBaseModel == null ) {
            log.error( "Annotation @KBase({}) found, but no KieBaseModel exist.\nEither the required kproject.xml does not exist, was corrupted, or mising the KieBase entry",
                       kBaseQName );
            return;
        }
        if ( !kBaseModel.getScope().trim().equals( entry.getScope().getClass().getName() ) ) {
            try {
                if ( kBaseModel.getScope().indexOf( '.' ) >= 0 ) {
                    entry.setScope( (Class< ? extends Annotation>) Class.forName( kBaseModel.getScope() ) );
                } else {
                    entry.setScope( (Class< ? extends Annotation>) Class.forName( "javax.enterprise.context." + kBaseModel.getScope() ) );
                }
            } catch ( ClassNotFoundException e ) {
                log.error( "KieBaseModule {} overrides default annotation, but it was not able to find it {}\n{}",
                           new String[]{kBaseQName, kBaseModel.getScope(), e.getMessage()} );
            }
        }
        KBaseBean bean = new KBaseBean( kBaseModel,
                                        kieContainer,
                                        entry.getKReleaseId(),
                                        entry.getScope(),
                                        entry.getName(),
                                        entry.getInjectionPoints() );
        if ( log.isDebugEnabled() ) {
            InternalKieModule kModule = kProject.getKieModuleForKBase( kBaseQName );
            log.debug( "Added Bean for @KBase({})",
                       kBaseQName,
                       kModule );
        }
        abd.addBean( bean );
View Full Code Here

                           entry.getValue(),
                           releaseId.toString() );
                return;
            }
        }
        KieProject kProject = kieContainer.getKieProject();

        String kSessionName = entry.getValue();
        KieSessionModel kSessionModel = null;
        if ( StringUtils.isEmpty( kSessionName  )) {
            kSessionModel = ( entry.getType() == KieSession.class ) ? kProject.getDefaultKieSession() : kProject.getDefaultStatelessKieSession();
        } else {
            kSessionModel =  kProject.getKieSessionModel( kSessionName );  
        }        
        if ( kSessionModel == null ) {
            log.error( "Annotation @KSession({}) found, but no KieSessioneModel exist.\nEither the required kproject.xml does not exist, was corrupted, or mising the KieBase entry",
                       kSessionName );
            return;
        }

        if ( !kSessionModel.getScope().trim().equals( entry.getScope().getClass().getName() ) ) {
            try {
                if ( kSessionModel.getScope().indexOf( '.' ) >= 0 ) {
                    entry.setScope( (Class< ? extends Annotation>) Class.forName( kSessionModel.getScope() ) );
                } else {
                    entry.setScope( (Class< ? extends Annotation>) Class.forName( "javax.enterprise.context." + kSessionModel.getScope() ) );
                }
            } catch ( ClassNotFoundException e ) {
                log.error( "KieBaseModule {} overrides default annotation, but it was not able to find it {}\n{}",
                           new String[]{kSessionName, kSessionModel.getScope(), e.getMessage()} );
            }
        }

        if ( KieSessionType.STATELESS.equals( kSessionModel.getType() ) ) {
            if ( log.isDebugEnabled() ) {
                InternalKieModule kModule = kProject.getKieModuleForKBase( ((KieSessionModelImpl) kSessionModel).getKieBaseModel().getName() );
                log.debug( "Added Bean for Stateless @KSession({}) from: {}",
                           kSessionName,
                           kModule );
            }
            abd.addBean( new StatelessKSessionBean( kSessionModel,
                                                    kieContainer,
                                                    entry.getKReleaseId(),
                                                    entry.getScope(),
                                                    entry.getName(),
                                                    entry.getInjectionPoints() ) );
        } else {
            InternalKieModule kModule = kProject.getKieModuleForKBase( ((KieSessionModelImpl) kSessionModel).getKieBaseModel().getName() );
            log.debug( "Added Bean for Stateful @KSession({})  from: {}",
                       kSessionName,
                       kModule );
            abd.addBean( new StatefulKSessionBean( kSessionModel,
                                                   kieContainer,
View Full Code Here

        try {
            KieRepository kr = ks.getRepository();
            KieModule kModule = kr.addKieModule(ks.getResources().newFileSystemResource(sourceFolder));
            KieContainerImpl kContainer = (KieContainerImpl) ks.newKieContainer(kModule.getReleaseId());

            KieProject kieProject = kContainer.getKieProject();
            ResultsImpl messages = kieProject.verify();

            List<Message> errors = messages.filterMessages(Message.Level.ERROR);
            if (!errors.isEmpty()) {
                for (Message error : errors) {
                    getLog().error(error.toString());
View Full Code Here

TOP

Related Classes of org.drools.compiler.kie.builder.impl.KieProject

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.