You can't "override" exported packages. But, if you use the same package version number as exported by a bundle, the framework will prefer an already exported package when resolving. Since the framework exports the system packages first, then they are preferred. --
BJ Hargrave Senior Technical Staff Member, IBM OSGi Fellow and CTO of the OSGi Alliance hargr...@us.ibm.com office: +1 386 848 1781 mobile: +1 386 848 3788 From: Jansson Patrik <patrik.jans...@saabgroup.com> To: Equinox development mailing list <equinox-dev@eclipse.org> Date: 2009/05/26 04:43 Subject: RE: [equinox-dev] Framework launching and class loaders Sent by: equinox-dev-boun...@eclipse.org What will happen if I let the org.eclipse.osgi.services bundle remain resolved in my OSGi framework and the system bundle export the same version of org.osgi.service.cm? Which package will be imported by other bundles (eclipse implementation of ConfigurationAdmin being one of them)? That way, I don't have to care about exporting packages inside org.eclipse.osgi.services that is not mutually shared by the launcher and bundles inside the framework. So, what I'm asking for is a way to override a specific package exported by a bundle (but not all of them), is that possible? Thanks, -Patrik From: equinox-dev-boun...@eclipse.org [ mailto:equinox-dev-boun...@eclipse.org] On Behalf Of BJ Hargrave Sent: den 25 maj 2009 15:12 To: Equinox development mailing list Subject: Re: [equinox-dev] Framework launching and class loaders The org.osgi.service.cm package has 2 "version" in your example. One loaded from a bundle and used by the ConfigurationAdmin service implementation and the other on the application classpath. You need to either use reflection to use the service (then you don't need the version on the classpath) or you need to configure the framework to export the version on the package on the application classpath from the system bundle (org.osgi.framework.systempackages.extra) so that the ConfigurationAdmin bundle uses that version of the package. -- BJ Hargrave Senior Technical Staff Member, IBM OSGi Fellow and CTO of the OSGi Alliance hargr...@us.ibm.com office: +1 386 848 1781 mobile: +1 386 848 3788 From: Jansson Patrik <patrik.jans...@saabgroup.com> To: "equinox-dev@eclipse.org" <equinox-dev@eclipse.org> Date: 2009/05/25 08:57 Subject: [equinox-dev] Framework launching and class loaders Sent by: equinox-dev-boun...@eclipse.org I'm using the framework launching API to start an OSGi framework (which in this case is Equinox 3.5M6). I need to pass some configuration from the launcher application to one of the bundles running so I thought of using the ConfigurationAdmin service for this. The launcher gets hold of a BundleContext (from the framework handle) and gets a reference to the service; ServiceReference reference = context.getServiceReference(...) But I get into trouble on the next step ConfigurationAdmin cAdmin = (ConfigurationAdmin) context.getService(reference); This throws a ClassCastException. The actual object returned uses equinox's class loader while the class I'm trying to cast to, ConfigurationAdmin, is loaded through the launcher's standard class loader (sun.misc.Launcher$AppClassLoader in this case). How can I go around this? Shouldn't I be playing with OSGi services outside the framework like this? In that case how should I pass configuration from the launcher to the bundle? Thanks, -Patrik Jansson _______________________________________________ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev _______________________________________________ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev
_______________________________________________ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev