private static InternalKieModule fetchKModule(URL url, String fixedURL) { if (url.getPath().endsWith("-spring.xml")) { // the entire kmodule creation is happening in the kie-spring module, // hence we force a null return fetchKModuleFromSpring(url, fixedURL); return null; } KieModuleModel kieProject = KieModuleModelImpl.fromXML(url); setDefaultsforEmptyKieModule(kieProject); String pomProperties = getPomProperties(fixedURL); if (pomProperties == null) { log.warn( "Cannot find maven pom properties for this project. Using the container's default ReleaseId"); } ReleaseId releaseId = pomProperties != null ? ReleaseIdImpl.fromPropertiesString(pomProperties) : KieServices.Factory.get().getRepository().getDefaultReleaseId(); String rootPath = fixedURL; if (rootPath.lastIndexOf(':') > 0) { rootPath = IoUtils.asSystemSpecificPath(rootPath, rootPath.lastIndexOf(':')); } return createInternalKieModule(url, fixedURL, kieProject, releaseId, rootPath); }
private void addKieModuleToRepo(KieModuleModel kieProject) { KieBuilderImpl.setDefaultsforEmptyKieModule(kieProject); InternalKieModule kJar = createKieModule(kieProject); if (kJar != null) { KieServices ks = KieServices.Factory.get(); log.info("adding KieModule from " + configFileURL.toExternalForm() + " to repository."); ks.getRepository().addKieModule(kJar); KieSpringUtils.setReleaseIdForContext(releaseId, context); } }
private static KieModuleModel getKieModuleModelFromJar(File jar) { ZipFile zipFile = null; try { zipFile = new ZipFile(jar); ZipEntry zipEntry = zipFile.getEntry(KieModuleModelImpl.KMODULE_JAR_PATH); KieModuleModel kieModuleModel = KieModuleModelImpl.fromXML(zipFile.getInputStream(zipEntry)); setDefaultsforEmptyKieModule(kieModuleModel); return kieModuleModel; } catch (Exception e) { } finally { if (zipFile != null) { try { zipFile.close(); } catch (IOException e) { } } } return null; }