Skip to content

Commit

Permalink
[BZ-1042867] fix bundle discovery in kie-aries-blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
mariofusco committed Jan 8, 2014
1 parent 96aae6b commit 5bdb23d
Showing 1 changed file with 16 additions and 2 deletions.
Expand Up @@ -17,6 +17,7 @@
package org.kie.aries.blueprint.namespace;

import org.apache.aries.blueprint.BeanProcessor;
import org.apache.aries.blueprint.ExtendedBeanMetadata;
import org.apache.aries.blueprint.ParserContext;
import org.apache.aries.blueprint.PassThroughMetadata;
import org.apache.aries.blueprint.mutable.MutableBeanArgument;
Expand All @@ -41,6 +42,7 @@
import org.kie.aries.blueprint.factorybeans.KBaseOptions;
import org.kie.aries.blueprint.factorybeans.KSessionOptions;
import org.kie.aries.blueprint.factorybeans.KieObjectsFactoryBean;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import org.osgi.service.blueprint.container.BlueprintContainer;
import org.osgi.service.blueprint.reflect.BeanArgument;
Expand Down Expand Up @@ -108,7 +110,7 @@ public void afterPropertiesSet(){
} else {
configFileURL = resources.get(0);
configFilePath = configFileURL.getPath();
log.debug(" :: Trying to intialize the KieModule from "+configFileURL+" :: ");
log.debug(" :: Trying to intialize the KieModule from " + configFileURL + " :: ");
}
if ( configFilePath == null) {
throw new RuntimeException("Failure creating a KieModule. Unable to determine the Configuration File Path.");
Expand All @@ -130,7 +132,7 @@ protected void injectKieModule(KieModuleModel kieModuleModel) {
}

private void createOsgiKieModule() {
configFileURL = FrameworkUtil.getBundle(this.getClass()).getEntry("/");
configFileURL = getConfigFileURL();
if (releaseId == null) {
releaseId = KieRepositoryImpl.INSTANCE.getDefaultReleaseId();
}
Expand All @@ -146,6 +148,18 @@ private void createOsgiKieModule() {
}
}

private URL getConfigFileURL() {
try {
Method m = Class.forName(blueprintContainer.getClass().getName(),
true,
blueprintContainer.getClass().getClassLoader())
.getMethod("getBundle");
Bundle bundle = (Bundle)m.invoke(blueprintContainer);
return bundle.getEntry("/");
} catch (Exception e) { }
return FrameworkUtil.getBundle(this.getClass()).getEntry("/");
}

private InternalKieModule createOsgiKModule(KieModuleModel kieProject) {
Method m;
try {
Expand Down

0 comments on commit 5bdb23d

Please sign in to comment.