Getting OSGi services from a bundle in Sling/CQ

By : joelt

I am using Day CQ. I want to store some data in a SQL Server DB, using the connection pool available in the Felix console. I can do this from a JSP, by using the "sling" object of type SlingScriptHelper defined in the defineObjects tag


However, I want to use a servlet created in an OSGi bundle to handle requests from the client. The servlet doesn't have a defineObjects tag, so the "sling" object is not defined. I don't see a way to create a valid SlingScriptHelper object in my servlet, but it seems like it has to be possible.

Is there a way?

By : joelt


YourClass obj = this.getSlingScriptHelper().getService(yourclass.class);


By : naga

This video can help you solving your question :)
By: admin