You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by jmanuelbr <jm...@gmail.com> on 2017/10/10 15:39:47 UTC

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(MyConfigurations.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

RE: Servlet Aware Configurations

Posted by Stefan Seifert <ss...@pro-vision.de>.
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:jmanuelbr@gmail.com]
>Sent: Tuesday, October 10, 2017 5:40 PM
>To: users@sling.apache.org
>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