What is OSGi Configuration?
- In the Context of software development, Osgi stands for(Open Services Gateway Initiative).
- OSGi is a modular framework for building Java applications, allowing them to be dynamically composed of smaller, reusable components called bundles.
- When you want to give some input to your Bundle means your Java file like you give for the component you write Osgi Configuration.
- Basically Osgi Configuration Used in Run Modes.
How Osgi Configuration look like?
Osgi Configuration Fields
- In crxde (Content Repository Extreme Development Environment). All the OSGI configurations are stored under (/apps/sling/config or /apps/system/config) by default.
- Basically Osgi Configuration Used in Run Modes.
- for eg:
- If our requirement is in Dev environment we want different configuration, In Stage environment we want different configuration & In Production environment we want different configuration then we will use Osgi Configuration.
- First of all we write Interface for Osgi Service.
- for eg:
In this class we are used few Specific annotation let's discuss what are these annotation and why we will use?
- @Component annotation make services from a simple class.
- @ObjectClassDefinition(name = "", description = " ")
- @ObjectClassDefinition this is used to generate Osgi Configuration fields.
- for eg:
- @Designate annotation this is used to generate designate element in the meta type resource for an @ObjectClassDefinition.
- It means it will generate for this
- we have to create a inner Interface class inside that you have to use public @interface this syntax.
- Inside that there is
- @AttributeDefinition(name = "", description = "", type = AttributeType.STRING)
- Basically this @AttributeDefination annotation will be using on particular method and you pass some parameters this is used to generate your fields.
- you will be seeing here I used @AttributeDefinition which have name and than the description and then type.
- This Type is defined which kind of filled it is so, I define the STRING.
- It means the filled will be string type.
- Then I define a method this method will return whatever, the value this filled have and you can give default value.
- with the help of @Activate annotation method we can use.
- When you want to be load or executed at the time of this service initiation or to deploy this bundle you will write in activate.
In short,
1)We have a OSGI Configuration that is residing in the OSGI Service.
2)We are calling the OSGI Service from the Sling Model.
3)We are calling the Sling Model using from Sightly/HTL.
Please feel free to comment in case of any mistake I am also learning.
Thanks
Matri Sharma
No comments:
Post a Comment