[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] BundleContext and getName



I agree that the method name should be getBundles(String UniqueId).  But I
do not think we should add too many helper methods.  Maybe it would be
better to change the symantics of getBundle(String UniqueId, String
version) to return an arbitrarily chosen bundle if the version parameter is
null.

What do you think?

Thomas Watson
Pervasive Development
Phone: 512-838-4533 Tie: 678-4533
tjwatson@xxxxxxxxxx



                                                                                                                                               
                      Rafael Chaves                                                                                                            
                      <Rafael_Chaves@ca.        To:       equinox-dev@xxxxxxxxxxx                                                              
                      ibm.com>                  cc:                                                                                            
                      Sent by:                  Subject:  Re: [equinox-dev] BundleContext and getName                                          
                      equinox-dev-admin@                                                                                                       
                      eclipse.org                                                                                                              
                                                                                                                                               
                                                                                                                                               
                      10/06/2003 08:44                                                                                                         
                      AM                                                                                                                       
                                                                                                                                               
                                                                                                                                               





I agree as well. I have just two concerns with the proposed APIs:

1 - The method that returns multiple bundles should be called "getBundles"
(plural).
2 - I would also suggest that a method that returns a single bundle with no
version specified could still be provided (see
org.eclipse.core.runtime.IPluginRegistry.getPluginDescriptor(String)):

      /**
      * Returns a Bundle with the specified Bundle-UniqueId
       * or null if none exist. If more than one bundle with
       * the specified Bundle-UniqueId exist, one of them will
       * be arbitrarily chosen.
      */
     public Bundle getBundle(String uniqueId, String version);

This is pretty useful when you don't care about versions, because it
doesn't force you to do this:

Bundle[] allBundles = context.getBundles(id);
Bundle interestingBundle = (allBundles == null) ? null : allBundles[0];

When all you need is:
Bundle interestingBundle = context.getBundle(id);


                                                                          
   Thomas Watson                                                          
   <tjwatson@xxxxxxxxxx>                  To:                             
   Sent by:                       equinox-dev@xxxxxxxxxxx                 
   equinox-dev-admin@xxxxxxxxxxx          cc:                             
                                          Subject:        Re:             
                                  [equinox-dev] BundleContext and getName 
   06/10/2003 09:17 AM                                                    
                                                                          









I think you are refering to the BundleContext.getBundle(String name)
method.  The BundleContext interface has a new method
BundleContext.getBundle(String name) which was intended to take a
Bundle-Name and look in the framework to find a single bundle with a
matching name.  This method definition has a flaw in the fact that it
assumes that Bundle-Names are unique in the framework.  I agree that the
new BundleContext.getBundle(String name) method should be changed.  I have
the following two proposals.

interface BundleContext {
...

     /**
      * Returns all Bundles with the specified Bundle-UniqueId or null
      * if none exist.
      */
     public Bundle[] getBundle(String uniqueId);
     /**
      * Returns the Bundle with the specified Bundle-UniqueId and
Bundle-Version
      * or null if none exist.
      */
     public Bundle getBundle(String uniqueId, String version);
...

}

Since the framework can have multiple versions of a bundle with the same
uniqueId installed then the BundleContext.getBundle(String uniqueId) should
return a list of all the bundles with the specified uniqueId.  If you want
a specific version of a bundle then use the BundleContext.getBundle(String
uniqueId, String version) method.  We can get by with only the
BundleContext.getBundle(String unqueId) method.  This just means the
callers would have to look for specific versions if they needed to in the
list returned.

Any comments?

Thomas Watson
Pervasive Development
Phone: 512-838-4533 Tie: 678-4533
tjwatson@xxxxxxxxxx




                     Pascal Rapicault

                     <Pascal_Rapicault@        To:
equinox-dev@xxxxxxxxxxx

                     ca.ibm.com>               cc:

                     Sent by:                  Subject:  [equinox-dev]
BundleContext and getName
                     equinox-dev-admin@

                     eclipse.org



                     10/06/2003 07:35

                     AM








Hi,

Currently BundleContext.getName(String) uses the Bundle-name entry to do
the lookup.
Now that we have Bundle-uniqueId, it seems to me that it would be more
appropriate to do the lookup on this value.
Any comments?

       PaScaL


_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/equinox-dev