Bundlecontext. install bundle example




















Return A map of all framework properties. Returns the Bundle object associated with this BundleContext. Return The Bundle object associated with this BundleContext. Return A Bundle object or nullptr if the identifier does not match any previously installed bundle. Parameters id : The identifier of the bundle to retrieve. Parameters location : The location of the bundles to get. This method returns a list of all bundles installed in the bundle environment at the time of the call to this method.

This list will also contain bundles which might already have been stopped. Return A std::vector of Bundle objects which will hold one object per known bundle. Registers the specified service object with the specified properties under the specified class names into the framework. A ServiceRegistration object is returned. The ServiceRegistration object is for the private use of the bundle registering the service and should not be shared with other bundles. The registering bundle is defined to be the context bundle.

A bundle can register a service object that implements the ServiceFactory or PrototypeServiceFactory interface to have more flexibility in providing service objects to other bundles.

Properties with these names in the specified ServiceProperties will be ignored. The service is added to the framework service registry and may now be used by other bundles. A ServiceRegistration object for this registration is returned. Note This is a low-level method and should normally not be used directly. Use one of the templated RegisterService methods instead. The keys in the properties object must all be std::string objects. See Constants for a list of standard service property keys.

Changes should not be made to this object after calling this method. The set of properties may be omitted if the service has no properties. Registers the specified service object with the specified properties using the specified interfaces types with the framework. This method is provided as a convenience when registering a service under two interface classes whose type is available to the caller.

Interfaces : Additional interface types under which the service can be located. ServiceException : If the service type S is invalid or the service object is nullptr. Registers the specified service factory as a service with the specified properties using the specified template argument as service interface type with the framework.

This method is provided as a convenience when factory will only be registered under a single class name whose type is available to the caller. ServiceException : If the service type S is invalid or the service factory object is nullptr.

Returns a list of ServiceReference objects. The returned list contains services that were registered under the specified class and match the specified filter expression. Bundle getBundle long id Returns the bundle with the specified identifier. Bundle [] getBundles Returns a list of all installed bundles. File getDataFile String filename Creates a File object for a file in the persistent storage area provided for the bundle by the Framework.

String getProperty String key Returns the value of the specified property. Object getService ServiceReference reference Returns the specified service object for a service. ServiceReference getServiceReference String clazz Returns a ServiceReference object for a service that implements and was registered under the specified class.

Bundle installBundle String location Installs a bundle from the specified location string. ServiceRegistration registerService String [] clazzes, Object service, Dictionary properties Registers the specified service object with the specified properties under the specified class names into the Framework. Improve this question. Community Bot 1 1 1 silver badge. Add a comment. Active Oldest Votes. String path method which return an Url and is documented as: Returns a URL to the entry at the specified path in this bundle.

Improve this answer. Manuel Selva Manuel Selva Is there anyway to access it outside of the context of the BundleActivator? However, I am looking for a solution if there is any to access it outside of the BundleActivator. I had a look at eclipsezone. Have you look on a way to get a Bundle object from the bundle id? I can get the entry, but the problem is that getEntry only supplies the relative path, and not the full root path of the bundle: techinfopad.

Alternatively the following should work: this. Neil Bartlett Neil Bartlett I have opted for this solution but had issues with trying to import all the directory's values e. I ended up 'copying' the files to a temporary location, but this induces some performance issues. We did this because we need to share the interface definition with other bundles, therefore it is better to separate service interfaces that need to be shared from code that does not need to be shared.

Such an approach ensures a strong separation between interface and implementation. In the following source code, the bundle uses its bundle context to register the dictionary service. We implement the dictionary service as an inner class of the bundle activator class, but we could have also put it in a separate file. The source code for our bundle is as follows in a file called Activator. Note that we do not need to unregister the service in the stop method, because the OSGi framework will automatically do so for us.

The dictionary service that we have implemented is very simple; its dictionary is a static array of only five words, so this solution is not optimal and is only intended for educational purposes. We must create a manifest. We specify which class is used to activate our bundle via the Bundle-Activator attribute and also specify that our bundle exports a shared package using the Export-Package attribute.

The Export-Package attribute makes it possible for other bundles to import our dictionary service interface.



0コメント

  • 1000 / 1000