SlideShare a Scribd company logo
1 of 43
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 ProcessingCarsten Ziegeler
 
Understanding Sling Models in AEM
Understanding Sling Models in AEMUnderstanding Sling Models in AEM
Understanding Sling Models in AEMAccunity Software
 
Experience and Content Fragment
Experience and Content FragmentExperience and Content Fragment
Experience and Content FragmentHeena Madan
 
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 knowPrabhdeep Singh
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling ResolutionDEEPAK KHETAWAT
 
AEM Sightly Template Language
AEM Sightly Template LanguageAEM Sightly Template Language
AEM Sightly Template LanguageGabriel Walt
 
Integration patterns in AEM 6
Integration patterns in AEM 6Integration patterns in AEM 6
Integration patterns in AEM 6Yuval Ararat
 
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webappsMikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webappshacktivity
 
Heap Dump Analysis - AEM: Real World Issues
Heap Dump Analysis - AEM: Real World IssuesHeap Dump Analysis - AEM: Real World Issues
Heap Dump Analysis - AEM: Real World IssuesKanika Gera
 
AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentGabriel Walt
 
Sling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatSling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatAEM HUB
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep DiveGabriel Walt
 
Omnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the ThingsOmnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the ThingsJustin Edelson
 
AEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser CachingAEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser CachingAndrew Khoury
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAshokkumar T A
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Examplekamal kotecha
 
Adobe Experience Manager Core Components
Adobe Experience Manager Core ComponentsAdobe Experience Manager Core Components
Adobe Experience Manager Core ComponentsGabriel 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
 
Understanding Sling Models in AEM
Understanding Sling Models in AEMUnderstanding Sling Models in AEM
Understanding Sling Models in AEM
 
Experience and Content Fragment
Experience and Content FragmentExperience and Content Fragment
Experience and Content Fragment
 
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
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
 
Aem maintenance
Aem maintenanceAem maintenance
Aem maintenance
 
AEM Sightly Template Language
AEM Sightly Template LanguageAEM Sightly Template Language
AEM Sightly Template Language
 
slingmodels
slingmodelsslingmodels
slingmodels
 
Integration patterns in AEM 6
Integration patterns in AEM 6Integration patterns in AEM 6
Integration patterns in AEM 6
 
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webappsMikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
 
Heap Dump Analysis - AEM: Real World Issues
Heap Dump Analysis - AEM: Real World IssuesHeap Dump Analysis - AEM: Real World Issues
Heap Dump Analysis - AEM: Real World Issues
 
AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component Development
 
Sling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatSling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak Khetawat
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
 
Omnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the ThingsOmnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the Things
 
AEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser CachingAEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser Caching
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Example
 
React-JS.pptx
React-JS.pptxReact-JS.pptx
React-JS.pptx
 
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 developmentMartin Toshev
 
OSGi User Forum US DC Metro
OSGi User Forum US DC MetroOSGi User Forum US DC Metro
OSGi User Forum US DC MetropjhInovex
 
OSGi user forum dc metro v1
OSGi user forum dc metro v1OSGi user forum dc metro v1
OSGi user forum dc metro v1pjhInovex
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014scolestock
 
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.0David Bosschaert
 
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 IstanbulMert Ç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_frameworkHarshad 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_BlocksRahul Shukla
 
Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to SpringSujit Kumar
 
Kirill Rozin - Practical Wars for Automatization
Kirill Rozin - Practical Wars for AutomatizationKirill Rozin - Practical Wars for Automatization
Kirill Rozin - Practical Wars for AutomatizationSergey Arkhipov
 
SFDC Deployments
SFDC DeploymentsSFDC Deployments
SFDC DeploymentsSujit Kumar
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenMert Çalışkan
 
Talkbits service architecture and deployment
Talkbits service architecture and deploymentTalkbits service architecture and deployment
Talkbits service architecture and deploymentOpen-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
 

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 introduction
OSGi introductionOSGi introduction
OSGi introduction
 
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/)
 

Recently uploaded

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

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