/** * Deploys a contribution from a given bundle. * * <p>The path will be relative to the bundle root. Example: <code> * deployContrib("org.nuxeo.ecm.core", "OSGI-INF/CoreExtensions.xml") * </code> * * <p>For compatibility reasons the name of the bundle may be a jar name, but this use is * discouraged and deprecated. * * @param name the name of the bundle to peek the contrib in * @param contrib the path to contrib in the bundle. */ @Override public void deployContrib(String name, String contrib) throws Exception { RuntimeContext context = runtime.getContext(name); if (context == null) { context = runtime.getContext(); BundleFile file = lookupBundle(name); URL location = file.getEntry(contrib); if (location == null) { throw new AssertionError("Cannot locate " + contrib + " in " + name); } context.deploy(location); return; } context.deploy(contrib); }
protected void loadComponents(Bundle bundle, RuntimeContext ctx) throws Exception { String list = getComponentsList(bundle); String name = bundle.getSymbolicName(); log.debug("Bundle: " + name + " components: " + list); if (list == null) { return; } StringTokenizer tok = new StringTokenizer(list, ", \t\n\r\f"); while (tok.hasMoreTokens()) { String path = tok.nextToken(); URL url = bundle.getEntry(path); log.debug("Loading component for: " + name + " path: " + path + " url: " + url); if (url != null) { try { ctx.deploy(url); } catch (Exception e) { // just log error to know where is the cause of the // exception log.error("Error deploying resource: " + url); Framework.handleDevError(e); throw e; } } else { String message = "Unknown component '" + path + "' referenced by bundle '" + name + "'"; log.error(message + ". Check the MANIFEST.MF"); Framework.handleDevError(null); warnings.add(message); } } }
@Override public synchronized boolean installContribution(Contribution contrib) { RegistrationInfo ri; try { ri = ctx.deploy(contrib); } catch (IOException e) { throw new RuntimeServiceException(e); } if (ri == null) { return false; } ri.setPersistent(true); return true; }
protected void deploy(String path) throws Exception { URL location = TestService.class.getResource("/".concat(path)); rc.deploy(location); }