[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Bundle and Registry

Proposal to register bundles in the service registry

When a bundle is installed, the Framework must register the Bundle
object in the Framework registry (BundleContext.registerService()). The
properties of this service are all the main manifest headers, the
state of the service (service.state String), the bundle location, and
the namespace identifiers (service.namespaces long[]). The owner
of the service (which is a Bundle object) must be the Framework.

When the Bundle changes state, the state property must be updated and a
ServiceEvent.MODIFIED must be emitted. When the bundle is un-installed,
the Bundle service object is removed from the service registry, after
all other services are un-registered.

It is now possible to:

- Find bundles depending on any criteria that is a assertion on the
  headers (name, uniqueid, version, module, ...), state or namespace.

- Listen to bundles that come and go, on specific criteria. Notice
  that you can specify a filter on the service tracker. This allows
  service trackers to be used for following a bundle's lifecycle.

- Use debuggers that enumerate the registry and allow the user to
  inspect it. Single mechanism, used for many purposes.

- Use ServicePermission(Bundle,GET) to control access to this

- Easy to extend with new service properties when the need arises.
  These kind of changes are 100% backward compatible and easy to adapt

- The visibility rules of services have not been defined yet and they
  make it necessary to specify the owner

- service.namespaces: This is the scope/namespace we will need to separate bundles
  that are running incompatible versions. This is probably a numeric identifier
  that is assigned by the framework. This is not discussed yet and I may
  be off track here ...)

- We might want to limit the headers that are visible in the registry.
  On the other hand, we might add more synthetic properties like
  exported packages, imported packages, etc.

- We might need a synthetic property that verifies if a bundle has a
  compatible namespace. This implies there needs to be a default: or
  searches are by default restricted and a full search requires to
  use this synthetic property. Or vice versa.

- The "owner" of the bundle could be either of:

  - The bundle itself.
  - The framework

  The framework as owner is more natural, however, we then have the
  visibility issue when multiple versions are around. We have not yet
  addressed this issue, except for some minor discussions. The requirement
  is that a bundle can only see services that are compatible in
  version (i.e. share a same namespace/scope). Registering a Bundle
  service with the Bundle itself as owner would automatically give you
  this protection but it feels a bit like a hack. I also think that
  the management bundles should see ALL services and should have a way
  to get the ones that are compatible.

- Security issues may arise because the properties are visible to all
  bundles having ServicePermission[Bundle]. However, imho this kind of
  access is privileged to management agents and they need sufficient
  access anyway. Are there (good) use cases where some bundles need
  access to the Bundle objects but are not allowed to see all the
  headers? (There is still always the Bundle methods on


Hope this helps, kind regards,

     Peter Kriens


PR> Peter, 

PR> Could you please provide more details on how this mechanism of registry 
PR> would work?
PR> The way I understand it, it seems to be quite similar to the plugin 
PR> registry that eclipse have and that returns the plugin object.

PR> Thanks

PR>   PaScaL

PR> Peter Kriens <Peter.Kriens@xxxxxxxx>
PR> Sent by: equinox-dev-admin@xxxxxxxxxxx
PR> 10/08/2003 02:26 AM
PR> Please respond to pkriens
PR>         To:     equinox-dev@xxxxxxxxxxx
PR>         cc: 
PR>         Subject:        Re[2]: [equinox-dev] BundleContext and getName

PR> OK, I propose -again- to register the bundle objects as a service with all 
PR> the
PR> attributes from the manifest (and more). This service should be registered 
PR> with the
PR> bundle itself as owner. This would allow full searching and it 
PR> automatically
PR> handles the visibility issue because you are only allowed to see
PR> the service of bundles that you are compatible with.

PR> I also see that we need a "namespace" id on services to handle the
PR> issue of different namespaces in registry.

PR> Kind regards,

PR>      Peter Kriens

BR>> I guess my big disagreement is with the idea that for something to be 
BR>> clear and concrete you must reflect it in the API as a method. You can 

BR>> have a clear spec and concrete exposure by defining a constant that 
PR> you 
BR>> can use in a filter. That is what we do for sid and pid in the example 

BR>> of service properties. We could have added getSID() and getPID() 
PR> methods 
BR>> to ServiceReference. By changing the API you cast in stone something 
BR>> that you may want to change further down the road.

BR>> Further, whatever you come up with you will need the option to see all 

BR>> the bundles, otherwise you will break management type bundles. (I tend 

BR>> to agree that you shouldn't change the semantics of getBundles()...)

BR>> Your example using filters would be:

BR>> Filter foo = new Filter("("+Constants.BUNDLE_UNIQUEID+"=Foo)");
BR>> Bundle bundles[] = context.getBundles(foo);

BR>> By doing this you could do things like bypass version filtering 
PR> (getting 
BR>> around the problem of not seeing all bundles):
BR>> Filter foo = new 
PR> Filter("&("+Constants.BUNDLE_UNIQUEID+"=Foo)("+Constants.BUNDLE_VERSION+"=*)"); 

BR>> // Gets all versions
BR>> or
BR>> Filter foo = new 
PR> Filter("&("+Constants.BUNDLE_UNIQUEID+"=Foo)("+Constants.BUNDLE_VERSION+"=2.*)"); 

BR>> // Gets all 2.X versions

BR>> my 3 cents
BR>> ben

BR>> ps - I REALLY hate naming discussions and I won't participate in 
BR>> discussions on naming topics, but uniqueID is a really BAD name! There 

BR>> are already two unique ids: Bundle ID and Bundle location. Calling 
BR>> another identifier the unique id is very confusing!

BR>> Jeff McAffer wrote:

>>> yes and no.  Yes, the unique id of a bundle is in the manifest for 
>>> that bundle.  There may be several bundles with the same unique id but 
>>> different version numbers.  Each of these would have manifests with 
>>> the the header
>>>         Bundle-UniqueId: Foo  (or some such)
>>> but
>>>         Bundle-Version:
>>> headers with different values
>>> For some bundle Bar which can "see" a bundle Foo, the system will 
>>> determine a particular version of Foo to present to Bar.  It is this 
>>> Foo which Bar.getBundleContext().getBundle("Foo") should return.
>>> So, to implement this using just getHeaders() you have to do something 
>>> like
>>>         Bundle[] bundles = Bar.getBundles()
>>>         for each b in bundles
>>>                 String id= b.getHeaders().get("Bundle-UniqueId")
>>>                 if (id.equals("Foo"))
>>>                         return b
>>>         return null
>>> Note that this only works if Bar.getBundles() returns only those 
>>> bundles which Bar can see (as determined by the system).  Some have 
>>> argued that this is an unacceptable semantic change.  That is, people 
>>> expect getBundles() to return all installed bundles.  If it did that, 
>>> then the list would include several Foo bundles and we would not know 
>>> which one to pick.  Note that either way you cut it, the code above is 
>>> slow.
>>> Ultimately what is being discussed is the introduction of a 
>>> semantically meaningful/powerful symbolic identifier for bundles that 
>>> is independent of origin (location) and install circumstances (i.e., 
>>> when it was installed).  This is in support of bundles as modules and 
>>> other work where one bundle needs to refer to another bundle.  The 
>>> argument is that this particular header is not "just another header" 
>>> and it warrants concrete exposure on the API of Bundle/BundleContext. 
>>>  Doing so allows for a clearer specification as well as easier, more 
>>> efficient code.
>>> Jeff
>>> *Benjamin Reed <breed@xxxxxxxxxxxxxxx>*
>>> 10/07/2003 02:03 PM
>>>         To:        Jeff McAffer/Ottawa/IBM@IBMCA
>>>         cc:        equinox-dev@xxxxxxxxxxx, BJ Hargrave 
>>> <hargrave@xxxxxxxxxx>, Pascal Rapicault/Ottawa/IBM@IBMCA, pkriens 
>>> <Peter.Kriens@xxxxxxxx>
>>>         Subject:        Re: [equinox-dev] BundleContext and getName
>>> If the framework reconciles the view of each bundle, you still don't
>>> have a problem searching headers. We have the same thing with
>>> permissions and service registry -- the framework makes sure you only
>>> see services that you are allowed to get.
>>> If I understand correctly, everything you are trying to search on is
>>> contained in the manifest. Right?
>>> ben
>>> Jeff McAffer wrote:
>>> >
>>> > I too am in favour of keeping the interfaces simple but there is a
>>> > subtle point about function in question.  In the context of possible
>>> > multiple version support, there may be several bundles with the same
>>> > uniqueId but different version numbers.  One idea was that the
>>> > framework would reconcile the view point of each bundle such that it
>>> > "sees" at most one version of the bundles with any given unique-id.
>>> >  Header lookup is not equivalent in this case.
>>> >
>>> > Jeff
>>> >
>>> >
>>> >
>>> >
>>> > *Benjamin Reed <breed@xxxxxxxxxxxxxxx>*
>>> > Sent by: equinox-dev-admin@xxxxxxxxxxx
>>> >
>>> > 10/06/2003 06:15 PM
>>> >
>>> > 
>>> >         To:        pkriens <Peter.Kriens@xxxxxxxx>
>>> >         cc:        Pascal Rapicault/Ottawa/IBM@IBMCA,
>>> > equinox-dev@xxxxxxxxxxx, BJ Hargrave <hargrave@xxxxxxxxxx>
>>> >         Subject:        Re: [equinox-dev] BundleContext and getName
>>> >
>>> >
>>> >
>>> >
>>> > Actually Peter, the discussion was about getting a bundle from the
>>> > location, not the name. They slipped another identifier in. Rather 
PR> than
>>> > proliferating methods I would encourage using Bundle.getHeaders() to 
PR> get
>>> > information about a specific bundle. If you want to add something to
>>> > BundleContext, it would seem much better to do
>>> > BundleContext.getBundles(Filter filter), where you can search on any 
PR> of
>>> > the header fields. That way when you find out that you want to look 
PR> up a
>>> > bundle by another manifest property (potentially Eclipse specific) 
PR> you
>>> > don't have to add another method.
>>> >
>>> > ben
>>> >
>>> > Peter Kriens wrote:
>>> >
>>> > >I saw the discussion regarding the extra method in BundleContext to
>>> > >get a bundle from its name.
>>> > >
>>> > >We had this discussion in the past year in the OSGi and decided 
>>> -not- to
>>> > >extend the BundleContext interface to keep it as simple as possible.
>>> > >There was quite a bit discussion about this.
>>> > >
>>> > >One thing that I proposed, which would more or less fit with the
>>> > >existing standard, is to register the bundle objects in the registry
>>> > >with properties for name, id, module, version, etc. This will allow
>>> > >you search for bundles with an OSGi filter. This may be a cleaner
>>> > >method than adding methods to BundleContext
>>> > >
>>> > >Kind regards,
>>> > >
>>> > >     Peter Kriens
>>> > >
>>> > >PR> Hi,
>>> > >
>>> > >PR> Currently BundleContext.getName(String) uses the Bundle-name
>>> > entry to do
>>> > >PR> the lookup.
>>> > >PR> Now that we have Bundle-uniqueId, it seems to me that it would 
PR> be
>>> > more
>>> > >PR> appropriate to do the lookup on this value.
>>> > >PR> Any comments?
>>> > >
>>> > >PR>         PaScaL
>>> > >
>>> > >
>>> > > 
>>> > >
>>> >
>>> >
>>> > _______________________________________________
>>> > equinox-dev mailing list
>>> > equinox-dev@xxxxxxxxxxx
>>> > http://dev.eclipse.org/mailman/listinfo/equinox-dev
>>> >
>>> >

Peter Kriens                              Mob. +46705950899
34 Place René Nelli                       Tel. +33467871853
34670 Baillargues, France                 AOL: pkriens