Monday, March 20, 2017

Run Modes with Use Cases In AEM 6.2 - Part2

Hi,

In the Run Modes -Part1, We have discussed about the purpose of Run Modes.

In this blog we will explore the purpose of Run Modes in detail:
  • OSGi Component Creation for a specific environment.
  • Bundle Creation for a specific environment.

OSGi Component Creation for a specific environment
Run Modes helps to create OSGi component for the specific environment.
Problem Statement: To make OSGi Component to be available only for publish instance.
Solution: To solve this problem, follow these two steps:
  • Annotate the component with “ConfigurationPolicy.REQUIRE
  • Make this configuration available under config.publish.

Sample code of OSGi Component


👉 Here “policy= ConfigurationPolicy.REQUIRE”  means that this component should be available as configuration created under config nodes. But Initially, this configuration will not exist  in felix console components
So, to make it visible in Felix console of publish instance, You need to create configuration of this component (using Pid of OSGi Component) under config.publish node.

component-config.jpg
Fig- Node name same as Pid of OSGi Component

After addition of this configuration, you can see, the component will be available in Felix console in publish instance.
Note: In other run modes, this component will not get executed because it is specified only for publish instance. If you want to use it in other run modes, you need to make it in other config as well. (eg: config.author,config.qa)


Bundle Creation for a specific environment

Run Modes is not only used for configurations, they can also be used to differentiate bundles based on the environments.
Isn’t it sounds interesting??
Problem Statement: Let Suppose, You have multiple bundles in a single project. like
Bundle A” for  “Author” Environment.
Bundle Bfor  “Publish” Environment
Solution: So we need to make environment specific configuration for install folder.
Install.author  (nt:folder)
                => Bundle A.jar
Install.publish (nt:folder)
                => Bundle B.jar
crx.PNG
Fig- sgaem-test.jar for author and sgaem-bundle.jar for publish instance

Note: If you are in publish instance, You will not able to see bundle "sgaem-test" in felix console and vice-Versa for author instance.

Note: Here the question arises that how to create multiple bundles in an AEM Maven project? So stay tuned for next upcoming blog to get the answer of above question 👍.

Kindly share your feedback and contact us at sgaem.blog02@gmail.com for any query.

Thanks and Happy Learning 😊



3 comments: