public static BundleStartLevelDTO newBundleStartLevelDTO(Bundle b, BundleStartLevel bsl) { if (bsl == null) { return null; } BundleStartLevelDTO dto = new BundleStartLevelDTO(); dto.bundle = b.getBundleId(); dto.activationPolicyUsed = bsl.isActivationPolicyUsed(); dto.persistentlyStarted = bsl.isPersistentlyStarted(); dto.startLevel = bsl.getStartLevel(); return dto; }
@Override public void setBundleStartLevel(long bundleId, int startLevel) throws PortalException { _checkPermission(); Bundle bundle = getBundle(bundleId); if (bundle == null) { throw new PortalException("No bundle with ID " + bundleId); } BundleStartLevel bundleStartLevel = bundle.adapt(BundleStartLevel.class); bundleStartLevel.setStartLevel(startLevel); }
public void start(int options) throws BundleException { if (getState() == UNINSTALLED) throw new IllegalStateException("Bundle.UNINSTALLED"); BundleStartLevel bundleStartLevel = adapt(BundleStartLevel.class); FrameworkStartLevel frameworkStartLevel = getFramework().adapt(FrameworkStartLevel.class); if ((bundleStartLevel != null) && (bundleStartLevel.getStartLevel() > frameworkStartLevel.getStartLevel())) { if ((options & START_TRANSIENT) == START_TRANSIENT) throw new BundleException("startLevel"); else return; } if (getState() == ACTIVE) return; if (getState() == INSTALLED) setState(RESOLVED); setState(STARTING); String location = getLocation(); if (location != null) { BundleActivator bundleActivator = null; Throwable exception = null; try { bundleActivator = (BundleActivator) loadClass(location.replace('/', '.')).newInstance(); bundleActivator.start(getBundleContext()); } catch (Throwable t) { logger.log(Level.SEVERE, "Error starting bundle: " + bundleActivator, t); if (t instanceof ThreadDeath) throw (ThreadDeath) t; else exception = t; } if (exception == null) this.bundleActivator = bundleActivator; else { setState(STOPPING); setState(RESOLVED); getFramework().fireBundleEvent(BundleEvent.STOPPED, this); throw new BundleException("BundleActivator.start", exception); } } if (getState() == UNINSTALLED) throw new IllegalStateException("Bundle.UNINSTALLED"); setState(ACTIVE); }
private void _installInitialBundle( String location, List<Bundle> lazyActivationBundles, List<Bundle> startBundles, List<Bundle> refreshBundles) { boolean start = false; int startLevel = PropsValues.MODULE_FRAMEWORK_BEGINNING_START_LEVEL; int index = location.lastIndexOf(StringPool.AT); if (index != -1) { String[] parts = StringUtil.split(location.substring(index + 1), StringPool.COLON); for (String part : parts) { if (part.equals("start")) { start = true; } else { startLevel = GetterUtil.getInteger(part); } } location = location.substring(0, index); } InputStream inputStream = null; try { if (!location.startsWith("file:")) { location = "file:".concat(PropsValues.LIFERAY_LIB_PORTAL_DIR.concat(location)); } URL initialBundleURL = new URL(location); try { inputStream = new BufferedInputStream(initialBundleURL.openStream()); } catch (IOException ioe) { if (_log.isWarnEnabled()) { _log.warn(ioe.getMessage()); } return; } Bundle bundle = (Bundle) addBundle(initialBundleURL.toString(), inputStream, false); if ((bundle == null) || _isFragmentBundle(bundle)) { return; } if (!start && _hasLazyActivationPolicy(bundle)) { lazyActivationBundles.add(bundle); return; } if (((bundle.getState() & Bundle.UNINSTALLED) == 0) && (startLevel > 0)) { BundleStartLevel bundleStartLevel = bundle.adapt(BundleStartLevel.class); bundleStartLevel.setStartLevel(startLevel); } if (start) { startBundles.add(bundle); } if ((bundle.getState() & Bundle.INSTALLED) != 0) { refreshBundles.add(bundle); } } catch (Exception e) { _log.error(e, e); } finally { StreamUtil.cleanUp(inputStream); } }