use of org.kie.api.cdi.KSession 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);
}
}
}
}
}
Aggregations