Skip to content

Commit

Permalink
[BZ-1051585][BZ-1058254] fix kie-spring to correctly discover the app…
Browse files Browse the repository at this point in the history
…lication root url on windows
  • Loading branch information
mariofusco committed Feb 26, 2014
1 parent ccd4d6a commit 268fe75
Showing 1 changed file with 12 additions and 20 deletions.
Expand Up @@ -48,6 +48,7 @@
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Map;

@Component("kiePostProcessor")
Expand Down Expand Up @@ -103,6 +104,7 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
} else {
releaseId = new ReleaseIdImpl("org.default", "artifact","1.0.0-SNAPSHOT");
}
log.info("Found project with releaseId: " + releaseId);
KieSpringUtils.setDefaultReleaseId(releaseId);
}

Expand Down Expand Up @@ -294,29 +296,19 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
throw new RuntimeException(e);
}
if (configFileURL.toString().endsWith("service-loader-resources/")) {
String moduleName = getModuleName();
if (moduleName != null) {
if (moduleName.endsWith(".war")) {
try {
configFileURL = new URL("vfs:/content/" + moduleName + "/WEB-INF/classes/");
} catch (MalformedURLException e) {
throw new RuntimeException(e);
try {
Enumeration<URL> urls = getClass().getClassLoader().getResources("/");
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
if (url.toString().endsWith("WEB-INF/classes/")) {
configFileURL = url;
break;
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

private String getModuleName() {
String clName = getClass().getClassLoader().toString();
int start = clName.indexOf("deployment.");
if (start >= 0) {
start += "deployment.".length();
int end = Math.min(clName.indexOf(':', start), clName.indexOf('"', start));
if (end > start) {
return clName.substring(start, end);
}
}
return null;
log.info("classpath root URL: " + configFileURL);
}
}

0 comments on commit 268fe75

Please sign in to comment.