This project will help you learn Kotlin programming language. You will find examples of common AEM developer tasks all written in both Java and Kotlin.
Local AEM author 6.5.8 instance running on http://localhost:4502
(*) Can be changed in instance.local-author.httpUrl
prop in gradle.user.properties
Put cq-quickstart-6.5.0.jar
, license.properties
, aem-service-pkg-6.5.8.zip
inside <project_root>/instance/
folder and run gradlew instanceUp
.
G.A.P. will create and start AEM author instance for you (this will take a few minutes).
Set true
on instance.local-publish.enabled
prop in gradle.user.properties
If you like to run it just type gradlew
from root folder or use provided package deploy
build for IntelliJ IDE
(*) Build is checking if org.apache.sling.api ver. 2.22.0
is available on the instance to ensure deployment on AEM 6.5.8
this can be disabled in build.gradle.kts
-
SimpleService
Java | Kotlin
OSGi@Component
andService
(all in one class) with (static final field
in Java /companion object
- in Kotlin). -
SimpleServlet
Java | Kotlin
OSGi@Component
andSling Servlet
withdependency injection
to another service.
You can test both servlets on:
http://localhost:4502/bin/java/hello
http://localhost:4502/bin/kotlin/hello
-
ConfigurableService
Java | Kotlin
Serviceinterface
definition. -
ConfigurableServiceImpl
Java | Kotlin
OSGi component that can be configured inAdobe Experience Manager Web Console Configuration
.
Use of@ObjectClassDefinition
,@AttributeDefinition
and service implementation.
Compare how to transformArray
toMap
withStream API
in Java andClosures
in Kotlin. -
ComponentDecoratorFilter
Java | Kotlin
OSGi component and basic implementation ofjavax.servlet.Filter
-
ComponentDecoratorProcessor
Java | Kotlin
Class used by ComponentDecoratorFilter to replace markup text with some other text. Compare howfinal fields
are defined,casting
.
Meetelvis operator
andfields definition directly in constructor
when writing in Kotlin. -
SampleModel
Java | Kotlin
SimpleSling Model
with property and serviceinjection
. Learn how to inject primitive types in Kotlin. -
Sample Component
path
Sample Component with Touch UI config dialog. Add selectorjava
orkotlin
and switch fromJSP
toHTL
with different model implementations. Links: Java | Kotlin
- 6.5.8 - Project recreated for the newer GAP | migrated to AEM 6.5.8
- 1.0.1 - GAP and Gradle updated | build scripts migrated to Kotlin DSL | AEM 6.3
- 1.0.0 - Initial version from 2018 | build scripts in Groovy DSL | AEM 6.3