public long getStateTimeStamp() { PlatformAdmin admin = getPlatformAdmin(); return admin == null ? -1 : admin.getState(false).getTimeStamp(); }
/** * Lists all packages visible from the specified bundle * @param bundle bundle to list visible packages */ @Descriptor(ConsoleMsg.CONSOLE_HELP_VISIBLE_PACKAGES_COMMAND_DESCRIPTION) public void getPackages(@Descriptor(ConsoleMsg.CONSOLE_HELP_VISIBLE_PACKAGES_COMMAND_ARGUMENTS_DESCRIPTION) Bundle bundle) { PlatformAdmin platformAdmin = activator.getPlatformAdmin(); if (platformAdmin == null) return; BundleDescription bundleDescription = platformAdmin.getState(false).getBundle(bundle.getBundleId()); ExportPackageDescription[] exports = platformAdmin.getStateHelper().getVisiblePackages(bundleDescription, StateHelper.VISIBLE_INCLUDE_EE_PACKAGES | StateHelper.VISIBLE_INCLUDE_ALL_HOST_WIRES); for (int i = 0; i < exports.length; i++) { System.out.println(exports[i] + ": " + platformAdmin.getStateHelper().getAccessCode(bundleDescription, exports[i])); //$NON-NLS-1$ } }
/** * Get the time stamp from the PlatformAdmin service. */ public static long getContainerTimestamp(BundleContext context, ServiceReference<?> ref) { if (ref == null) return -1; try { PlatformAdmin admin = (PlatformAdmin) context.getService(ref); return admin == null ? -1 : admin.getState(false).getTimeStamp(); } finally { context.ungetService(ref); } }
private void diagnose(BundleDescription bundle, PlatformAdmin platformAdmin) { System.out.println(Utils.bundleToString(bundle)); StateHelper stateHelper = platformAdmin.getStateHelper(); VersionConstraint[] unsatisfied = stateHelper.getUnsatisfiedConstraints(bundle); ResolverError[] resolverErrors = analyzeErrors(bundle, platformAdmin.getState(false)); if (unsatisfied.length == 0 && resolverErrors.length == 0) { System.out.println(Utils.formatMessage(2, "No unresolved constraints.")); } if (unsatisfied.length > 0) { System.out.println(Utils.formatMessage(2, "Unresolved constraints:")); for (int i = 0; i < unsatisfied.length; i++) { System.out.println(Utils.formatMessage(3, getResolutionFailureMessage(unsatisfied[i]))); } } }
/** * Get the time stamp from the PlatformAdmin service. */ public static long getContainerTimestamp(BundleContext context, ServiceReference ref) { if (ref == null) return -1; try { PlatformAdmin admin = (PlatformAdmin) context.getService(ref); return admin == null ? -1 : admin.getState(false).getTimeStamp(); } finally { context.ungetService(ref); } }
/** * Get the time stamp from the PlatformAdmin service. */ public static long getContainerTimestamp(BundleContext context, ServiceReference ref) { if (ref == null) return -1; try { PlatformAdmin admin = (PlatformAdmin) context.getService(ref); return admin == null ? -1 : admin.getState(false).getTimeStamp(); } finally { context.ungetService(ref); } }
public State getState() { return getPlatformAdmin().getState(false); }
/** * Get the time stamp from the PlatformAdmin service. */ public static long getContainerTimestamp(BundleContext context, ServiceReference ref) { if (ref == null) return -1; try { PlatformAdmin admin = (PlatformAdmin) context.getService(ref); return admin == null ? -1 : admin.getState(false).getTimeStamp(); } finally { context.ungetService(ref); } }
static void setDisabled(boolean disable, Bundle bundle, BundleContext systemContext) { ServiceReference ref = systemContext.getServiceReference(PlatformAdmin.class.getName()); PlatformAdmin pa = (PlatformAdmin) (ref == null ? null : systemContext.getService(ref)); if (pa == null) throw new RuntimeException("No Platform Admin service is available."); //$NON-NLS-1$ try { State state = pa.getState(false); BundleDescription desc = state.getBundle(bundle.getBundleId()); setDisabled(disable, desc); } finally { systemContext.ungetService(ref); } }
static void setDisabled(boolean disable, Bundle bundle, BundleContext systemContext) { ServiceReference ref = systemContext.getServiceReference(PlatformAdmin.class.getName()); PlatformAdmin pa = (PlatformAdmin) (ref == null ? null : systemContext.getService(ref)); if (pa == null) throw new RuntimeException("No Platform Admin service is available."); //$NON-NLS-1$ try { State state = pa.getState(false); BundleDescription desc = state.getBundle(bundle.getBundleId()); setDisabled(disable, desc); } finally { systemContext.ungetService(ref); } }
protected ClassLoader[] getPluginClassLoaders() { if (orderedPluginClassLoaders == null) { Iterator classLoaders= pluginClassLoaders.iterator(); Map idToLoader= new HashMap(pluginClassLoaders.size()); List bundles = new ArrayList(pluginClassLoaders.size()); while (classLoaders.hasNext()) { WrappedClassLoader loader = (WrappedClassLoader) classLoaders.next(); idToLoader.put(loader.bundle.getSymbolicName(), loader); bundles.add(Platform.getPlatformAdmin().getState(false).getBundle(loader.bundle.getBundleId())); } List descriptions = computePrerequisiteOrder(bundles); List loaders = new ArrayList(descriptions.size()); for (Iterator iter = descriptions.iterator(); iter.hasNext(); ) { String id =((BundleDescription) iter.next()).getSymbolicName(); loaders.add(idToLoader.get(id)); } orderedPluginClassLoaders = (WrappedClassLoader[]) loaders.toArray(new WrappedClassLoader[loaders.size()]); } return orderedPluginClassLoaders; }
public long getStateTimeStamp() { PlatformAdmin admin = getPlatformAdmin(); return admin == null ? -1 : admin.getState(false).getTimeStamp(); }
public long getStateTimeStamp() { PlatformAdmin admin = getPlatformAdmin(); return admin == null ? -1 : admin.getState(false).getTimeStamp(); }
public long getStateTimeStamp() { PlatformAdmin admin = getPlatformAdmin(); return admin == null ? -1 : admin.getState(false).getTimeStamp(); }
@Override public void hackBundles(final Framework osgiContainer, final File tempDirectory) { BundleContext systemBundleContext = osgiContainer.getBundleContext(); ServiceReference<PlatformAdmin> platformServiceSR = systemBundleContext .getServiceReference(PlatformAdmin.class); PlatformAdmin platformAdmin = systemBundleContext.getService(platformServiceSR); State state = platformAdmin.getState(); Bundle[] bundles = systemBundleContext.getBundles(); List<BundleCapability> availableCapabilities = getAllCapabilities(bundles, state); for (Bundle bundle : bundles) { if (bundle.getState() == Bundle.INSTALLED) { BundleDescription bundleDescription = state.getBundle(bundle.getBundleId()); hackBundle(bundle, bundleDescription, availableCapabilities); } } }
/** * Returns a number that changes whenever the set of installed plug-ins * changes. This can be used for invalidating caches that are based on * the set of currently installed plug-ins. (e.g. extensions) * * @see PlatformAdmin#getState() * @see State#getTimeStamp() */ public static long getStateStamp() { ServiceReference<PlatformAdmin> platformAdminReference = getContext().getServiceReference(PlatformAdmin.class); if (platformAdminReference == null) return -1; PlatformAdmin admin = getContext().getService(platformAdminReference); return admin == null ? -1 : admin.getState(false).getTimeStamp(); }
@Descriptor(ConsoleMsg.CONSOLE_HELP_LD_COMMAND_DESCRIPTION) public void disabledBundles() throws Exception { PlatformAdmin platformAdmin = activator.getPlatformAdmin(); if (platformAdmin == null) { System.out.println(ConsoleMsg.CONSOLE_CANNOT_LIST_DISABLED_NO_PLATFORM_ADMIN_MESSAGE); return; } State systemState = platformAdmin.getState(false); BundleDescription[] disabledBundles = systemState.getDisabledBundles(); System.out.println(NLS.bind(ConsoleMsg.CONSOLE_DISABLED_COUNT_MESSAGE, String.valueOf(disabledBundles.length))); if (disabledBundles.length > 0) { System.out.println(); } for (int i = 0; i < disabledBundles.length; i++) { DisabledInfo[] disabledInfos = systemState.getDisabledInfos(disabledBundles[i]); System.out.println(NLS.bind(ConsoleMsg.CONSOLE_DISABLED_BUNDLE_HEADER, formatBundleName(disabledBundles[i]), String.valueOf(disabledBundles[i].getBundleId()))); System.out.print(NLS.bind(ConsoleMsg.CONSOLE_DISABLED_BUNDLE_REASON, disabledInfos[0].getMessage(), disabledInfos[0].getPolicyName())); for (int j = 1; j < disabledInfos.length; j++) { System.out.print(NLS.bind(ConsoleMsg.CONSOLE_DISABLED_BUNDLE_REASON, disabledInfos[j].getMessage(), String.valueOf(disabledInfos[j].getPolicyName()))); } System.out.println(); } }
private static Long getBundleId(String name) { BundleDescription descr = PDERuntimePlugin.getDefault().getPlatformAdmin().getState(false).getBundle(name, null); return descr == null ? null : Long.valueOf(descr.getBundleId()); }
private static boolean getIsEnabled(org.osgi.framework.Bundle bundle) { PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); State state = plaformAdmin.getState(false); BundleDescription description = state.getBundle(bundle.getBundleId()); return (state.getDisabledInfos(description)).length == 0; }
public void _disableBundle(CommandInterpreter ci) throws Exception { String nextArg = ci.nextArgument(); if (nextArg == null) { ci.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return; } try { State systemState = getPlatformAdmin(ci).getState(false); while (nextArg != null) { BundleDescription bundleDesc = getBundleDescriptionFromToken(systemState, nextArg); if (bundleDesc == null) { ci.println(NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONSOLE_CANNOT_FIND_BUNDLE_ERROR, nextArg)); nextArg = ci.nextArgument(); continue; } DisabledInfo info = new DisabledInfo(POLICY_CONSOLE, EclipseAdaptorMsg.ECLIPSE_CONSOLE_BUNDLE_DISABLED_MESSAGE, bundleDesc); getPlatformAdmin(ci).addDisabledInfo(info); nextArg = ci.nextArgument(); } } finally { ungetPlatformAdmin(); } }