>From your example, it seems that 2 bundles have a copy of the same classfile. However each bundle's classloader will load its copy of the classfile resulting in 2 distinct classes in the VM. They both have the same name but they are different Class objects because the tuple (class name, class loader) is different.
So when each bundle registers an object of its class as a service, you end up with 2 service registrations. Each service will be registered under the same class name but the service objects are not class compatible (see paragraph above). Now let assume each bundle exported the package containing MyClass (the class of the service). Then if a 3rd bundle imported that package, it would be wired to only one of the orginal 2 bundles. So when the 3rd bundle does a service lookup (BundleContext.getServiceReference), it will find the service registered by the bundle to which its import is wired. If the 3rd bundle calls BundleContext.getAllServiceReferences it will see both services, since that method does include package wiring in its constraints. BJ Hargrave Senior Technical Staff Member, IBM OSGi Fellow and CTO of the OSGi Alliance [EMAIL PROTECTED] Office: +1 407 849 9117 Mobile: +1 386 848 3788 "joe antony lawrence david" <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 08/08/2006 03:46 AM Please respond to OSGi Developer Mail List <[EMAIL PROTECTED]> To [EMAIL PROTECTED] cc Subject [osgi-dev] Service Registration Hi everybody! Greetings! I have a doubt with service registration in OSGi R4. Can two diff bundles register two similar services, meaning with the same classname and properties, but with a different service impl object. For e.g., Class MyClass implements BundleActivator { pulic void start() { // construct a map with a property holding this classname. sReg = bundlecontext.registerService(this.getClass ().getName(), this, map); } public void stop() { sReg.unregister(); } } Now, can I have the same class as part of two of my bundles, install and start them sucessfully. Will two services be registered in the framework under the same classname? Please note that the package in which this class resides is the same in both the bundles. -- Cheers Joe ---------------- Visit my blog at http://djlolly.blogspot.com * Believing in yourself is an endless destination; But, believing your have failed is the end of the journey. * A pound a fret cant pay an ounce a debt. _______________________________________________ osgi-dev mailing list osgi-dev@bundles.osgi.org http://bundles.osgi.org/mailman/listinfo/osgi-dev _______________________________________________ osgi-dev mailing list osgi-dev@bundles.osgi.org http://bundles.osgi.org/mailman/listinfo/osgi-dev