public Bundle getBundle() { return ctx.getBundle(); }
public static PackageAdmin getPackageAdmin() { BundleContext sysctx = Framework.getRuntime().getContext().getBundle().getBundleContext(); ServiceReference ref = sysctx.getServiceReference(PackageAdmin.class.getName()); return (PackageAdmin) sysctx.getService(ref); }
public static Bundle[] getBundles() { return Framework.getRuntime().getContext().getBundle().getBundleContext().getBundles(); }
@Override public void activate(ComponentContext context) { super.activate(context); bundle = context.getRuntimeContext().getBundle(); }
public Script getScript() throws IOException { if (rc != null) { URL url = rc.getBundle().getEntry(script); if (url == null) { // if not found using bundle entries try using classloader // in a test environment bundle entries may not work url = rc.getResource(script); if (url == null) { throw new IOException("Script Not found: " + script); } } return Script.newScript(url); } else { return Script.newScript(script); } }
@Override public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) { if (XP_SERVLETS.equals(extensionPoint)) { registry.removeServlet((ServletDescriptor) contribution); } else if (XP_FILTERS.equals(extensionPoint)) { registry.removeFilterSet((FilterSetDescriptor) contribution); } else if (XP_RESOURCES.equals(extensionPoint)) { ResourcesDescriptor rd = (ResourcesDescriptor) contribution; rd.setBundle(contributor.getContext().getBundle()); registry.removeResources(rd); } else if (XP_SUBRESOURCES.equals(extensionPoint)) { ResourceExtension rxt = (ResourceExtension) contribution; rxt.setBundle(contributor.getContext().getBundle()); ApplicationManager.getInstance().getOrCreateApplication(rxt.getApplication()).removeExtension(rxt); } }
@Override public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) { if (XP_SERVLETS.equals(extensionPoint)) { ((ServletDescriptor) contribution).setBundle(contributor.getContext().getBundle()); try { registry.addServlet((ServletDescriptor) contribution); } catch (ServletException | NamespaceException e) { throw new RuntimeException(e); } } else if (XP_FILTERS.equals(extensionPoint)) { registry.addFilterSet((FilterSetDescriptor) contribution); } else if (XP_RESOURCES.equals(extensionPoint)) { ResourcesDescriptor rd = (ResourcesDescriptor) contribution; rd.setBundle(contributor.getContext().getBundle()); registry.addResources(rd); } else if (XP_SUBRESOURCES.equals(extensionPoint)) { ResourceExtension rxt = (ResourceExtension) contribution; rxt.setBundle(contributor.getContext().getBundle()); ApplicationManager.getInstance().getOrCreateApplication(rxt.getApplication()).addExtension(rxt); } }
@Override public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) { if (contribution instanceof GwtWarStrategy) { GwtWarStrategy descriptor = (GwtWarStrategy) contribution; resolver.install(descriptor.name, descriptor.strategy); } else if (contribution instanceof GwtWarDirectory) { GwtWarDirectory descriptor = (GwtWarDirectory) contribution; try { resolver.install(descriptor.name, descriptor.dir.toURI()); } catch (IOException cause) { throw new NuxeoException("Cannot install " + descriptor, cause); } } else if (contribution instanceof GwtWarBundle) { GwtWarBundle descriptor = (GwtWarBundle) contribution; URL location = contributor.getContext().getBundle().getEntry(descriptor.pathname); if (location == null) { throw new NuxeoException("Cannot locate GWT " + descriptor + " in " + contributor.getContext().getBundle()); } try { resolver.install(descriptor.name, location.toURI()); } catch (IOException | URISyntaxException cause) { throw new NuxeoException("Cannot install " + descriptor, cause); } } }
public static synchronized SimplifiedServerInfo getInfo() { if (info == null) { RuntimeService runtime = Framework.getRuntime(); Collection<RegistrationInfo> registrations = runtime.getComponentManager().getRegistrations(); bundleIds = new ArrayList<>(); List<SimplifiedBundleInfo> bundles = new ArrayList<>(); for (RegistrationInfo ri : registrations) { Bundle bundle = ri.getContext().getBundle(); if (bundle != null && !bundleIds.contains(bundle.getSymbolicName())) { SimplifiedBundleInfo bi = getBundleSimplifiedInfo(bundle); bundleIds.add(bundle.getSymbolicName()); if (bi != null) { bundles.add(bi); } } } Collections.sort(bundles); info = new SimplifiedServerInfo(); info.setBundleInfos(bundles); info.setRuntimeVersion(runtime.getVersion().toString()); info.setWarnings(runtime.getWarnings()); } return info; }
public static synchronized SimplifiedServerInfo getInfo() { if (info == null) { RuntimeService runtime = Framework.getRuntime(); Collection<RegistrationInfo> registrations = runtime.getComponentManager().getRegistrations(); bundleIds = new ArrayList<>(); List<SimplifiedBundleInfo> bundles = new ArrayList<>(); for (RegistrationInfo ri : registrations) { Bundle bundle = ri.getContext().getBundle(); if (bundle != null && !bundleIds.contains(bundle.getSymbolicName())) { SimplifiedBundleInfo bi = getBundleSimplifiedInfo(bundle); bundleIds.add(bundle.getSymbolicName()); if (bi != null) { bundles.add(bi); } } } Collections.sort(bundles); info = new SimplifiedServerInfo(); info.setBundleInfos(bundles); info.setRuntimeVersion(runtime.getVersion().toString()); RuntimeMessageHandler runtimeMessageHandler = runtime.getMessageHandler(); info.setWarnings(runtimeMessageHandler.getWarnings()); info.setErrors(runtimeMessageHandler.getErrors()); } return info; }
occ.toOperationChain(contributor.getContext().getBundle()), occ); service.putOperation(docChainType, occ.replace); } catch (OperationException e) {