com.atlassian.plugin.osgi.container.felix
Class FelixOsgiContainerManager

java.lang.Object
  extended by com.atlassian.plugin.osgi.container.felix.FelixOsgiContainerManager
All Implemented Interfaces:
OsgiContainerManager, OsgiContainerManager.AllowsReferenceInstall

public class FelixOsgiContainerManager
extends Object
implements OsgiContainerManager, OsgiContainerManager.AllowsReferenceInstall

Felix implementation of the OSGi container manager


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.plugin.osgi.container.OsgiContainerManager
OsgiContainerManager.AllowsReferenceInstall
 
Nested classes/interfaces inherited from interface com.atlassian.plugin.osgi.container.OsgiContainerManager.AllowsReferenceInstall
OsgiContainerManager.AllowsReferenceInstall.Default
 
Field Summary
static String OSGI_FRAMEWORK_BUNDLES_ZIP
           
static int REFRESH_TIMEOUT
           
 
Constructor Summary
FelixOsgiContainerManager(File frameworkBundlesDirectory, OsgiPersistentCache persistentCache, PackageScannerConfiguration packageScannerConfig, HostComponentProvider provider, PluginEventManager eventManager)
          Constructs the container manager.
FelixOsgiContainerManager(File frameworkBundlesDir, PackageScannerConfiguration packageScannerConfig, HostComponentProvider provider, PluginEventManager eventManager)
          Deprecated. Since 2.2.0, use FelixOsgiContainerManager(OsgiPersistentCache, PackageScannerConfiguration, HostComponentProvider, PluginEventManager) instead
FelixOsgiContainerManager(OsgiPersistentCache persistentCache, PackageScannerConfiguration packageScannerConfig, HostComponentProvider provider, PluginEventManager eventManager)
          Constructs the container manager using the framework bundles zip file located in this library.
FelixOsgiContainerManager(URL frameworkBundlesZip, File frameworkBundlesDir, PackageScannerConfiguration packageScannerConfig, HostComponentProvider provider, PluginEventManager eventManager)
          Deprecated. Since 2.2.0, use FelixOsgiContainerManager(URL, OsgiPersistentCache, PackageScannerConfiguration, HostComponentProvider, PluginEventManager) instead
FelixOsgiContainerManager(URL frameworkBundlesZip, OsgiPersistentCache persistentCache, PackageScannerConfiguration packageScannerConfig, HostComponentProvider provider, PluginEventManager eventManager)
          Constructs the container manager.
 
Method Summary
 void clearExportCache()
          Clears export cache.
 org.osgi.framework.Bundle[] getBundles()
          Gets a list of installed bundles
 List<HostComponentRegistration> getHostComponentRegistrations()
          Gets a list of host component registrations
 org.osgi.framework.ServiceReference[] getRegisteredServices()
          Gets a list of service references
 org.osgi.util.tracker.ServiceTracker getServiceTracker(String interfaceClassName)
          Gets a service tracker to follow a service registered under a certain interface.
 org.osgi.util.tracker.ServiceTracker getServiceTracker(String interfaceClassName, org.osgi.util.tracker.ServiceTrackerCustomizer serviceTrackerCustomizer)
          Gets a service tracker to follow a service registered under a certain interface with a ServiceTrackerCustomizer attached for customizing tracked service objects.
 org.osgi.framework.Bundle installBundle(File file)
          Installs a bundle into a running OSGI container
 org.osgi.framework.Bundle installBundle(File file, boolean allowReference)
          Installs a bundle into a running OSGI container.
 boolean isRunning()
           
 void onPluginFrameworkWarmRestarting(PluginFrameworkWarmRestartingEvent event)
           
 void onPluginUninstallation(PluginUninstalledEvent event)
           
 void onPluginUpgrade(PluginUpgradedEvent event)
           
 void onShutdown(PluginFrameworkShutdownEvent event)
           
 void onStart(PluginFrameworkStartingEvent event)
           
 void setDisableMultipleBundleVersions(boolean val)
           
 void setFelixLogger(org.apache.felix.framework.Logger logger)
           
 void start()
          Starts the OSGi container
 void stop()
          Stops the OSGi container
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OSGI_FRAMEWORK_BUNDLES_ZIP

public static final String OSGI_FRAMEWORK_BUNDLES_ZIP
See Also:
Constant Field Values

REFRESH_TIMEOUT

public static final int REFRESH_TIMEOUT
See Also:
Constant Field Values
Constructor Detail

FelixOsgiContainerManager

@Deprecated
public FelixOsgiContainerManager(File frameworkBundlesDir,
                                            PackageScannerConfiguration packageScannerConfig,
                                            HostComponentProvider provider,
                                            PluginEventManager eventManager)
Deprecated. Since 2.2.0, use FelixOsgiContainerManager(OsgiPersistentCache, PackageScannerConfiguration, HostComponentProvider, PluginEventManager) instead

Constructs the container manager using the framework bundles zip file located in this library

Parameters:
frameworkBundlesDir - The directory to unzip the framework bundles into.
packageScannerConfig - The configuration for package scanning
provider - The host component provider. May be null.
eventManager - The plugin event manager to register for init and shutdown events

FelixOsgiContainerManager

@Deprecated
public FelixOsgiContainerManager(URL frameworkBundlesZip,
                                            File frameworkBundlesDir,
                                            PackageScannerConfiguration packageScannerConfig,
                                            HostComponentProvider provider,
                                            PluginEventManager eventManager)
Deprecated. Since 2.2.0, use FelixOsgiContainerManager(URL, OsgiPersistentCache, PackageScannerConfiguration, HostComponentProvider, PluginEventManager) instead

Constructs the container manager

Parameters:
frameworkBundlesZip - The location of the zip file containing framework bundles
frameworkBundlesDir - The directory to unzip the framework bundles into.
packageScannerConfig - The configuration for package scanning
provider - The host component provider. May be null.
eventManager - The plugin event manager to register for init and shutdown events

FelixOsgiContainerManager

public FelixOsgiContainerManager(OsgiPersistentCache persistentCache,
                                 PackageScannerConfiguration packageScannerConfig,
                                 HostComponentProvider provider,
                                 PluginEventManager eventManager)
Constructs the container manager using the framework bundles zip file located in this library.

This method uses the default framework bundles zip file from this library. The data for the zip file is obtained from the classloader. Since tomcat permanently caches resources obtained from the webapp classloader, this constructor should not be used in tomcat web applications in memory constrained environments, prefer to make the framework bundles available in the filesystem directly, and use FelixOsgiContainerManager(File, OsgiPersistentCache, PackageScannerConfiguration, HostComponentProvider, PluginEventManager) instead.

Parameters:
persistentCache - The persistent cache configuration.
packageScannerConfig - The configuration for package scanning
provider - The host component provider. May be null.
eventManager - The plugin event manager to register for init and shutdown events
Since:
2.2.0

FelixOsgiContainerManager

public FelixOsgiContainerManager(URL frameworkBundlesZip,
                                 OsgiPersistentCache persistentCache,
                                 PackageScannerConfiguration packageScannerConfig,
                                 HostComponentProvider provider,
                                 PluginEventManager eventManager)
                          throws OsgiContainerException
Constructs the container manager.

Parameters:
frameworkBundlesZip - The location of the zip file containing framework bundles
persistentCache - The persistent cache to use for the framework and framework bundles
packageScannerConfig - The configuration for package scanning
provider - The host component provider. May be null.
eventManager - The plugin event manager to register for init and shutdown events
Throws:
OsgiContainerException - If the host version isn't supplied and the cache directory cannot be cleaned.
Since:
2.2.0

FelixOsgiContainerManager

public FelixOsgiContainerManager(File frameworkBundlesDirectory,
                                 OsgiPersistentCache persistentCache,
                                 PackageScannerConfiguration packageScannerConfig,
                                 HostComponentProvider provider,
                                 PluginEventManager eventManager)
                          throws OsgiContainerException
Constructs the container manager.

This constructor is used when frameworkBundlesDirectory has already been populated with the framework bundles. It ignores OsgiPersistentCache.getFrameworkBundleCache().

Parameters:
frameworkBundlesDirectory - The directory containing framework bundles
persistentCache - The persistent cache to use for the framework
packageScannerConfig - The configuration for package scanning
provider - The host component provider. May be null.
eventManager - The plugin event manager to register for init and shutdown events
Throws:
OsgiContainerException - If the host version isn't supplied and the cache directory cannot be cleaned.
Since:
3.0.21
Method Detail

setFelixLogger

public void setFelixLogger(org.apache.felix.framework.Logger logger)

setDisableMultipleBundleVersions

public void setDisableMultipleBundleVersions(boolean val)

clearExportCache

public void clearExportCache()
Clears export cache.

Since:
2.9.0

onStart

public void onStart(PluginFrameworkStartingEvent event)

onShutdown

public void onShutdown(PluginFrameworkShutdownEvent event)

onPluginUpgrade

public void onPluginUpgrade(PluginUpgradedEvent event)

onPluginUninstallation

public void onPluginUninstallation(PluginUninstalledEvent event)

onPluginFrameworkWarmRestarting

public void onPluginFrameworkWarmRestarting(PluginFrameworkWarmRestartingEvent event)

start

public void start()
           throws OsgiContainerException
Description copied from interface: OsgiContainerManager
Starts the OSGi container

Specified by:
start in interface OsgiContainerManager
Throws:
OsgiContainerException - If the container cannot be started

stop

public void stop()
          throws OsgiContainerException
Description copied from interface: OsgiContainerManager
Stops the OSGi container

Specified by:
stop in interface OsgiContainerManager
Throws:
OsgiContainerException - If the container cannot be stopped

getBundles

public org.osgi.framework.Bundle[] getBundles()
Description copied from interface: OsgiContainerManager
Gets a list of installed bundles

Specified by:
getBundles in interface OsgiContainerManager
Returns:
An array of bundles

getRegisteredServices

public org.osgi.framework.ServiceReference[] getRegisteredServices()
Description copied from interface: OsgiContainerManager
Gets a list of service references

Specified by:
getRegisteredServices in interface OsgiContainerManager
Returns:
An array of service references

getServiceTracker

public org.osgi.util.tracker.ServiceTracker getServiceTracker(String interfaceClassName)
Description copied from interface: OsgiContainerManager
Gets a service tracker to follow a service registered under a certain interface. Will return a new ServiceTracker instance for every call, so don't call more than necessary. Any provided ServiceTracker instances will be opened before returning and automatically closed on shutdown.

Specified by:
getServiceTracker in interface OsgiContainerManager
Parameters:
interfaceClassName - The interface class as a String
Returns:
A service tracker to follow all instances of that interface

getServiceTracker

public org.osgi.util.tracker.ServiceTracker getServiceTracker(String interfaceClassName,
                                                              org.osgi.util.tracker.ServiceTrackerCustomizer serviceTrackerCustomizer)
Description copied from interface: OsgiContainerManager
Gets a service tracker to follow a service registered under a certain interface with a ServiceTrackerCustomizer attached for customizing tracked service objects. Will return a new ServiceTracker instance for every call, so don't call more than necessary. Any provided ServiceTracker instances will be opened before returning and automatically closed on shutdown.

Specified by:
getServiceTracker in interface OsgiContainerManager
Parameters:
interfaceClassName - The interface class as a String
serviceTrackerCustomizer - service tracker customizer for the created service tracker
Returns:
A service tracker to follow all instances of that interface

installBundle

public org.osgi.framework.Bundle installBundle(File file)
                                        throws OsgiContainerException
Description copied from interface: OsgiContainerManager
Installs a bundle into a running OSGI container

Specified by:
installBundle in interface OsgiContainerManager
Parameters:
file - The bundle file to install
Returns:
The created bundle
Throws:
OsgiContainerException - If the bundle cannot be loaded

installBundle

public org.osgi.framework.Bundle installBundle(File file,
                                               boolean allowReference)
                                        throws OsgiContainerException
Description copied from interface: OsgiContainerManager.AllowsReferenceInstall
Installs a bundle into a running OSGI container.

Specified by:
installBundle in interface OsgiContainerManager.AllowsReferenceInstall
Parameters:
file - The bundle file to install.
allowReference - true iff the file need not be copied, and the container may install a reference to it.
Returns:
The installed bundle.
Throws:
OsgiContainerException - If the bundle cannot be loaded

isRunning

public boolean isRunning()
Specified by:
isRunning in interface OsgiContainerManager
Returns:
If the container is running or not

getHostComponentRegistrations

public List<HostComponentRegistration> getHostComponentRegistrations()
Description copied from interface: OsgiContainerManager
Gets a list of host component registrations

Specified by:
getHostComponentRegistrations in interface OsgiContainerManager
Returns:
A list of host component registrations


Copyright © 2015 Atlassian. All rights reserved.