Search code examples
javaosgiaemosgi-bundle

AEM/CQ5 multiple bundles same package name and different data type attributes


I have almost similar question and it will be really appreciated if anyone can answers the below question?

  1. I have multiple AEM consumers (i.e AEM1, AEM2, AEM3)
  2. Also having external bundle with different symbolic name (i.e. Bundle A, Bundle B)
  3. The difference between these 2 bundles are attributes data type in same packages (i.e package: com.abc.xyz [same package name in both bundles], class: SampleObject, Bundle A’s attributes: int sampleAttrbute, Bundle B’s attributes: String sampleAttrbute)
  4. The AEM1 & AEM2, will consume(JSP & backend JAVA) the sampleAttrbute as integer and AEM3 will consume(JSP & backend JAVA) the sampleAttrbute as String.

Q: Is this possible in the AEM/CQ5 OSGI bundles approach? If yes then how?

Thank you!!!


Solution

  • The OSGI Felix implementation in AEM will select one of the bundles and will use that for the com.abc.xyz package. So even though it exists in two different bundles, both of which are installed, only one will be used at runtime. You can control which one by making whatever will consume the package be dependent on a specific version (make it import a specific version), then making your Bundle A and Bundle B have different version numbers so it can differentiate which one to use. See Multiple bundle versions deployed in one OSGi instance for details on how this is done.

    See also