SlideShare a Scribd company logo
OSGI
What is OSGI
STANDS FOR “OPEN
SERVICE GATEWAY
INITIATIVE”.
JAVA FRAMEWORK FOR
THE DEVELOPMENT AND
DEPLOYMENT OF
MODULAR SOFTWARE
PROGRAMS AND LIBRARIES
BY BREAKING THE
APPLICATION INTO
INDIVIDUAL MODULES
CALLED BUNDLES SO THAT
THESE BUNDLES CAN BE
INDEPENDENTLY STARTED
AND STOPPED.
ITS CORE SPECIFICATION
DEFINES A COMPONENT
AND SERVICE MODEL FOR
JAVA.
THE COMPONENTS AND
SERVICES CAN BE
DYNAMICALLY INSTALLED,
ACTIVATED, DE-ACTIVATED,
UPDATED AND
UNINSTALLED.
OSGI SPECIFICATION HAS
SEVERAL
IMPLEMENTATIONS:
ECLIPSE EQUINOX,
KNOPFLERFISH OSGI OR
APACHE FELIX.
AEM USES APACHE FELIX.
“is the dynamic module system for Java™.”
comes under the classification Universal Middleware.
“provides the standardized primitives that allow applications to be constructed from small, reusable and collaborative components.
These components can be composed into an application and deployed.”
OSGi bundles can contain compiled Java code, scripts, content that is to be loaded in the repository, and configuration or additional
files, as needed.
allows the bundles to be loaded, and installed, during normal operations. In the case of CQ5, this is managed by the Sling
Management Console.
OSGI
OSGi has a
layered
model:
• Bundles – Bundles are normal jar components with extra manifest headers.
• Services – The service layer, which hold the service-side of the framework, keeps the service
registry and manages it
• Life-Cycle – The lifecycle layer manages and keeps track of the frameworks and bundles lifecycle
state. It is used to install or uninstall framework objects and start or stop them.
• Modules – The module layer, which is the bundle space, holds the bundles that are installed on
the framework and are managed through the lifecycle layer.
• Security – The security layer, which extends the jave 2 security architecture, is optional. When
active, it validate the bundle signatures and controls the component access rights
• Execution Environment – The execution environment layer, which is the bottom layer on which
the bundles live, is selected to fit the underlying hardware or operating system.
Bundle in AEM
Classes + Jars + configuration Files + Manifest headers
Bundle(jar)
A bundle is essentially a Jar
file.
You deploy in the Apache
Felix console.
Felix console is the OSGi
container. To make it
simpler, to accomplish a
complex task, you can
deploy a bundle in Felix
console that runs
with AEM, and then avail
the services offered by
the bundle.
Where we can see OSGI
bundle in crx?
• login to <host>:<port>/crx/de/index.jsp
• Click apps
• Go to your project, In my case it is wknd(refer
screenshot)
• Click install
• OSGI bundle is
• /apps/wknd/install/aem-guides-wknd.core-
0.0.3-SNAPSHOT.jar
OSGI bundle in web console
• login to <host>:<port>/crx/de/index.jsp for eg:
http://localhost:4502/crx/de/index.jsp
• Go to Web console: <host>:<port>/system/console/bundles for eg:
http://localhost:4502/system/console/bundles
Find your project name:
Bundles
• A bundle must have a unique identity,
a long, chosen by the Framework.
• This identity must not change during
the lifecycle of a bundle, even when
the bundle is updated.
• Uninstalling and then reinstalling the
bundle must create a new unique
identity.
Modules
Modularity is at the core of the
OSGi specifications and
embodied in the bundleconcept.
In Java terms, a bundle is a plain
old JAR file.
OSGi hides everything in that
JAR
Package vs Bundle
Package
• A Package is a zip file that
contains the content in the form
of a file-system serialization
(called “vault” serialization) that
displays the content from the
repository as an easy-to-use-
and-edit representation of files
and folders. Packages can
include content and project-
related data.
Bundle
• Bundle is a tightly coupled,
dynamically loadable collection
of classes, jars, and
configuration files that explicitly
declare their external
dependencies (if any).
OSGI Lifecycle:
Lifecycle states
• INSTALLED
• RESOLVED
• UNINSTALLED
• STOPPING
• ACTIVE
• STARTING
OSGI Lifecycle ctd..
INSTALLED: The OSGi runtime knows
the bundle is there.
RESOLVED: The bundle is there and all
it’s prerequisites (dependencies) are
available. The bundle can be started
(or has been stopped).
STARTING: The bundle is being
started. If it has a BundleActivator
class, the BundleActivator.start()
method is being executed. When
done, the bundle will become
ACTIVE. Note: Bundles that can be
activated lazily (Bundle-
ActivationPolicy: lazy) stay in this
state until one of their class files is
loaded.
ACTIVE: The bundle is running.
STOPPING: The bundle is being
stopped. If it has a BundleActivator
class, the BundleActivator.stop()
method is being executed. When
done, the bundle will become
RESOLVED
UNINSTALLED: The bundle has been
removed from the OSGi runtime.
Services
• We need the service model is because Java shows how hard it
is to write collaborative model with only class sharing.
• OSGi service registry. A bundle can create an object and
register it with the OSGi service registry under one or more
interfaces. Other bundles can go to the registry and list all
objects that are registered under a specific interfaces or class.
Basic SCR
Annotation used
for developing a
component or
service in osgi
are:-
@COMPONENT – DEFINES THE
CLASS AS A COMPONENT.
@SERVICE – DEFINES THE
SERVICE INTERFACE THAT IS
PROVIDED BY THE COMPONENT.
@REFERENCE – INJECTS A
SERVICE INTO THE COMPONENT.
@PROPERTY – DEFINES A
PROPERTY THAT CAN BE USED IN
THE CLASS.
@component
• The @Component annotation is the only
required annotation. If this annotation is not
declared for a Java class, the class is not
declared as a component.
• For eg:@Component(
service = Servlet.class,
property = {
"sling.servlet.extensions=html",
"sling.servlet.selectors=training",
"sling.servlet.paths=/bin/trainingservlet",
"sling.servlet.paths=/bin/trainingservlet2",
"sling.servlet.methods=get",
"sling.servlet.resourceTypes=my-aem-project/components/page/page"
}
)
@Reference
The @Reference annotation defines references
to other services made available to the
component by the Service Component Runtime.
• This annotation may be declared on a Class
level or any Java field to which it might apply.
Depending on where the annotation is
declared, the parameters may have different
default values.
Sling servlets in OSGI- AEM 6.3+
Declarative Services
Component annotation
• Declarative services is a compile time process.
• Annotations:
• @Designate(ocd=“T.class”)
• @ObjectClassDefinition
• @AttributeDefinition
@Designate
• Generate a Designate element in the Meta
Type Resource for an
ObjectClassDefinition(ocd) using the annotated
Declarative Services component.
• This annotation must be used on a type that is
also annotated with the Declarative Services
Component annotation. The component must
only have a single PID which is used for the
generated Designate element.
@Component(
immediate = true,
service = Servlet.class,
property = {
"sling.servlet.resourceTypes=project/components/component"
}
)
@Designate(ocd = SampleOsgiServlet.Configuration.class)
public class SampleOsgiServlet extends SlingSafeMethodsServlet {
@Activate
protected void Activate(Configuration config) {
boolean enabled = config.servletname_enabled();
}
@ObjectClassDefinition(name="OSGi Annotation Demo Servlet")
public @interface Configuration {
@AttributeDefinition(
name = "Enable",
description = "Enable the servlet"
)
boolean servletname_enabled() default false;
}
}
OSGI
BASICS
• OSGI is a modular programming approach. Application
can be divided into modules or bundles. Bundle will be
JAR file + Metadata.
• OSGI uses Apache Felix Implementation.
• All Bundles are deployed on Felix container.
• Every bundle has its own life cycle. i.e., it’s
independent. Can be redeploy without affecting other
bundle.
• Each Bundle has its own class loader. Which allows
developers to start and stop each bundle separately.
• OSGI supports multiple version of bundle.
• AEM works with the inbuilt bundles for separate
functionalities.
• Bundles are stored under crx-quickstart/launchpad/felix.
OSGi Configuration with the Web Console
• Go to web console:
• http://localhost:4502/system/cons
ole/bundles
• Under OSGI-> Click Configuration
OR
Directly go to url:
http://localhost:4502/system/consol
e/configMgr
Basic SCR Annotation
used for developing a
component or service
in osgi are:-
• @Component – defines the class as a
component.
• @Service – defines the service interface that is
provided by the component.
• @Reference – injects a service into the
component.
• @Property – defines a property that can be
used in the class.
OSGI DI
• A of Bundle A has
dependency on Class B & C of
Bundle B & C , Now OSGI will
export Class B & Class C and
import them into Bundle A to
resolve dependency.
Run Modes
for example
author Publish Test Development
Production etc.
Run modes allow you to tune your AEM instance for a
specific purpose.
Starting CQ with a
specific run mode
There are many ways to set run modes of AEM instances:
1) Using the sling.properties file.
• The sling.properties file can be used to define the
required run mode:
• Edit the configuration file:
• <cq-installation-dir>/crx-
quickstart/conf/sling.properties
• Add the following properties; the following example is
for author:
sling.run.modes=author
Using jar file
• The jar file must use the naming convention:
cq5-<run-mode>-p<port-number>
• For example, set the publish run mode by naming the jar file:
cq5-publish-p4503
It sets as publish run mode
•
Using the -r option
• A custom run mode can be activated by using
the -r option when launching the quickstart.
• Use below command to start your Aem
instance with “author” as run mode
java -jar cq-56-p4502.jar -r author
Defining configuration
properties for a run
mode
• A collection of values for configuration properties,
used for a particular run mode, can be saved in the
repository.
• The run mode is indicated by a suffix on the folder
name.
For example:
• Config - Applicable for all run modes
• config.author - Used for author run mode
• config.publish - Used for publish run mode
Configuring
OSGi
By
Configuring
files:
To update a
configuration with
the web console:
• Access the Configuration tab of the Web
Console.
• Go to
http://localhost:4502/system/console/bundles
• Click Osgi -> Configuration
Or directly go to
http://localhost:4502/system/console/configMgr
• Select the bundle that you want to configure.
Open configuration
edit value-> click save
Ways to Create
AEM projects
• 1) Normal way
• create maven/gradle project.
• Inside that parent project create
modules
• Add dependencies in pom.xml(in
maven case)
• 2) Using Eclipse Plugin.
Installing AEM
Eclipse Plugin
• 1. Goto Help, Install New Software.…
2. Click Add and
enter http://eclipse.adobe.com/aem/dev-
tools/ in Location and click OK.
Project
Creation in
Eclipse:
• Creating a new project
• You can create a new project by performing
these steps:
• 1. Open the Eclipse IDE.
• 2. Switch to the AEM perspective, to have the
panels arranged in a convenient way: Menu
Window –> Open Perspective –> Other… –>
AEM –> OK.
• 3. Click on the new project icon.
• 4. Select AEM –> AEM Sample Multi-Module
Project.
• 5. Select version 10 of the Maven Archetype,
which is a blueprint used for the project that is
going to be created.
Steps for
creating an
OSGI Bundle in
AEM:-
• Run the below Maven command:
mvn archetype:generate -
DarchetypeRepository=http://repo.adobe.com/n
exus/content/groups/public/ -
DarchetypeGroupId=com.day.jcr.vault -
DarchetypeArtifactId=multimodule-content-
package-archetype -DarchetypeVersion=1.0.2 -
DgroupId=com.aem -
DartifactId=MyFirstOSGIBundle -Dversion=1.0-
SNAPSHOT -Dpackage=com.aem -
DappsFolderName=aemcq5tutorials -
DartifactName="MY First OSGI Service" -
DcqVersion=“5.6.1" -DpackageGroup="Aem Cq5
Tutorials“
Follow #39,40
When prompted for confirmation, Specify Y.
• Then go to project directory and run:
mvn eclipse:eclipse
Benefits Of OSGI
Reduced Complexity Reuse Real World – The
OSGi framework is
dynamic.
Easy Deployment Dynamic Updates Versioning
Fast Secure
DEMO
References
• https://docs.osgi.org/javadoc/r6/cmpn/org
/osgi/service/metatype/annotations/Desig
nate.html
• https://docs.adobe.com/content/help/en/
experience-manager-
65/deploying/configuring/configure-
runmodes.html
• http://www.aemcq5tutorials.com/tutorials
/create-osgi-bundle-in-aem/
• Note: Follow adobe documents for AEM
relevant stuff.

More Related Content

What's hot

Adobe AEM - From Eventing to Job Processing
Adobe AEM - From Eventing to Job ProcessingAdobe AEM - From Eventing to Job Processing
Adobe AEM - From Eventing to Job Processing
Carsten Ziegeler
 
Experience and Content Fragment
Experience and Content FragmentExperience and Content Fragment
Experience and Content Fragment
Heena Madan
 
Sightly - Part 2
Sightly - Part 2Sightly - Part 2
Sightly - Part 2
Prabhdeep Singh
 
webpack 101 slides
webpack 101 slideswebpack 101 slides
webpack 101 slides
mattysmith
 
Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson
AEM HUB
 
Sharing Data Between Angular Components
Sharing Data Between Angular ComponentsSharing Data Between Angular Components
Sharing Data Between Angular Components
Squash Apps Pvt Ltd
 
CSS Selectors
CSS SelectorsCSS Selectors
CSS Selectors
Rachel Andrew
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
Ashokkumar T A
 
인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017
인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017
인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017
Amazon Web Services Korea
 
Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2
Knoldus Inc.
 
AWS EBS
AWS EBSAWS EBS
AWS EBS
Mahesh Raj
 
AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component Development
Gabriel Walt
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
Rohit Gupta
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JS
Cakra Danu Sedayu
 
NEXT.JS
NEXT.JSNEXT.JS
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)
iFour Technolab Pvt. Ltd.
 
An Intro into webpack
An Intro into webpackAn Intro into webpack
An Intro into webpack
Squash Apps Pvt Ltd
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to know
Prabhdeep Singh
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
akhilsreyas
 
Adobe Experience Manager Core Components
Adobe Experience Manager Core ComponentsAdobe Experience Manager Core Components
Adobe Experience Manager Core Components
Gabriel Walt
 

What's hot (20)

Adobe AEM - From Eventing to Job Processing
Adobe AEM - From Eventing to Job ProcessingAdobe AEM - From Eventing to Job Processing
Adobe AEM - From Eventing to Job Processing
 
Experience and Content Fragment
Experience and Content FragmentExperience and Content Fragment
Experience and Content Fragment
 
Sightly - Part 2
Sightly - Part 2Sightly - Part 2
Sightly - Part 2
 
webpack 101 slides
webpack 101 slideswebpack 101 slides
webpack 101 slides
 
Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson
 
Sharing Data Between Angular Components
Sharing Data Between Angular ComponentsSharing Data Between Angular Components
Sharing Data Between Angular Components
 
CSS Selectors
CSS SelectorsCSS Selectors
CSS Selectors
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
 
인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017
인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017
인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017
 
Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2
 
AWS EBS
AWS EBSAWS EBS
AWS EBS
 
AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component Development
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JS
 
NEXT.JS
NEXT.JSNEXT.JS
NEXT.JS
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)
 
An Intro into webpack
An Intro into webpackAn Intro into webpack
An Intro into webpack
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to know
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
 
Adobe Experience Manager Core Components
Adobe Experience Manager Core ComponentsAdobe Experience Manager Core Components
Adobe Experience Manager Core Components
 

Similar to Osgi

Eclipse plug in development
Eclipse plug in developmentEclipse plug in development
Eclipse plug in development
Martin Toshev
 
OSGi & Blueprint
OSGi & BlueprintOSGi & Blueprint
OSGi & Blueprint
Kara Satish Kumar
 
OSGi User Forum US DC Metro
OSGi User Forum US DC MetroOSGi User Forum US DC Metro
OSGi User Forum US DC Metro
pjhInovex
 
OSGi user forum dc metro v1
OSGi user forum dc metro v1OSGi user forum dc metro v1
OSGi user forum dc metro v1
pjhInovex
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014
scolestock
 
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...
IndicThreads
 
What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0
David Bosschaert
 
Liferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for DevelopersLiferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for Developers
Azilen Technologies Pvt. Ltd.
 
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OpenBlend society
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
Mert Çalışkan
 
How to use_cucumber_rest-assured_api_framework
How to use_cucumber_rest-assured_api_frameworkHow to use_cucumber_rest-assured_api_framework
How to use_cucumber_rest-assured_api_framework
Harshad Ingle
 
Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development
Pei-Hsuan Hsieh
 
Eclipse_Building_Blocks
Eclipse_Building_BlocksEclipse_Building_Blocks
Eclipse_Building_Blocks
Rahul Shukla
 
Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to Spring
Sujit Kumar
 
Kirill Rozin - Practical Wars for Automatization
Kirill Rozin - Practical Wars for AutomatizationKirill Rozin - Practical Wars for Automatization
Kirill Rozin - Practical Wars for Automatization
Sergey Arkhipov
 
SFDC Deployments
SFDC DeploymentsSFDC Deployments
SFDC Deployments
Sujit Kumar
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
Mert Çalışkan
 
Talkbits service architecture and deployment
Talkbits service architecture and deploymentTalkbits service architecture and deployment
Talkbits service architecture and deployment
Open-IT
 
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Martin Toshev
 
Introduction to OSGi - Part-1
Introduction to OSGi - Part-1Introduction to OSGi - Part-1
Introduction to OSGi - Part-1
kshanth2101
 

Similar to Osgi (20)

Eclipse plug in development
Eclipse plug in developmentEclipse plug in development
Eclipse plug in development
 
OSGi & Blueprint
OSGi & BlueprintOSGi & Blueprint
OSGi & Blueprint
 
OSGi User Forum US DC Metro
OSGi User Forum US DC MetroOSGi User Forum US DC Metro
OSGi User Forum US DC Metro
 
OSGi user forum dc metro v1
OSGi user forum dc metro v1OSGi user forum dc metro v1
OSGi user forum dc metro v1
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014
 
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...
 
What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0
 
Liferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for DevelopersLiferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for Developers
 
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
How to use_cucumber_rest-assured_api_framework
How to use_cucumber_rest-assured_api_frameworkHow to use_cucumber_rest-assured_api_framework
How to use_cucumber_rest-assured_api_framework
 
Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development
 
Eclipse_Building_Blocks
Eclipse_Building_BlocksEclipse_Building_Blocks
Eclipse_Building_Blocks
 
Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to Spring
 
Kirill Rozin - Practical Wars for Automatization
Kirill Rozin - Practical Wars for AutomatizationKirill Rozin - Practical Wars for Automatization
Kirill Rozin - Practical Wars for Automatization
 
SFDC Deployments
SFDC DeploymentsSFDC Deployments
SFDC Deployments
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
 
Talkbits service architecture and deployment
Talkbits service architecture and deploymentTalkbits service architecture and deployment
Talkbits service architecture and deployment
 
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
 
Introduction to OSGi - Part-1
Introduction to OSGi - Part-1Introduction to OSGi - Part-1
Introduction to OSGi - Part-1
 

Recently uploaded

GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
alexjohnson7307
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
Data Hops
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 

Recently uploaded (20)

GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 

Osgi

  • 2. What is OSGI STANDS FOR “OPEN SERVICE GATEWAY INITIATIVE”. JAVA FRAMEWORK FOR THE DEVELOPMENT AND DEPLOYMENT OF MODULAR SOFTWARE PROGRAMS AND LIBRARIES BY BREAKING THE APPLICATION INTO INDIVIDUAL MODULES CALLED BUNDLES SO THAT THESE BUNDLES CAN BE INDEPENDENTLY STARTED AND STOPPED. ITS CORE SPECIFICATION DEFINES A COMPONENT AND SERVICE MODEL FOR JAVA. THE COMPONENTS AND SERVICES CAN BE DYNAMICALLY INSTALLED, ACTIVATED, DE-ACTIVATED, UPDATED AND UNINSTALLED. OSGI SPECIFICATION HAS SEVERAL IMPLEMENTATIONS: ECLIPSE EQUINOX, KNOPFLERFISH OSGI OR APACHE FELIX. AEM USES APACHE FELIX.
  • 3. “is the dynamic module system for Java™.” comes under the classification Universal Middleware. “provides the standardized primitives that allow applications to be constructed from small, reusable and collaborative components. These components can be composed into an application and deployed.” OSGi bundles can contain compiled Java code, scripts, content that is to be loaded in the repository, and configuration or additional files, as needed. allows the bundles to be loaded, and installed, during normal operations. In the case of CQ5, this is managed by the Sling Management Console.
  • 5. OSGi has a layered model: • Bundles – Bundles are normal jar components with extra manifest headers. • Services – The service layer, which hold the service-side of the framework, keeps the service registry and manages it • Life-Cycle – The lifecycle layer manages and keeps track of the frameworks and bundles lifecycle state. It is used to install or uninstall framework objects and start or stop them. • Modules – The module layer, which is the bundle space, holds the bundles that are installed on the framework and are managed through the lifecycle layer. • Security – The security layer, which extends the jave 2 security architecture, is optional. When active, it validate the bundle signatures and controls the component access rights • Execution Environment – The execution environment layer, which is the bottom layer on which the bundles live, is selected to fit the underlying hardware or operating system.
  • 6. Bundle in AEM Classes + Jars + configuration Files + Manifest headers Bundle(jar) A bundle is essentially a Jar file. You deploy in the Apache Felix console. Felix console is the OSGi container. To make it simpler, to accomplish a complex task, you can deploy a bundle in Felix console that runs with AEM, and then avail the services offered by the bundle.
  • 7. Where we can see OSGI bundle in crx? • login to <host>:<port>/crx/de/index.jsp • Click apps • Go to your project, In my case it is wknd(refer screenshot) • Click install • OSGI bundle is • /apps/wknd/install/aem-guides-wknd.core- 0.0.3-SNAPSHOT.jar
  • 8. OSGI bundle in web console • login to <host>:<port>/crx/de/index.jsp for eg: http://localhost:4502/crx/de/index.jsp • Go to Web console: <host>:<port>/system/console/bundles for eg: http://localhost:4502/system/console/bundles Find your project name:
  • 9. Bundles • A bundle must have a unique identity, a long, chosen by the Framework. • This identity must not change during the lifecycle of a bundle, even when the bundle is updated. • Uninstalling and then reinstalling the bundle must create a new unique identity.
  • 10. Modules Modularity is at the core of the OSGi specifications and embodied in the bundleconcept. In Java terms, a bundle is a plain old JAR file. OSGi hides everything in that JAR
  • 11. Package vs Bundle Package • A Package is a zip file that contains the content in the form of a file-system serialization (called “vault” serialization) that displays the content from the repository as an easy-to-use- and-edit representation of files and folders. Packages can include content and project- related data. Bundle • Bundle is a tightly coupled, dynamically loadable collection of classes, jars, and configuration files that explicitly declare their external dependencies (if any).
  • 12. OSGI Lifecycle: Lifecycle states • INSTALLED • RESOLVED • UNINSTALLED • STOPPING • ACTIVE • STARTING
  • 13. OSGI Lifecycle ctd.. INSTALLED: The OSGi runtime knows the bundle is there. RESOLVED: The bundle is there and all it’s prerequisites (dependencies) are available. The bundle can be started (or has been stopped). STARTING: The bundle is being started. If it has a BundleActivator class, the BundleActivator.start() method is being executed. When done, the bundle will become ACTIVE. Note: Bundles that can be activated lazily (Bundle- ActivationPolicy: lazy) stay in this state until one of their class files is loaded. ACTIVE: The bundle is running. STOPPING: The bundle is being stopped. If it has a BundleActivator class, the BundleActivator.stop() method is being executed. When done, the bundle will become RESOLVED UNINSTALLED: The bundle has been removed from the OSGi runtime.
  • 14. Services • We need the service model is because Java shows how hard it is to write collaborative model with only class sharing. • OSGi service registry. A bundle can create an object and register it with the OSGi service registry under one or more interfaces. Other bundles can go to the registry and list all objects that are registered under a specific interfaces or class.
  • 15. Basic SCR Annotation used for developing a component or service in osgi are:- @COMPONENT – DEFINES THE CLASS AS A COMPONENT. @SERVICE – DEFINES THE SERVICE INTERFACE THAT IS PROVIDED BY THE COMPONENT. @REFERENCE – INJECTS A SERVICE INTO THE COMPONENT. @PROPERTY – DEFINES A PROPERTY THAT CAN BE USED IN THE CLASS.
  • 16. @component • The @Component annotation is the only required annotation. If this annotation is not declared for a Java class, the class is not declared as a component. • For eg:@Component( service = Servlet.class, property = { "sling.servlet.extensions=html", "sling.servlet.selectors=training", "sling.servlet.paths=/bin/trainingservlet", "sling.servlet.paths=/bin/trainingservlet2", "sling.servlet.methods=get", "sling.servlet.resourceTypes=my-aem-project/components/page/page" } )
  • 17. @Reference The @Reference annotation defines references to other services made available to the component by the Service Component Runtime. • This annotation may be declared on a Class level or any Java field to which it might apply. Depending on where the annotation is declared, the parameters may have different default values.
  • 18. Sling servlets in OSGI- AEM 6.3+
  • 19. Declarative Services Component annotation • Declarative services is a compile time process. • Annotations: • @Designate(ocd=“T.class”) • @ObjectClassDefinition • @AttributeDefinition
  • 20. @Designate • Generate a Designate element in the Meta Type Resource for an ObjectClassDefinition(ocd) using the annotated Declarative Services component. • This annotation must be used on a type that is also annotated with the Declarative Services Component annotation. The component must only have a single PID which is used for the generated Designate element.
  • 21. @Component( immediate = true, service = Servlet.class, property = { "sling.servlet.resourceTypes=project/components/component" } ) @Designate(ocd = SampleOsgiServlet.Configuration.class) public class SampleOsgiServlet extends SlingSafeMethodsServlet { @Activate protected void Activate(Configuration config) { boolean enabled = config.servletname_enabled(); } @ObjectClassDefinition(name="OSGi Annotation Demo Servlet") public @interface Configuration { @AttributeDefinition( name = "Enable", description = "Enable the servlet" ) boolean servletname_enabled() default false; } }
  • 22. OSGI BASICS • OSGI is a modular programming approach. Application can be divided into modules or bundles. Bundle will be JAR file + Metadata. • OSGI uses Apache Felix Implementation. • All Bundles are deployed on Felix container. • Every bundle has its own life cycle. i.e., it’s independent. Can be redeploy without affecting other bundle. • Each Bundle has its own class loader. Which allows developers to start and stop each bundle separately. • OSGI supports multiple version of bundle. • AEM works with the inbuilt bundles for separate functionalities.
  • 23. • Bundles are stored under crx-quickstart/launchpad/felix.
  • 24. OSGi Configuration with the Web Console • Go to web console: • http://localhost:4502/system/cons ole/bundles • Under OSGI-> Click Configuration OR Directly go to url: http://localhost:4502/system/consol e/configMgr
  • 25. Basic SCR Annotation used for developing a component or service in osgi are:- • @Component – defines the class as a component. • @Service – defines the service interface that is provided by the component. • @Reference – injects a service into the component. • @Property – defines a property that can be used in the class.
  • 26. OSGI DI • A of Bundle A has dependency on Class B & C of Bundle B & C , Now OSGI will export Class B & Class C and import them into Bundle A to resolve dependency.
  • 27. Run Modes for example author Publish Test Development Production etc. Run modes allow you to tune your AEM instance for a specific purpose.
  • 28. Starting CQ with a specific run mode There are many ways to set run modes of AEM instances: 1) Using the sling.properties file. • The sling.properties file can be used to define the required run mode: • Edit the configuration file: • <cq-installation-dir>/crx- quickstart/conf/sling.properties • Add the following properties; the following example is for author: sling.run.modes=author
  • 29. Using jar file • The jar file must use the naming convention: cq5-<run-mode>-p<port-number> • For example, set the publish run mode by naming the jar file: cq5-publish-p4503 It sets as publish run mode •
  • 30. Using the -r option • A custom run mode can be activated by using the -r option when launching the quickstart. • Use below command to start your Aem instance with “author” as run mode java -jar cq-56-p4502.jar -r author
  • 31. Defining configuration properties for a run mode • A collection of values for configuration properties, used for a particular run mode, can be saved in the repository. • The run mode is indicated by a suffix on the folder name. For example: • Config - Applicable for all run modes • config.author - Used for author run mode • config.publish - Used for publish run mode
  • 33. To update a configuration with the web console: • Access the Configuration tab of the Web Console. • Go to http://localhost:4502/system/console/bundles • Click Osgi -> Configuration Or directly go to http://localhost:4502/system/console/configMgr • Select the bundle that you want to configure. Open configuration edit value-> click save
  • 34.
  • 35. Ways to Create AEM projects • 1) Normal way • create maven/gradle project. • Inside that parent project create modules • Add dependencies in pom.xml(in maven case) • 2) Using Eclipse Plugin.
  • 36. Installing AEM Eclipse Plugin • 1. Goto Help, Install New Software.… 2. Click Add and enter http://eclipse.adobe.com/aem/dev- tools/ in Location and click OK.
  • 37. Project Creation in Eclipse: • Creating a new project • You can create a new project by performing these steps: • 1. Open the Eclipse IDE. • 2. Switch to the AEM perspective, to have the panels arranged in a convenient way: Menu Window –> Open Perspective –> Other… –> AEM –> OK. • 3. Click on the new project icon. • 4. Select AEM –> AEM Sample Multi-Module Project. • 5. Select version 10 of the Maven Archetype, which is a blueprint used for the project that is going to be created.
  • 38. Steps for creating an OSGI Bundle in AEM:- • Run the below Maven command: mvn archetype:generate - DarchetypeRepository=http://repo.adobe.com/n exus/content/groups/public/ - DarchetypeGroupId=com.day.jcr.vault - DarchetypeArtifactId=multimodule-content- package-archetype -DarchetypeVersion=1.0.2 - DgroupId=com.aem - DartifactId=MyFirstOSGIBundle -Dversion=1.0- SNAPSHOT -Dpackage=com.aem - DappsFolderName=aemcq5tutorials - DartifactName="MY First OSGI Service" - DcqVersion=“5.6.1" -DpackageGroup="Aem Cq5 Tutorials“ Follow #39,40
  • 39. When prompted for confirmation, Specify Y.
  • 40. • Then go to project directory and run: mvn eclipse:eclipse
  • 41. Benefits Of OSGI Reduced Complexity Reuse Real World – The OSGi framework is dynamic. Easy Deployment Dynamic Updates Versioning Fast Secure
  • 42. DEMO