Service Activator Toolkit
Version 1.1.0 (20081206)

org.eclipse.soda.sat.core.framework
Class BaseBundleActivator

java.lang.Object
  extended by org.eclipse.soda.sat.core.framework.BaseBundleActivator
All Implemented Interfaces:
BundleActivator
Direct Known Subclasses:
ManagedServiceBundleActivator, ManagedServiceFactoryBundleActivator

public abstract class BaseBundleActivator
extends Object
implements BundleActivator

BaseBundleActivator is an abstract class from which all SAT bundles typically derive their BundleActivator. The BaseBundleActivator class is central to SAT since it prescribes the algorithm for managing the life cycle of a bundle.

The BaseBundleActivator class is implemented using the Template Method Pattern, providing hook and configuration methods that subclasses can override, and supporting query methods.

Subclasses of BaseBundleActivator are often created using the Eclipse-based SAT Bundle Activator wizard. The wizard can be accessed by selecting File > New > Other... and selecting the Service Activator Toolkit category from the dialog.

While subclassing the BaseBundleActivator is by far the most common way of using SAT, this is not the only way. A bundle that needs to be highly customized can have its activator built using the SAT abstractions that are available via the FactoryUtility class.


Field Summary
protected static String[] NO_SERVICES
           
 
Constructor Summary
BaseBundleActivator()
           
 
Method Summary
protected  Object acquireImportedService(String name)
          Configuration API: Acquire the specified imported services.
protected  void acquireImportedServices()
          Configuration API: Acquire all the imported services.
protected  void acquireOptionalImportedServices()
          Configuration API: Acquire all the optional imported services.
protected  void activate()
          Hook API: This method is overridden by subclasses that wish to execute domain specific activation.
protected  void addExportedProxyService(Class interfaceType, IProxyServiceHandler handler, Dictionary properties)
          Configuration API: Add an exported proxy service.
protected  void addExportedProxyServices(Class[] interfaceTypes, IProxyServiceHandler handler, Dictionary properties)
          Configuration API: Add an exported proxy service.
protected  void addExportedService(String name, Object service, Dictionary properties)
          Configuration API: Add an exported service with properties.
protected  void addExportedServices(String[] names, Object service, Dictionary properties)
          Configuration API: Add multiple exported service with properties.
protected  void addImportedServiceFilter(String name, String filterString)
          Configuration API: Add an LDAP filter to an imported service.
protected  void addOptionalImportedServiceFilter(String name, String filterString)
          Configuration API: Add an LDAP filter to an optional imported service.
protected  String[] basicGetImportedServiceNames()
          Get the imported service names.
protected  String[] basicGetOptionalImportedServiceNames()
          Get the optional imported service names.
protected  void collectImportedServiceNames(Set serviceNames)
          Hook API: This method is extended by subclasses that have required imported services.
protected  void collectOptionalImportedServiceNames(Set serviceNames)
          Hook API: This method is extended by subclasses that have optional imported services.
protected  void deactivate()
          Hook API: You have been deactivated.
protected  int getAsyncStartPriority()
          Configuration Parameter API: Get the async start thread priority.
protected  Bundle getBundle()
          OSGi Query API: Get the bundle.
protected  IBundleActivationManager getBundleActivationManager()
          Protected bundleActivationManager getter.
protected  BundleContext getBundleContext()
          OSGi Query API: Get the bundle context.
protected  String getBundleSymbolicName()
          OSGi Query API: Query the bundle's manifest for its Bundle-SymbolicName header.
protected  File getDataDirectory()
          Persistent Bundle Storage API: Get the bundle's private data directory.
protected  File getDataFile(String filename)
          Persistent Bundle Storage API: Open a data file contained in the bundle's private data directory.
protected  Object getExportedService(String name)
          Query API: Get a named exported service object.
protected  String[] getExportedServiceNamesFromManifest()
          Deprecated. OSGi R4 has deprecated the Export-Service header.
protected  Dictionary getExportedServiceProperties(String name)
          Query API: Answers the properties of an exported service.
protected  Dictionary getExportedServiceProperties(String name, Object service)
          Query API: Answers the properties of a specific exported service.
protected  Map getExportedServices()
          Query API: Query the exported services.
protected  Object[] getExportedServices(String name)
          Query API: Query the exported services.
protected  InputStream getFilePropertiesInputStream()
          Query API: Create an input stream on the default properties file.
protected  InputStream getFilePropertiesInputStream(String filename)
          Query API: Create an input stream on the specified properties file.
protected  Object getImportedService(String name)
          Query API: Get the named imported service.
protected  Filter getImportedServiceFilter(String name)
          Query API: Search for an imported service filter.
protected  String[] getImportedServiceNames()
          Query API: Answers the names of all the services that are imported by the bundle.
protected  String[] getImportedServiceNamesFromManifest()
          Deprecated. OSGi R4 has deprecated the Import-Service header.
protected  Object getImportedServiceProperty(String name, String key)
          Query API: Get the value of an imported service's property.
protected  String[] getImportedServicePropertyKeys(String name)
          Query API: Get the keys of an imported service's properties.
protected  Map getImportedServices()
          Query API: Query the imported services.
protected  Object getOptionalImportedService(String name)
          Query API: Get the named optional imported service.
protected  Filter getOptionalImportedServiceFilter(String name)
          Query API: Search for an optional imported service filter.
protected  String[] getOptionalImportedServiceNames()
          Query API: Answers the names of all the services that are optionally imported by the bundle.
protected  Object getOptionalImportedServiceProperty(String name, String key)
          Query API: Get the value of an optional imported service's property.
protected  String[] getOptionalImportedServicePropertyKeys(String name)
          Query API: Get the keys of an optional imported service's properties.
protected  Map getOptionalImportedServices()
          Query API: Query the optional imported services.
protected  Properties getProperties()
          Query API: Create a Properties object out of the bundle's properties.
protected  InputStream getPropertiesInputStream()
          Hook API: Get an input stream to the bundle's properties.
protected  String getProperty(String key, String defaultValue)
          Query API: Get the value of a property.
protected  InputStream getResourcePropertiesInputStream()
          Query API: Create an input stream on the default resource properties.
protected  InputStream getResourcePropertiesInputStream(String filename)
          Query API: Create an input stream on the specified resource file.
protected  void handleAcquiredOptionalImportedService(String serviceName, Object service)
          Hook Handler API: When an optional imported service is acquired, this method is called.
protected  boolean handleException(Exception exception)
          Hook Handler API: Handles a thrown exception.
protected  void handleFailedToFindProperties(String filename)
          Hook Handler API: Handle the fact that the specified properties file could not be found.
protected  void handleReleasedOptionalImportedService(String serviceName, Object service)
          Hook Handler API: When an optional imported service is released, this method is called.
protected  boolean isStartAsync()
          Configuration Parameter API: Specifies whether the bundle should start asynchronously.
protected  boolean isTransient()
          Configuration Parameter API: Specify whether the bundle should be treated as transient.
protected  boolean isUninstallable()
          Configuration Parameter API: Specify whether the bundle should be treated as uninstalled.
protected  void releaseImportedService(String name)
          Configuration API: Release the specified imported services.
protected  void releaseImportedServices()
          Configuration API: Release all the imported services.
protected  void releaseOptionalImportedServices()
          Configuration API: Release all the optional imported services.
protected  void removeExportedService(String name)
          Configuration API: Remove the exported service record of the specified type.
protected  void removeExportedService(String name, Object service)
          Configuration API: Removes the specified exported service.
protected  void removeExportedServices(String name)
          Configuration API: Remove the named exported service domain object.
protected  void removeImportedServiceFilter(String name)
          Configuration API: Removes the LDAP filter for an imported service.
protected  void removeOptionalImportedServiceFilter(String name)
          Configuration API: Removes the LDAP filter for an optional imported service.
protected  void restartFramework()
          OSGi Framework API: Stop and restart the OSGi framework.
protected  void setExportedServiceProperties(String name, Dictionary properties)
          Configuration API: Sets the properties of an exported service.
protected  void setExportedServiceProperties(String name, Object service, Dictionary properties)
          Configuration API: Sets the properties of an exported service.
protected  void shutdownFramework()
          OSGi Framework API: Shutdown the OSGi framework.
protected  void start()
          Hook API: This method is called by start(BundleContext) .
 void start(BundleContext bundleContext)
          Bundle Activator API: This is where the bundle activator starts its execution.
protected  void stop()
          Hook API: This method is called by stop(BundleContext) .
 void stop(BundleContext bundleContext)
          Bundle Activator API: This is where the bundle activator stops its execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_SERVICES

protected static final String[] NO_SERVICES
Constructor Detail

BaseBundleActivator

public BaseBundleActivator()
Method Detail

acquireImportedService

protected final Object acquireImportedService(String name)
Configuration API: Acquire the specified imported services. This method is typically not used by subclasses, except in rare cases. For an example see the method releaseImportedService(String).

Parameters:
name - The name of an imported service.
Returns:
Object
See Also:
releaseImportedService(java.lang.String), IBundleActivationManager.acquireImportedService(java.lang.String)

acquireImportedServices

protected final void acquireImportedServices()
Configuration API: Acquire all the imported services. This method is typically not used by subclasses, except in rare cases. For an example see the method releaseImportedServices().

See Also:
releaseImportedServices(), IBundleActivationManager.acquireImportedServices()

acquireOptionalImportedServices

protected final void acquireOptionalImportedServices()
Configuration API: Acquire all the optional imported services. This method is typically not used by subclasses, except in rare cases.

See Also:
releaseOptionalImportedServices(), IBundleActivationManager.acquireOptionalImportedServices()

activate

protected void activate()
Hook API: This method is overridden by subclasses that wish to execute domain specific activation. For example:
 protected void activate() {
     MyDomainObject object = (MyDomainObject) getExportedService(MyService.SERVICE_NAME);
     object.startup();
 }
 

See Also:
IBundleActivationManagerOwner.activate()

addExportedProxyService

protected final void addExportedProxyService(Class interfaceType,
                                             IProxyServiceHandler handler,
                                             Dictionary properties)
Configuration API: Add an exported proxy service.
 protected void createExportedServices() {
     IProxyServiceHandler handler = new ProxyServiceAdapter() {
         public Object createService() {
             return new HotdogVendor();
         }
     };

     Dictionary properties = new Hashtable(11);
     properties.put("cn", "simona");
     properties.put("o", "OTI");
     properties.put("c", "US");

     addExportedProxyService(VendorService.class, handler, properties);
 }
 

See Also:
IBundleActivationManager.addExportedProxyService(java.lang.Class, org.eclipse.soda.sat.core.framework.interfaces.IProxyServiceHandler, java.util.Dictionary)

addExportedProxyServices

protected final void addExportedProxyServices(Class[] interfaceTypes,
                                              IProxyServiceHandler handler,
                                              Dictionary properties)
Configuration API: Add an exported proxy service.
 protected void createExportedServices() {
     Class[] interfaceTypes = new Class[] {
         VendorService.class,
         TicketService.class
     };

     IProxyServiceHandler handler = new ProxyServiceAdapter() {
         public Object createService() {
             return new HotdogVendor();
         }
     };

     Dictionary properties = new Hashtable(11);
     properties.put("cn", "simona");
     properties.put("o", "OTI");
     properties.put("c", "US");

     addExportedProxyService(interfaceTypes, handler, properties);
 }
 

See Also:
IBundleActivationManager.addExportedProxyServices(java.lang.Class[], org.eclipse.soda.sat.core.framework.interfaces.IProxyServiceHandler, java.util.Dictionary)

addExportedService

protected final void addExportedService(String name,
                                        Object service,
                                        Dictionary properties)
Configuration API: Add an exported service with properties. For example:
 protected void createExportedServices() {
     VendorService vendor = new HotdogVendor();

     Dictionary properties = new Hashtable(11);
     properties.put("cn", "simona");
     properties.put("o", "OTI");
     properties.put("c", "US");

     addExportedService(VendorService.SERVICE_NAME, vendor, properties);
 }
 

See Also:
IBundleActivationManager.addExportedService(java.lang.String, java.lang.Object, java.util.Dictionary)

addExportedServices

protected final void addExportedServices(String[] names,
                                         Object service,
                                         Dictionary properties)
Configuration API: Add multiple exported service with properties. For example:
 protected void createExportedServices() {
     String[] names = new String[] {
         VendorService.SERVICE_NAME,
         TicketService.SERVICE_NAME
     };

     Object vendor = new HotdogVendor();

     Dictionary properties = new Hashtable(11);
     properties.put("cn", "simona");
     properties.put("o", "OTI");
     properties.put("c", "US");

     addExportedService(names, vendor, properties);
 }
 

See Also:
IBundleActivationManager.addExportedServices(java.lang.String[], java.lang.Object, java.util.Dictionary)

addImportedServiceFilter

protected final void addImportedServiceFilter(String name,
                                              String filterString)
Configuration API: Add an LDAP filter to an imported service. For example:
 protected void start() {
     BundleContext context = getBundleContext();
     addImportedServiceFilter(YourService.SERVICE_NAME, "(o=IBM)");
 }
 

See Also:
IBundleActivationManager.addImportedServiceFilter(java.lang.String, java.lang.String)

addOptionalImportedServiceFilter

protected final void addOptionalImportedServiceFilter(String name,
                                                      String filterString)
Configuration API: Add an LDAP filter to an optional imported service. For example:
 protected void start() {
     BundleContext context = getBundleContext();
     addOptionalImportedServiceFilter(YourService.SERVICE_NAME, "(o=IBM)");
 }
 

See Also:
IBundleActivationManager.addOptionalImportedServiceFilter(java.lang.String, java.lang.String)

basicGetImportedServiceNames

protected final String[] basicGetImportedServiceNames()
Get the imported service names. This is the a basic implementation that collects the imported service names by delegating to the subclass.

Returns:
An array of imported service names.

basicGetOptionalImportedServiceNames

protected final String[] basicGetOptionalImportedServiceNames()
Get the optional imported service names. This is the a basic implementation that collects the optional imported service names by delegating to the subclass.

Returns:
An array of optional imported service names.

collectImportedServiceNames

protected void collectImportedServiceNames(Set serviceNames)
Hook API: This method is extended by subclasses that have required imported services. Note: This method is an alternative to implementing getImportedServiceNames().

Parameters:
serviceNames - A Set into which collected service names must be added.

collectOptionalImportedServiceNames

protected void collectOptionalImportedServiceNames(Set serviceNames)
Hook API: This method is extended by subclasses that have optional imported services. Note: This method is an alternative to implementing getOptionalImportedServiceNames().

Parameters:
serviceNames - A Set into which collected service names must be added.

deactivate

protected void deactivate()
Hook API: You have been deactivated. Concrete subclasses sometimes override this method to execute domain specific deactivation. For example:
 protected void deactivate() {
     MyDomainObject object = (MyDomainObject) getExportedService(MyService.SERVICE_NAME);
     object.shutdown();
 }
 

See Also:
IBundleActivationManagerOwner.deactivate()

getAsyncStartPriority

protected int getAsyncStartPriority()
Configuration Parameter API: Get the async start thread priority. This method is overridden by bundles that have overridden the method isStartAsync() to return true and wish to specify a thread priority other than Thread.NORM_PRIORITY . For example:
 protected int getAsyncStartPriority() {
     return Thread.NORM_PRIORITY + 1;
 }
 

See Also:
IBundleActivationManagerOwner.getAsyncStartPriority()

getBundle

protected final Bundle getBundle()
OSGi Query API: Get the bundle.

See Also:
IBundleActivationManager.getBundle()

getBundleActivationManager

protected final IBundleActivationManager getBundleActivationManager()
Protected bundleActivationManager getter.

Returns:
The IBundleActivationManager.

getBundleContext

protected final BundleContext getBundleContext()
OSGi Query API: Get the bundle context.

See Also:
IBundleActivationManager.getBundleContext()

getBundleSymbolicName

protected final String getBundleSymbolicName()
OSGi Query API: Query the bundle's manifest for its Bundle-SymbolicName header.

See Also:
IBundleActivationManager.getBundleSymbolicName()

getDataDirectory

protected final File getDataDirectory()
Persistent Bundle Storage API: Get the bundle's private data directory. The data directory is where it stores persistent data files.

See Also:
IBundleActivationManager.getDataDirectory()

getDataFile

protected final File getDataFile(String filename)
Persistent Bundle Storage API: Open a data file contained in the bundle's private data directory. If the file does not exist, then it is created. The data file resides persistently in the bundle's private data directory within the bundle store.

See Also:
IBundleActivationManager.getDataFile(java.lang.String)

getExportedService

protected final Object getExportedService(String name)
Query API: Get a named exported service object.

See Also:
IBundleActivationManager.getExportedService(java.lang.String)

getExportedServiceNamesFromManifest

protected final String[] getExportedServiceNamesFromManifest()
Deprecated. OSGi R4 has deprecated the Export-Service header.

Query API: Answers the names of all the services that are documented in the bundle's manifest as exported.

Returns:
Array of String service names.

getExportedServiceProperties

protected final Dictionary getExportedServiceProperties(String name)
Query API: Answers the properties of an exported service.

See Also:
IBundleActivationManager.getExportedServiceProperties(java.lang.String)

getExportedServiceProperties

protected final Dictionary getExportedServiceProperties(String name,
                                                        Object service)
Query API: Answers the properties of a specific exported service.

See Also:
IBundleActivationManager.getExportedServiceProperties(java.lang.String, java.lang.Object)

getExportedServices

protected final Map getExportedServices()
Query API: Query the exported services.

See Also:
IBundleActivationManager.getExportedServices()

getExportedServices

protected final Object[] getExportedServices(String name)
Query API: Query the exported services.

See Also:
IBundleActivationManager.getExportedServices(java.lang.String)

getFilePropertiesInputStream

protected final InputStream getFilePropertiesInputStream()
                                                  throws IOException
Query API: Create an input stream on the default properties file.

Throws:
IOException
See Also:
IBundleActivationManager.getFilePropertiesInputStream()

getFilePropertiesInputStream

protected final InputStream getFilePropertiesInputStream(String filename)
                                                  throws IOException
Query API: Create an input stream on the specified properties file.

Throws:
IOException
See Also:
IBundleActivationManager.getFilePropertiesInputStream(java.lang.String)

getImportedService

protected final Object getImportedService(String name)
Query API: Get the named imported service.

See Also:
IBundleActivationManager.getImportedService(java.lang.String)

getImportedServiceFilter

protected final Filter getImportedServiceFilter(String name)
Query API: Search for an imported service filter.

See Also:
IBundleActivationManager.getImportedServiceFilter(java.lang.String)

getImportedServiceNames

protected String[] getImportedServiceNames()
Query API: Answers the names of all the services that are imported by the bundle.

See Also:
IBundleActivationManagerOwner.getImportedServiceNames()

getImportedServiceNamesFromManifest

protected final String[] getImportedServiceNamesFromManifest()
Deprecated. OSGi R4 has deprecated the Import-Service header.

Query API: Answers the names of all the services that are documented in the bundle's manifest as imported.

Returns:
Array of String service names.

getImportedServiceProperty

protected final Object getImportedServiceProperty(String name,
                                                  String key)
Query API: Get the value of an imported service's property.

See Also:
IBundleActivationManager.getImportedServiceProperty(java.lang.String, java.lang.String)

getImportedServicePropertyKeys

protected final String[] getImportedServicePropertyKeys(String name)
Query API: Get the keys of an imported service's properties.

See Also:
IBundleActivationManager.getImportedServicePropertyKeys(java.lang.String)

getImportedServices

protected final Map getImportedServices()
Query API: Query the imported services.

See Also:
IBundleActivationManager.getImportedServices()

getOptionalImportedService

protected final Object getOptionalImportedService(String name)
Query API: Get the named optional imported service.

See Also:
IBundleActivationManager.getOptionalImportedService(java.lang.String)

getOptionalImportedServiceFilter

protected final Filter getOptionalImportedServiceFilter(String name)
Query API: Search for an optional imported service filter.

See Also:
IBundleActivationManager.getOptionalImportedServiceFilter(java.lang.String)

getOptionalImportedServiceNames

protected String[] getOptionalImportedServiceNames()
Query API: Answers the names of all the services that are optionally imported by the bundle.

See Also:
IBundleActivationManagerOwner.getOptionalImportedServiceNames()

getOptionalImportedServiceProperty

protected final Object getOptionalImportedServiceProperty(String name,
                                                          String key)
Query API: Get the value of an optional imported service's property.

See Also:
IBundleActivationManager.getOptionalImportedServiceProperty(java.lang.String, java.lang.String)

getOptionalImportedServicePropertyKeys

protected final String[] getOptionalImportedServicePropertyKeys(String name)
Query API: Get the keys of an optional imported service's properties.

See Also:
IBundleActivationManager.getOptionalImportedServicePropertyKeys(java.lang.String)

getOptionalImportedServices

protected final Map getOptionalImportedServices()
Query API: Query the optional imported services.

See Also:
IBundleActivationManager.getOptionalImportedServices()

getProperties

protected final Properties getProperties()
Query API: Create a Properties object out of the bundle's properties. The properties are obtained using the query method getPropertiesInputStream(), which is typically overridden by subclasses that define properties.

Returns:
The bundle's properties.

getPropertiesInputStream

protected InputStream getPropertiesInputStream()
                                        throws IOException
Hook API: Get an input stream to the bundle's properties. This method is overridden by subclasses that possess properties. For example, if the properties file is stored as a resource in the same package as the BundleActivator:
 protected InputStream getPropertiesInputStream() throws IOException {
     return getResourcePropertiesInputStream();
 }
 
And if the properties are stored as a file in the local file system:
 protected InputStream getPropertiesInputStream() throws IOException {
     return getFilePropertiesInputStream();
 }
 

Throws:
IOException
See Also:
IBundleActivationManagerOwner.getPropertiesInputStream()

getProperty

protected String getProperty(String key,
                             String defaultValue)
Query API: Get the value of a property.

Parameters:
key - The property key.
defaultValue - The default value for the property.
Returns:
The value of the property, or the default value if the key is not found.

getResourcePropertiesInputStream

protected final InputStream getResourcePropertiesInputStream()
                                                      throws IOException
Query API: Create an input stream on the default resource properties.

Returns:
An input stream to the default resource properties.
Throws:
IOException

getResourcePropertiesInputStream

protected final InputStream getResourcePropertiesInputStream(String filename)
                                                      throws IOException
Query API: Create an input stream on the specified resource file.

Parameters:
filename - The name of the properties resource file.
Returns:
An input stream to the resource properties.
Throws:
IOException

handleAcquiredOptionalImportedService

protected void handleAcquiredOptionalImportedService(String serviceName,
                                                     Object service)
Hook Handler API: When an optional imported service is acquired, this method is called. Subclasses should override this method to handle the domain specific case where an optional imported service is acquired. For example:
 protected void handleAcquiredOptionalImportedService(String serviceName, Object service) {
     if (serviceName.equals(PrinterApplicationService.SERVICE_NAME)) {
         PrinterApplicationWindow window = getWindow();
         PrinterApplicationService model = (PrinterApplicationService) service;
         window.setModel(model);
     } else {
         super.handleAcquiredOptionalImportedService(serviceName, service);
     }
 }
 
Since all acquired optional imported services will arrive via this method, it is important to separately handle each imported service.

See Also:
IBundleActivationManagerOwner.handleAcquiredOptionalImportedService(java.lang.String, java.lang.Object)

handleException

protected boolean handleException(Exception exception)
Hook Handler API: Handles a thrown exception. This method can be overridden by subclasses that wish to handle thrown exceptions themselves.

See Also:
IBundleActivationManagerOwner.handleException(java.lang.Exception)

handleFailedToFindProperties

protected void handleFailedToFindProperties(String filename)
Hook Handler API: Handle the fact that the specified properties file could not be found.

See Also:
IBundleActivationManagerOwner.handleFailedToFindProperties(java.lang.String)

handleReleasedOptionalImportedService

protected void handleReleasedOptionalImportedService(String serviceName,
                                                     Object service)
Hook Handler API: When an optional imported service is released, this method is called. Subclasses should override this method to handle the domain specific case where an optional imported service is released. For example:
 protected void handleReleasedOptionalImportedService(String serviceName, Object service) {
     if (serviceName.equals(PrinterApplicationService.SERVICE_NAME)) {
         PrinterApplicationWindow window = getWindow();
         window.setModel(null);
     } else {
         super.handleReleasedOptionalImportedService(serviceName, service);
     }
 }
 
Since all acquired optional imported services will arrive via this method, it is important to separately handle each imported service.

See Also:
IBundleActivationManagerOwner.handleReleasedOptionalImportedService(java.lang.String, java.lang.Object)

isStartAsync

protected boolean isStartAsync()
Configuration Parameter API: Specifies whether the bundle should start asynchronously. This method should be overridden by bundles that wish to start asynchronously. For example:
 protected boolean isStartAsync() {
     return true;
 }
 

See Also:
IBundleActivationManagerOwner.isStartAsync()

isTransient

protected boolean isTransient()
Configuration Parameter API: Specify whether the bundle should be treated as transient. Transient bundles are automatically uninstalled once they have started and entered the Bundle.ACTIVE state. This method should be overridden by bundles that are to be considered transient. For example:
 protected boolean isTransient() {
     return true;
 }
 
Note:

See Also:
IBundleActivationManagerOwner.isTransient()

isUninstallable

protected boolean isUninstallable()
Configuration Parameter API: Specify whether the bundle should be treated as uninstalled. Uninstalled bundles are automatically uninstalled when their last dependent bundle is uninstalled. This method should be overridden to return true by bundles that are uninstallable prerequisites. For example:
 protected boolean isUninstallable() {
     return true;
 }
 

Note:

See Also:
IBundleActivationManagerOwner.isUninstallable()

releaseImportedService

protected final void releaseImportedService(String name)
Configuration API: Release the specified imported services. This method is typically not used by subclasses, except in rare cases. For example, when a bundle imports multiple services using filters, and needs to change multiple filters atomically. Before calling the method addImportedServiceFilter(String, String) to change the filter for each imported service, it is necessary to call the method releaseImportedService(String) for each imported service that has a filter first. Once the filters have been changed, call the method acquireImportedService(String) for each imported service that has a filter to re-acquire the imported services. Doing so ensures that the bundle only ever atomically acquires services with the the appropriate filters.
 ...
 try {
   releaseImportedService(VendorService.SERVICE_NAME);
   releaseImportedService(NapkinService.SERVICE_NAME);
   addImportedServiceFilter(VendorService.SERVICE_NAME, "(spiciness=5)");
   addImportedServiceFilter(NapkinService.SERVICE_NAME, "(ply=2)");
 } finally {
   acquireImportedService(VendorService.SERVICE_NAME);
   acquireImportedService(NapkinService.SERVICE_NAME);
 }
 ...
 
Using try/finally is not strictly necessary, but does nicely ensure that the imported services will always be re-acquired in the face of a thrown exception, however unlikely.

Parameters:
name - The name of an imported service.
See Also:
acquireImportedService(java.lang.String), IBundleActivationManager.releaseImportedService(java.lang.String)

releaseImportedServices

protected final void releaseImportedServices()
Configuration API: Release all the imported services. This method is typically not used by subclasses, except in rare cases. For example, when a bundle imports multiple services using filters, and needs to change multiple filters atomically. Before calling the method addImportedServiceFilter(String, String) to change the filter for each imported service, it is necessary to call the method releaseImportedServices() first. Once both filters have been changed, call the method acquireImportedServices() to re-acquire the services. Doing so ensures that the bundle only ever atomically acquires services with appropriate filters.
 ...
 try {
   releaseImportedServices();
   addImportedServiceFilter(VendorService.SERVICE_NAME, "(spiciness=5)");
   addImportedServiceFilter(NapkinService.SERVICE_NAME, "(ply=2)");
 } finally {
   acquireImportedServices();
 }
 ...
 
Using try/finally is not strictly necessary, but does nicely ensure that the imported services will always be re-acquired in the face of a thrown exception, however unlikely.

See Also:
acquireImportedServices(), IBundleActivationManager.releaseImportedServices()

releaseOptionalImportedServices

protected final void releaseOptionalImportedServices()
Configuration API: Release all the optional imported services.

See Also:
acquireOptionalImportedServices(), IBundleActivationManager.releaseOptionalImportedServices()

removeExportedService

protected final void removeExportedService(String name)
Configuration API: Remove the exported service record of the specified type.

Note: All exported services are automatically removed by SAT when the bundle is deactivated.

See Also:
IBundleActivationManager.removeExportedService(java.lang.String)

removeExportedService

protected final void removeExportedService(String name,
                                           Object service)
Configuration API: Removes the specified exported service.

Note: All exported services are automatically removed by SAT when the bundle is deactivated.

See Also:
IBundleActivationManager.removeExportedService(java.lang.String, java.lang.Object)

removeExportedServices

protected final void removeExportedServices(String name)
Configuration API: Remove the named exported service domain object. While this method is visible to subclasses, it is not typically used.

Note: All exported services are automatically removed by SAT when the bundle is deactivated.

See Also:
IBundleActivationManager.removeExportedServices(java.lang.String)

removeImportedServiceFilter

protected final void removeImportedServiceFilter(String name)
Configuration API: Removes the LDAP filter for an imported service.

See Also:
IBundleActivationManager.removeImportedServiceFilter(java.lang.String)

removeOptionalImportedServiceFilter

protected final void removeOptionalImportedServiceFilter(String name)
Configuration API: Removes the LDAP filter for an optional imported service.

See Also:
IBundleActivationManager.removeOptionalImportedServiceFilter(java.lang.String)

restartFramework

protected final void restartFramework()
                               throws BundleException
OSGi Framework API: Stop and restart the OSGi framework. If the bundle has been stopped, this method does nothing.

Note: Sadly, this method does not work on Equinox 3.3.0. See Eclipse bug 128531 for more details.

Throws:
BundleException
See Also:
IBundleActivationManager.restartFramework()

setExportedServiceProperties

protected final void setExportedServiceProperties(String name,
                                                  Dictionary properties)
Configuration API: Sets the properties of an exported service.

See Also:
IBundleActivationManager.setExportedServiceProperties(String, java.util.Dictionary)

setExportedServiceProperties

protected final void setExportedServiceProperties(String name,
                                                  Object service,
                                                  Dictionary properties)
Configuration API: Sets the properties of an exported service.

See Also:
IBundleActivationManager.setExportedServiceProperties(java.lang.String, java.lang.Object, java.util.Dictionary)

shutdownFramework

protected final void shutdownFramework()
                                throws BundleException
OSGi Framework API: Shutdown the OSGi framework. If the bundle has been stopped, this method does nothing.

Throws:
BundleException
See Also:
IBundleActivationManager.shutdownFramework()

start

protected void start()
              throws Exception
Hook API: This method is called by start(BundleContext) . This method is typically overridden by subclasses that wish to perform behavior exactly once when the bundle starts. For example:
 protected void start() {
     PrinterApplicationWindow window = getWindow();
     WindowListener listener = getWindowListener();
     window.addWindowListener(listener);
     window.open();
 }
 

Throws:
Exception
See Also:
IBundleActivationManagerOwner.start()

start

public final void start(BundleContext bundleContext)
                 throws Exception
Bundle Activator API: This is where the bundle activator starts its execution.

Specified by:
start in interface BundleActivator
Throws:
Exception
See Also:
BundleActivator.start(org.osgi.framework.BundleContext)

stop

protected void stop()
             throws Exception
Hook API: This method is called by stop(BundleContext) . This method is overridden by subclasses that wish to perform behavior exactly once when the bundle stops. For example:
 protected void stop() {
     PrinterApplicationWindow window = getWindow();
     window.close();
     WindowListener listener = getWindowListener();
     window.removeWindowListener(listener);
 }
 

Throws:
Exception
See Also:
IBundleActivationManagerOwner.stop()

stop

public final void stop(BundleContext bundleContext)
                throws Exception
Bundle Activator API: This is where the bundle activator stops its execution.

Specified by:
stop in interface BundleActivator
Throws:
Exception
See Also:
BundleActivator.stop(org.osgi.framework.BundleContext)

Service Activator Toolkit
Version 1.1.0 (20081206)