Пример #1
0
void
BundleLoader::LoadBundle(Bundle::Pointer bundle)
{
  if (bundle->GetState() == IBundle::BUNDLE_INSTALLED ||
      bundle->GetState() == IBundle::BUNDLE_RESOLVED)
  {
    Poco::Mutex::ScopedLock lock(m_Mutex);
    if (m_BundleMap[bundle->GetSymbolicName()].m_Bundle.IsNull())
    {
      BundleInfo bundleInfo;
      bundleInfo.m_Bundle = bundle;
      bundleInfo.m_ClassLoader = new ActivatorClassLoader();
      Poco::Path path; Platform::GetStatePath(path, bundle);
      bundleInfo.m_Context = new BundleContext(*this, bundle, path);
      m_BundleMap[bundle->GetSymbolicName()] = bundleInfo;

      this->InstallLibraries(bundle);

      //BundleEvent event(bundle, BundleEvent::EV_BUNDLE_LOADED);
      //m_BundleEvents.bundleLoaded(this, event);
    }
    else
    {
      //TODO version conflict check
    }
  }
  else
  {
    throw BundleStateException("The bundle must be in state INSTALLED in order to be loaded.");
  }
}
Пример #2
0
void Bundle::uninstall()
{
	if (_state != BUNDLE_INSTALLED && _state != BUNDLE_RESOLVED) throw BundleStateException("uninstall() requires INSTALLED or RESOLVED state");
	
	BundleEvent uninstallingEvent(this, BundleEvent::EV_BUNDLE_UNINSTALLING);
	events().bundleUninstalling(this, uninstallingEvent);
	_loader.uninstallBundle(this);
	_state = BUNDLE_UNINSTALLED;
	BundleEvent uninstalledEvent(this, BundleEvent::EV_BUNDLE_UNINSTALLED);
	events().bundleUninstalled(this, uninstalledEvent);
}
Пример #3
0
void Bundle::resolve()
{
	if (_state != BUNDLE_INSTALLED) throw BundleStateException("resolve() requires INSTALLED state");
	
	BundleEvent resolvingEvent(this, BundleEvent::EV_BUNDLE_RESOLVING);
	events().bundleResolving(this, resolvingEvent);
	_loader.resolveBundle(this);
	_state = BUNDLE_RESOLVED;
	BundleEvent resolvedEvent(this, BundleEvent::EV_BUNDLE_RESOLVED);
	events().bundleResolved(this, resolvedEvent);
}
Пример #4
0
void Bundle::stop()
{
	if (_state != BUNDLE_ACTIVE) throw BundleStateException("stop() requires ACTIVE state");
	
	StateChange stateChange(_state, BUNDLE_STOPPING);
	BundleEvent stoppingEvent(this, BundleEvent::EV_BUNDLE_STOPPING);
	events().bundleStopping(this, stoppingEvent);
	_loader.stopBundle(this);
	stateChange.commit(BUNDLE_RESOLVED);
	BundleEvent stoppedEvent(this, BundleEvent::EV_BUNDLE_STOPPED);
	events().bundleStopped(this, stoppedEvent);
}
Пример #5
0
void Bundle::start()
{
	if (_state != BUNDLE_RESOLVED) throw BundleStateException("start() requires RESOLVED state");
	
	StateChange stateChange(_state, BUNDLE_STARTING);
	BundleEvent startingEvent(this, BundleEvent::EV_BUNDLE_STARTING);
	events().bundleStarting(this, startingEvent);
	_loader.startBundle(this);
	stateChange.commit(BUNDLE_ACTIVE);
	BundleEvent startedEvent(this, BundleEvent::EV_BUNDLE_STARTED);
	events().bundleStarted(this, startedEvent);
}
Пример #6
0
void Bundle::addExtensionBundle(Bundle* pExtensionBundle)
{
	if (isResolved())
	{
		{
			Poco::FastMutex::ScopedLock lock(_extensionBundlesMutex);
		
			_extensionBundles.insert(Bundle::Ptr(pExtensionBundle, true));
		}
		_pProperties->addProperties(pExtensionBundle->_pProperties, -static_cast<int>(_extensionBundles.size()), true);
	}
	else throw BundleStateException("addExtensionBundle() requires at least RESOLVED state");
}