Menu

metatype=true in AEM

Why we add parameter metatype=true in @Component annotation?


When we add parameter metatype=true then Apache felix generate a metatype.xml file for that component, if we don’t then there will no metaype.xml file.
Metatype.xml file contains an element <OCD> which have parameters name and description of the component. Under the <OCD> we have another ta <AD> which have detail information of property which we want to make visible and configurable on Apache felix console localhost:4502/system/console/configMgr.
So if we specified ten properties in our component then there will be ten <AD> elements under the <OCD>

Metatype.xml file also contains the element <Designate> with attribute PID and <Object> which has parameter OCDREF under the <Designate> element, which represent and store the configured values. Value for PID and OCDREF is always used to same and that is also the name of the file which you will find in the CRX.  

When we add metatype=true in the parameter of @component that means we have made the property of that component or service configurable and visible on Felix console, which is an easy and helpful way to configure properties of any component and service. Felix web console uses the meta type information to show user-friendly and easy the GUI configuration.

interface MetaTypeService helps to obtain the meta type information of any bundle and component. MetaType Service will examine the specified bundle for meta type documents to create the returned MetaTypeInformation object.
If the specified bundle does not contain any meta type documents, then a MetaTypeInformation object will be returned that wrappers any ManagedService or ManagedServiceFactory services registered by the specified bundle that implement MetaTypeProvider. Thus the MetaType Service can be used to retrieve meta type information for bundles which contain a meta-type document or which provide their own MetaTypeProvider objects.

Where I could find the metatype.xml file in my project? Or Where metatype.xml file exist?

[PROJECT NAME]\core\bin\target\classes\OSGI-INF\metatype

Example of a metafile.xml



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<?xml version="1.0" encoding="UTF-8"?><metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0" localization="OSGI-INF/metatype/com.rashid.jorvee.aem.services.MetaTypeExample">

    <OCD id="com.rashid.jorvee.aem.services.MetaTypeExample" name="%com.rashid.jorvee.aem.services.MetaTypeExample.name" description="%com.rashid.jorvee.aem.services.MetaTypeExample.description">

        <AD id="MetaType.userID" type="String" name="%com.rashid.jorvee.aem.services.MetaTypeExample.MetaType.userID.name" description="%com.rashid.jorvee.aem.services.MetaTypeExample.MetaType.userID.description"/>

        <AD id="MetaType.contact" type=" Integer " name="%com.rashid.jorvee.aem.services.MetaTypeExample.MetaType. contact.name" description="%com.rashid.jorvee.aem.services.MetaTypeExample.MetaType.contact.description"/>

        <AD id="MetaType.address" type="String" default="Boston, united States" name="%com.rashid.jorvee.aem.services.MetaTypeExample.MetaType.address.name" description="%com.rashid.jorvee.aem.services.MetaTypeExample.MetaType.address.description"/>

    </OCD>

    <Designate pid="com.rashid.jorvee.aem.services.MetaTypeExample">

        <Object ocdref="com.rashid.jorvee.aem.services.MetaTypeExample"/>

    </Designate>

</metatype:MetaData>

In the above example, we have created a service class MetaTypeExample which have following configurable properties.
  1. userID
  2. contact
  3. address


Marriage of Alauddin Khilji and Padmavati

Finally, the day comes when Alauddin Khilji married with Padmavati. On this pious day, Alauddin Khilji most powerful King of 13th century Delhi Sultanate won the heart of prince Padmini as known as Padmavati(queen of Mewar present day in Rajasthan) propose her and bound life-death relation with her, this ceremony also makes an India's biggest myth into reality.

Malik Muhham Jaisi, a poet who was not in the court of Alauddin Khilji, not even he was born in the era of Alauddin Khilji wrote an epic poetry "Padmavat" an imaginative story of a queen which was not based on any real story but Bollywood actor and actress embrace his story and helps him to make it true in the 21st century.

Bollywood actor and actress who played the role of Sultan Alauddin Khilji(Ranbir Singh) and Queen Padmavati(Deepika Padukon) in Movie Padmavaat(directed by Sanjay Leela Bhansali) happily get married on November 14th, 2018.

Reference:

Alauddin Khalji - A powerful king of Delhi Sultanate
Malik Muhammad Jayasi | known for his epic poetry Padmavati
Poem Padmavat- imagination of Malik Muhammad Jayasi
Movie Padmaavat - Directed by Sanjay Leela Bhansali

Tu Reh Naward-e-Shauq Hai, Manzil Na Kar Qabool

تو  رہ  نوارد-ا-شوق  ہے منزل  نہ کر قبول

لیلیٰ  بھی  ہم -نشین  ہو  تو  محمل  نہ  کر  قبول
Tu Reh Naward-e-Shauq Hai, Manzil Na Kar Qabool

Laila Bhi Hum-Nasheen Ho To Mehmil Na Kar Qabool
If you traverse the road of love, Donʹt yearn to seek repose or rest,

If Layla be your companion close that litter shun with great contempt.

اے جوے اب بڑھ کے ہو دریا-ا-تند-و-تیز

ساحل تجھے اتا ہو تو ساحل نہ کر قبول
Ae Jooye Aab Barh Ke Ho Darya-e-Tund-o-Taiz

Sahil Tujhe Atta Ho To Sahil Na Kar Qabool
O streamlet, onward flow and get transformed to torrent strong and deep,

If bank is eʹer on you bestowed, Abstain, flow on with mighty sweep.
کھویا  نہ  جا  صنم  کدہ-و-کائنات میں

محفل گداز گرمی-و-محفل نہ کر قابول
Khoya Na Ja Sanamkada-e-Kainat Mein
Mehfil Gudaz! Garmi-e-Mehfil Na Kar Qabool
Donʹt lose your bearings in this world because with idols it is full,

The assemblage here can cast a spell,disdain, or strings of heart shall pull.
صبح ازل یہ مجھ  سے کہا جبریل نے

جو عقل کا غلام ہو, وہ دل نہ کر قبول
Subah-e-Azal Ye Mujh Se Kaha Jibreel Ne

Jo Aqal Ka Ghulam Ho, Woh Dil Na Kar Qabool
Gabriel on Creationʹs Early Morn, a piece of useful counsel gave,

He bade me not accept a heart enchained by mind of man like slave.
باطل دوویی پسند ہے, حق لا-شریک ہے

شرکت میانہ حق-و-باطل نہ کر قبول

Batil Dooyi Pasand Hai, Haq La-Shareek Hai

Shirkat Mayana-e-Haq-o-Batil Na Kar Qabool
Untruth conceals in various masks but Truth and God are both unique,

There canʹt be pool ʹtwixt good and bad—This fact is known from times antique.