X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.osgi%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fosgi%2Finternal%2FBundleModuleSource.java;h=a805e6026607c2f31e708651ba67fa982d5d5d90;hp=87b78d6ebf44434c61a252baf8fc339886bc9d1f;hb=5704e9deb877257b2c0c542e185fda124cf3ce37;hpb=9c21f5837af6102a9dd05cb6a425bafe25576822 diff --git a/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleModuleSource.java b/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleModuleSource.java index 87b78d6eb..a805e6026 100644 --- a/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleModuleSource.java +++ b/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleModuleSource.java @@ -14,6 +14,7 @@ import java.util.Arrays; import org.eclipse.core.runtime.FileLocator; import org.osgi.framework.Bundle; +import org.osgi.framework.BundleException; import org.osgi.framework.wiring.BundleWiring; import org.simantics.scl.compiler.internal.codegen.types.JavaReferenceValidatorFactory; import org.simantics.scl.compiler.module.ImportDeclaration; @@ -80,13 +81,13 @@ public class BundleModuleSource extends EncodedTextualModuleSource implements Up } return digest.digest(); } catch (NoSuchAlgorithmException e) { - LOGGER.error("No SHA1 algorithm available", e); + LOGGER.error("No SHA1 algorithm found", e); return new byte[0]; } finally { stream.close(); } } catch(IOException e) { - LOGGER.error("Could not compute digest for {}", this); + LOGGER.error("Could not compute digest for {}", getModuleName(), e); return new byte[0]; } } @@ -104,17 +105,27 @@ public class BundleModuleSource extends EncodedTextualModuleSource implements Up } return url.openStream(); } - + @Override public ClassLoader getClassLoader() { - if(bundle.getSymbolicName().equals("org.simantics.scl.runtime")) + if (bundle.getSymbolicName().equals("org.simantics.scl.runtime")) return Type.class.getClassLoader(); else { BundleWiring wiring = bundle.adapt(BundleWiring.class); - if(wiring != null) + if (wiring == null && bundle.getState() == Bundle.INSTALLED) { + try { + bundle.start(); + } catch (BundleException e) { + LOGGER.error("Could not start bundle {}", bundle.getSymbolicName(), e); + } + wiring = bundle.adapt(BundleWiring.class); + } + if (wiring != null) { return wiring.getClassLoader(); - else + } else { + LOGGER.error("Couldn't find class loader for bundle {} with state {}", bundle.getSymbolicName(), BundleUtils.resolveBundleState(bundle)); return getClass().getClassLoader(); + } } } @@ -169,7 +180,7 @@ public class BundleModuleSource extends EncodedTextualModuleSource implements Up return; Files.write(path, newSourceText.getBytes(Charset.forName("UTF-8"))); } catch(IOException e) { - LOGGER.error("Could not update {} with {}", this, newSourceText, e); + LOGGER.error("Could not update module {} in url {} with text {}", getModuleName(), url, newSourceText); } checkUpdates(); }