SlideShare une entreprise Scribd logo
1  sur  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.

Contenu connexe

Tendances

Dynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEMDynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEMBojana Popovska
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 formsEyal Vardi
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling ResolutionDEEPAK KHETAWAT
 
Understanding Sling Models in AEM
Understanding Sling Models in AEMUnderstanding Sling Models in AEM
Understanding Sling Models in AEMAccunity Software
 
AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentGabriel Walt
 
Java 8-streams-collectors-patterns
Java 8-streams-collectors-patternsJava 8-streams-collectors-patterns
Java 8-streams-collectors-patternsJosé Paumard
 
JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?connectwebex
 
AWS 기반 대규모 트래픽 견디기 - 장준엽 (구로디지털 모임) :: AWS Community Day 2017
AWS 기반 대규모 트래픽 견디기 - 장준엽 (구로디지털 모임) :: AWS Community Day 2017AWS 기반 대규모 트래픽 견디기 - 장준엽 (구로디지털 모임) :: AWS Community Day 2017
AWS 기반 대규모 트래픽 견디기 - 장준엽 (구로디지털 모임) :: AWS Community Day 2017AWSKRUG - AWS한국사용자모임
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep DiveGabriel Walt
 
AEM Asset and Tag API
AEM Asset and Tag APIAEM Asset and Tag API
AEM Asset and Tag APILokesh BS
 
Experience and Content Fragment
Experience and Content FragmentExperience and Content Fragment
Experience and Content FragmentHeena Madan
 
Apache Sling : JCR, OSGi, Scripting and REST
Apache Sling : JCR, OSGi, Scripting and RESTApache Sling : JCR, OSGi, Scripting and REST
Apache Sling : JCR, OSGi, Scripting and RESTCarsten Ziegeler
 
From Monolithic to Microservices
From Monolithic to Microservices From Monolithic to Microservices
From Monolithic to Microservices Amazon Web Services
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_contentNAVEENSAGGAM1
 

Tendances (20)

Dynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEMDynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEM
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
Aem Training Tutorials for Beginners
Aem  Training Tutorials for BeginnersAem  Training Tutorials for Beginners
Aem Training Tutorials for Beginners
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
 
AEM - Client Libraries
AEM - Client LibrariesAEM - Client Libraries
AEM - Client Libraries
 
Understanding Sling Models in AEM
Understanding Sling Models in AEMUnderstanding Sling Models in AEM
Understanding Sling Models in AEM
 
AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component Development
 
Java 8-streams-collectors-patterns
Java 8-streams-collectors-patternsJava 8-streams-collectors-patterns
Java 8-streams-collectors-patterns
 
JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?
 
AWS 기반 대규모 트래픽 견디기 - 장준엽 (구로디지털 모임) :: AWS Community Day 2017
AWS 기반 대규모 트래픽 견디기 - 장준엽 (구로디지털 모임) :: AWS Community Day 2017AWS 기반 대규모 트래픽 견디기 - 장준엽 (구로디지털 모임) :: AWS Community Day 2017
AWS 기반 대규모 트래픽 견디기 - 장준엽 (구로디지털 모임) :: AWS Community Day 2017
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
 
AEM Asset and Tag API
AEM Asset and Tag APIAEM Asset and Tag API
AEM Asset and Tag API
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Experience and Content Fragment
Experience and Content FragmentExperience and Content Fragment
Experience and Content Fragment
 
Apache Sling : JCR, OSGi, Scripting and REST
Apache Sling : JCR, OSGi, Scripting and RESTApache Sling : JCR, OSGi, Scripting and REST
Apache Sling : JCR, OSGi, Scripting and REST
 
From Monolithic to Microservices
From Monolithic to Microservices From Monolithic to Microservices
From Monolithic to Microservices
 
Terraform
TerraformTerraform
Terraform
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_content
 
slingmodels
slingmodelsslingmodels
slingmodels
 

Similaire à 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
 

Similaire à 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/)
 

Dernier

Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandIES VE
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Paige Cruz
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideStefan Dietze
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfFIDO Alliance
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxFIDO Alliance
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!Memoori
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024Stephen Perrenod
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Skynet Technologies
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform EngineeringMarcus Vechiato
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 

Dernier (20)

Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 

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