Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

AEM OSGi Declarative Services Annotations

This project demonstrates the basics of using the OSGi Declarative Services annotations along side the more familiar Felix SCR annotations.

Examples are given for both annotation styles in each of a servlet, service, filter, scheduler and an event handler / listener. These five examples are common AEM project requirements and the examples can be extrapolated out for anything else such as MBeans, Adapters, Workflow Process Steps, Replication Preprocessors, etc...

Note the service example creates the Configuration as a separate class while the other examples create the Configuration as a subclass.

View the associated blog post at http://www.nateyolles.com/blog/2017/05/osgi-declarative-services-annotations-in-aem.

How to build

This project has been built and tested in AEM 6.2.

To build all the modules run in the project root directory the following command with Maven 3:

mvn clean install

Or to deploy the bundle to the author, run

mvn clean install -PautoInstallBundle

Test

Below are a some cURL commands to help you test the components. Navigate to the Felix Configuration console to update component properties.

Servlets and Services

Make a GET request to the servlets which consume the services and respond back with plain text:

curl -u admin:admin http://localhost:4502/bin/felix
curl -u admin:admin http://localhost:4502/bin/osgi

Event Handler

Create a new node under /content and watch the logs:

curl -u admin:admin http://localhost:4502/content/foo -F"myproperty=bar"

Scheduler

View the logs to see the scheduler running every 60 seconds by default.

Filters

Make a request to a resouce under /content and watch the logs:

curl -u admin:admin http://localhost:4502/content/geometrixx/en/products/triangle.html

Maven settings

The project comes with the auto-public repository configured. To setup the repository in your Maven settings, refer to:

http://helpx.adobe.com/experience-manager/kb/SetUpTheAdobeMavenRepository.html