Search in sources :

Example 1 with KReleaseId

use of org.kie.api.cdi.KReleaseId in project drools by kiegroup.

the class KieCDIExtension method processInjectionTarget.

public <T> void processInjectionTarget(@Observes ProcessInjectionTarget<T> pit) {
    if (classpathKContainer == null) {
        init();
    }
    KieServices ks = KieServices.Factory.get();
    // Find all uses of KieBaseModel and KieSessionModel and add to Set index
    if (!pit.getInjectionTarget().getInjectionPoints().isEmpty()) {
        for (InjectionPoint ip : pit.getInjectionTarget().getInjectionPoints()) {
            boolean kBaseExists = false;
            boolean kSessionExists = false;
            boolean kContainerExists = false;
            Class clazz = getClassType(ip);
            if (clazz != null) {
                KBase kBase = null;
                KSession kSession = null;
                if ((KieSession.class.isAssignableFrom(clazz) || StatelessKieSession.class.isAssignableFrom(clazz))) {
                    kSession = ip.getAnnotated().getAnnotation(KSession.class);
                    kSessionExists = true;
                } else if (KieBase.class.isAssignableFrom(clazz)) {
                    kBaseExists = true;
                    kBase = ip.getAnnotated().getAnnotation(KBase.class);
                } else if (KieContainer.class.isAssignableFrom(clazz)) {
                    kContainerExists = true;
                }
                if (!kSessionExists && !kBaseExists && !kContainerExists) {
                    continue;
                }
                KReleaseId kReleaseId = ip.getAnnotated().getAnnotation(KReleaseId.class);
                ReleaseId releaseId = null;
                if (kReleaseId != null) {
                    releaseId = ks.newReleaseId(kReleaseId.groupId(), kReleaseId.artifactId(), kReleaseId.version());
                    gavs.put(releaseId, null);
                }
                Class<? extends Annotation> scope = getScope(pit);
                if (kBaseExists) {
                    addKBaseInjectionPoint(ip, kBase, scope, releaseId, kReleaseId);
                } else if (kSessionExists) {
                    addKSessionInjectionPoint(ip, kSession, scope, releaseId, kReleaseId);
                } else if (kContainerExists) {
                    addKContainerInjectionPoint(ip, null, scope, releaseId, kReleaseId);
                }
            }
        }
    }
}
Also used : InjectionPoint(javax.enterprise.inject.spi.InjectionPoint) KieBase(org.kie.api.KieBase) KieServices(org.kie.api.KieServices) KSession(org.kie.api.cdi.KSession) KReleaseId(org.kie.api.cdi.KReleaseId) KReleaseId(org.kie.api.cdi.KReleaseId) ReleaseId(org.kie.api.builder.ReleaseId) KBase(org.kie.api.cdi.KBase)

Aggregations

InjectionPoint (javax.enterprise.inject.spi.InjectionPoint)1 KieBase (org.kie.api.KieBase)1 KieServices (org.kie.api.KieServices)1 ReleaseId (org.kie.api.builder.ReleaseId)1 KBase (org.kie.api.cdi.KBase)1 KReleaseId (org.kie.api.cdi.KReleaseId)1 KSession (org.kie.api.cdi.KSession)1