Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [concierge-dev] How to set Image from Bundle-Icon header where bundle is in INSTALLED state

sorry, but I made a mistake:
bundle.getEntry() in INSTALLED state returns of course: bundle://1.0/icon.png // after bundle.getEntry( "Bundle-Icon").toString()

2014-12-05 12:51 GMT+01:00 Ladislav Török <ltorokrl@xxxxxxxxx>:
bundle.getHeaders() in INSTALLED state returns :

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.2
Bundle-Activator: sk.ltorok.bundles.Bundle1
Created-By: 1.8.0_40-ea-b15 (Oracle Corporation)
Bundle-ManifestVersion: 2
Import-Package: org.osgi.framework
Bundle-SymbolicName: sk.ltorok.bundles
Bundle-Name: sk.ltorok.bundles
Bundle-Version: 1.0.0
Bundle-Icon: /icon.png

and bundle.getEntry() in INSTALLED state returns:
bundle://1.0/VideoPlayer.png // after bundle.getEntry( "Bundle-Icon").toString()

2014-12-05 11:19 GMT+01:00 Jochen Hiller <jo.hiller@xxxxxxxxxxxxxx>:
Hi Ladislav,

On Fri, Dec 5, 2014 at 10:52 AM, Ladislav Török <ltorokrl@xxxxxxxxx> wrote:
I want in INSTALLED state of bundle only create ImageView (in JavaFX) - It will represent bundle for my using.
After click on ImageView (icon) bundle is call bundle.start() -> ACTIVE state.

OK I see. Sounds reasonable

 
Present snippet is ok but only in RESOLVED state of bundle, at INSTALLED state of bundle ImageView dont have picture.

URL entry = bundle.getEntry(bundle.getHeaders().get(ICON_HEADER));

What does bundle.getHeaders() and bundle.getEntry() return in INSTALLED state? Maybe the property is defined wrong.
You may have to specify the name of entry with leading slash, e.g. "/myicon.jpg"?
(OK this is no argument why it is working in RESOLVED state).

Bye, Jochen

 
I don't know where is problem.

2014-12-05 8:38 GMT+01:00 Jochen Hiller <jo.hiller@xxxxxxxxxxxxxx>:
Hi Ladislav,

every bundle has its own state based on OSGi bundle life cycle.

INSTALLED means that is has been installed into a framework. This does not necessarily mean that it will work.
When bundle will be started, it goes first to RESOLVED state when all dependencies can be resolved, or stay in INSTALLED state when it can not be resolved. It will go to ACTIVE state when everything is fine.

To be honest there are more variations on that (intermediate states like STARTING, LAZY mode ...). For more details see OSGi R5 spec chapter 4.3.

Whether a bundle can be used in INSTALLED state or only in RESOLVED/ACTIVE state depends on your requirements.
If no Java classes are needed (which seems to be the case when you want to get the Manifest header for a Bundle-Icon) you can also try to get a resource via bundle.getEntry(). In OSGi spec 10.1.6.17 it will be stated that this should be possible. Only when bundle has been uninstalled it will raise an IllegalStateException.

I will check how Concierge will behave in such a situation.

But anyway: why do you want to use the bundle in INSTALLED state only? There are very few situations where this makes sense (e.g. just providing static content).

Bye, Jochen






On Fri, Dec 5, 2014 at 8:12 AM, Ladislav Török <ltorokrl@xxxxxxxxx> wrote:
Here is my snippet:

import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
...

private static final String ICON_HEADER = "Bundle-Icon";
...

final BundleContext bundleContext = framework.getBundleContext();

            bundleContext.addBundleListener((BundleEvent event) -> {
                Bundle bundle = event.getBundle();
                String resolvedBundleEventType = resolveBundleEventType(event.getType());
                System.out.println(bundle.getSymbolicName() + " -> " + resolvedBundleEventType);

                if (resolvedBundleEventType == "INSTALLED") {
                    Image bundleImage = null;
                    URL entry = bundle.getEntry(bundle.getHeaders().get(ICON_HEADER));
                    if (entry != null) {
                        bundleImage = new Image(entry.toString());
                    }

                    if (bundleImage != null) {
                        ImageView bundleImageView = new ImageView(bundleImage);
                        bundleImageView.setX(30);
                        bundleImageView.setY(100);
                        ((Group) scene.getRoot()).getChildren().add(bundleImageView);
                    }
                }
            });

If I replace the line
if (resolvedBundleEventType == "INSTALLED") {
to
if (resolvedBundleEventType== "RESOLVED") {
then all is ok.

There is no way to do this in INSTALLED state of bundle?

_______________________________________________
concierge-dev mailing list
concierge-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/concierge-dev


_______________________________________________
concierge-dev mailing list
concierge-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/concierge-dev


_______________________________________________
concierge-dev mailing list
concierge-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/concierge-dev


_______________________________________________
concierge-dev mailing list
concierge-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/concierge-dev



Back to the top