the ConfigurationBuilder.as(<Class>) method should never return null.
(this is also documented in the javadoc and it has a @NonNull annotation).

are you sure that the "as" method returns null in your case?

in the few code lines you posted i do not see an error.

stefan

>-----Original Message-----
>From: jmanuelbr [mailto:[email protected]]
>Sent: Tuesday, October 10, 2017 5:40 PM
>To: [email protected]
>Subject: Servlet Aware Configurations
>
>I was wondering if it would make sense to implement this feature since in
>my
>case that would have saved some time.
>
>I tried the following:
>
>SlingServlet set as follows:
>
>@SlingServlet(
>           resourceTypes = "myproject/components/structure/page",
>           selectors = "form",
>           extensions = "html",
>           methods = "GET")
>
>when getting the SlingHttpServletRequest in the doGet() method I can obtain
>the resource by just calling request.getResource(), although that resource
>is not something that Sling can recognise to apply the right configuration,
>in fact this:
>
>               MyConfigurations config =
>request.getResource().adaptTo(ConfigurationBuilder.class).as(MyConfiguratio
>ns.class);
>
>returns a null value.
>
>
>I tried this in AEM 6.3 with the following bundles installed
>Apache Sling Context-Aware Configuration APIorg.apache.sling.caconfig.api
>1.1.0
>Apache Sling Context-Aware Configuration
>Implementationorg.apache.sling.caconfig.impl   1.2.0
>Apache Sling Context-Aware Configuration SPIorg.apache.sling.caconfig.spi
>1.2.0
>
>Any feedback, thoughts would be greatly appreciated,
>Jose.
>
>
>
>--
>Sent from: http://apache-sling.73963.n3.nabble.com/Sling-Users-f73968.html


Reply via email to