@Override public List<Bundle> install(String absolutePath) { try { return jdiscOsgi.installBundle(normalizeLocation(absolutePath)); } catch (BundleException e) { throw new RuntimeException(e); } }
@Override public Bundle[] getBundles() { List<Bundle> bundles = jdiscOsgi.bundles(); return bundles.toArray(new Bundle[bundles.size()]); }
@Override public void refreshPackages() { jdiscOsgi.refreshPackages(); } }
@Override public void init(String appLocation, boolean privileged) throws Exception { log.finer("Initializing application loader."); osgiFramework.start(); BundleContext ctx = osgiFramework.bundleContext(); if (ctx != null) { ctx.registerService(CurrentContainer.class.getName(), this, null); appBundles.addAll(osgiFramework.installBundle(appLocation)); if (OsgiHeader.isSet(appBundles.get(0), OsgiHeader.PRIVILEGED_ACTIVATOR)) { osgiFramework.startBundles(appBundles, privileged);
@Inject public ConfiguredApplication(ContainerActivator activator, OsgiFramework osgiFramework, com.yahoo.jdisc.Timer timer, SubscriberFactory subscriberFactory) throws ListenFailedException { this.activator = activator; this.osgiFramework = osgiFramework; this.timerSingleton = timer; this.subscriberFactory = subscriberFactory; this.configId = System.getProperty("config.id"); this.restrictedOsgiFramework = new DisableOsgiFramework(new RestrictedBundleContext(osgiFramework.bundleContext())); applicationWithLegacySetup = new ContainerDiscApplication(configId); }
private void start(Bundle bundle) throws BundleException { if (bundle.getState() == Bundle.ACTIVE) { throw new BundleException("OSGi bundle " + bundle.getSymbolicName() + " already started."); } if (!OsgiHeader.asList(bundle, OsgiHeader.APPLICATION).isEmpty()) { throw new BundleException("OSGi header '" + OsgiHeader.APPLICATION + "' not allowed for " + "non-application bundle " + bundle.getSymbolicName() + "."); } osgiFramework.startBundles(Arrays.asList(bundle), false); }
@Override public void destroy() { log.finer("Destroying application loader."); try { watchdog.close(); osgiFramework.stop(); } catch (BundleException | InterruptedException e) { e.printStackTrace(); } }
ServerSocketChannel preBoundChannel = getChannelFromServiceLayer(connectorFactory.getConnectorConfig().listenPort(), osgiFramework.bundleContext()); server.addConnector(connectorFactory.createConnector(metric, server, preBoundChannel)); listenedPorts.add(connectorFactory.getConnectorConfig().listenPort());
Bundle appBundle = appBundles.get(0); if (!OsgiHeader.isSet(appBundle, OsgiHeader.PRIVILEGED_ACTIVATOR)) { osgiFramework.startBundles(appBundles, false);
public List<Bundle> installAndStart(Iterable<String> locations) throws BundleException { List<Bundle> bundles = new LinkedList<>(); try { for (String location : locations) { bundles.addAll(osgiFramework.installBundle(location)); } } catch (BundleInstallationException e) { bundles.addAll(e.installedBundles()); throw new BundleInstallationException(bundles, e); } catch (Exception e) { throw new BundleInstallationException(bundles, e); } try { for (Bundle bundle : bundles) { start(bundle); } } catch (Exception e) { throw new BundleInstallationException(bundles, e); } return bundles; }
@Override public BundleClasses getBundleClasses(ComponentSpecification bundleSpec, Set<String> packagesToScan) { //Temporary hack: Using class name since ClassLoaderOsgiFramework is not available at compile time in this bundle. if (osgiFramework.getClass().getName().equals("com.yahoo.application.container.impl.ClassLoaderOsgiFramework")) { Bundle syntheticClassPathBundle = first(osgiFramework.bundles()); ClassLoader classLoader = syntheticClassPathBundle.adapt(BundleWiring.class).getClassLoader(); return new BundleClasses( syntheticClassPathBundle, OsgiUtil.getClassEntriesForBundleUsingProjectClassPathMappings(classLoader, bundleSpec, packagesToScan)); } else { Bundle bundle = getBundle(bundleSpec); if (bundle == null) throw new RuntimeException("No bundle matching " + quote(bundleSpec)); return new BundleClasses(bundle, OsgiUtil.getClassEntriesInBundleClassPath(bundle, packagesToScan)); } }