Below are the two easiest ways to get Service:
1. Using the slingScriptHelper
<sling:defineObjects />
<%
ServiceType service = sling.getService(ServiceType.class);
%>
2. Using adaptTo()
adaptTo() method that will translate the object to the class type being passed as the argument.
Example:
Node node = resource.adaptTo(Node.
class
);
More Info on Adaptors: http://dev.day.com/docs/en/cq/current/developing/sling-adapters.html
No comments:
Post a Comment