[
https://issues.apache.org/jira/browse/SLING-6034?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15465151#comment-15465151
]
Carsten Ziegeler commented on SLING-6034:
-----------------------------------------
[[email protected]] I think we must avoid classpath scanning if possible.
You load up resources into memory at a point when they are definitly not needed
yet, and maybe they are never used at all.
But my main reason was actually b) - while the adapter pattern is nice, you're
not really adapting the resource to something, you rather use it as a short cut
to avoid boilerplate code; I know that we have this in various places and I
think this is bad and we shouldn't have done it in the first place. But equally
important this prevents adapting a context resource to such a configuration
annotation directly. Which in turn prevents reuse of the configuration
annotation. I think the resulting code is confusing, what does:
resource.adaptTo(Foo.class)
do ?
Does it adapt the resource directory to Foo because this might be a model class
or does it first get a configuration resource and adapt it to Foo?
> Context-Aware Config: Allow direct adaption of configuration annotation
> classes
> -------------------------------------------------------------------------------
>
> Key: SLING-6034
> URL: https://issues.apache.org/jira/browse/SLING-6034
> Project: Sling
> Issue Type: New Feature
> Components: Extensions
> Reporter: Stefan Seifert
> Assignee: Stefan Seifert
> Labels: contextaware-config
> Fix For: Context-Aware Configuration 1.0.0
>
>
> currently for getting a configuration mapped to a configuration annotation
> classes you need this code line:
> {code:java}
> SimpleConfig config =
> resourcePage1.adaptTo(ConfigurationBuilder.class).as(SimpleConfig.class);
> {code}
> with a dynamic adapter factory it should be also possible to adapt directly
> to the configuration class:
> {code:java}
> SimpleConfig config = resourcePage1.adaptTo(SimpleConfig.class);
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)