Announcement Announcement Module
Collapse
No announcement yet.
resolution=optional Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • resolution=optional

    what is the use of ;resolution=optional

  • #2
    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

    Comment


    • #3
      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

      Comment


      • #4
        what do i do in such scenario .

        Comment


        • #5
          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

          Comment


          • #6
            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

            Comment


            • #7
              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

              Comment

              Working...
              X