Results 1 to 7 of 7

Thread: resolution=optional

  1. #1
    Join Date
    Nov 2008
    Posts
    232

    Default resolution=optional

    what is the use of ;resolution=optional

  2. #2
    Join Date
    Nov 2008
    Posts
    232

    Default

    My use case was :

    Bundle A has import of package with resolution=optional Bundle B having that package is deployed ,Now Bundle A tries to instantiate a Class in the package but shows ClassNotFound .But when the bundle A was redeployed it gets the class succesfully

  3. #3
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    As far as I know optional packages will be resolved only at deployment time. So if the package is present at that time it will available. Otherwise no further resolution attempt will be made later on.

    Regards,
    Andreas

  4. #4
    Join Date
    Nov 2008
    Posts
    232

    Default

    what do i do in such scenario .

  5. #5
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Maybe it just helps to separate interface and implementation of your service. That way the interface should be referred to in a non-optional way, while the implementation is separately managed by the osgi runtime.

    Regards,
    Andreas

  6. #6
    Join Date
    Nov 2008
    Posts
    232

    Default

    In the case i mentioned ,I need to instantiate the class based upon some configuration using Class.forName (the configuration may change during rumtime). hence i cannot expose the instances as OSGi service Is their any way i can acheive the goal i m looking for

  7. #7
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    You mean you use Class.forName() in bundle A to instantiate a class which is configured in that bundle and which is (possibly) present in bundle B? In that case I would suggest to reconsider your approach as this appears quite fragile to me.

    Maybe you could define a service taking a class name and returning the class. That service could be registered by bundle B (and maybe others).

    Bundle A could then lookup all these services and check whether they may return the needed class object. That way you avoid cross-bundle classloading.
    However, the class object itself is maybe of little use. I guess you need an instance, right? If there is also a common interface then that could be used.

    Regards,
    Andreas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •