This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-models-provider.git
commit 5bef3a07400e4a164b820e4b5ce05fc9677c0e59 Author: Konrad Windszus <[email protected]> AuthorDate: Thu Sep 17 06:58:24 2015 +0000 SLING-4734 skip provider as early as possible if the given class is no model git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1703499 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- .../sightly/models/impl/ModelFactoryUseProvider.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 218f80c..04cddd5 100644 --- a/pom.xml +++ b/pom.xml @@ -92,7 +92,7 @@ <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.models.api</artifactId> - <version>1.2.0</version> + <version>1.2.2</version> <scope>provided</scope> </dependency> diff --git a/src/main/java/org/apache/sling/scripting/sightly/models/impl/ModelFactoryUseProvider.java b/src/main/java/org/apache/sling/scripting/sightly/models/impl/ModelFactoryUseProvider.java index 07c495b..6c81d92 100644 --- a/src/main/java/org/apache/sling/scripting/sightly/models/impl/ModelFactoryUseProvider.java +++ b/src/main/java/org/apache/sling/scripting/sightly/models/impl/ModelFactoryUseProvider.java @@ -80,6 +80,11 @@ public class ModelFactoryUseProvider implements UseProvider { // next use provider will be queried return ProviderOutcome.failure(); } + if (!modelFactory.isModelClass(cls)) { + log.debug("{} is no Sling Model (because it lacks the according Model annotation or is not being picked up by the Bundle Listener)!"); + // next use provider will be queried + return ProviderOutcome.failure(); + } Bindings globalBindings = renderContext.getBindings(); Bindings bindings = merge(globalBindings, arguments); Resource resource = (Resource) bindings.get(SlingBindings.RESOURCE); @@ -90,16 +95,11 @@ public class ModelFactoryUseProvider implements UseProvider { if (request == null) { return ProviderOutcome.failure(new IllegalStateException("Could not get request from bindings")); } - + // pass parameters as request attributes Map<String, Object> overrides = setRequestAttributes(request, arguments); Object obj = null; try { - if (!modelFactory.isModelClass(resource, cls)) { - log.debug("{} is no Sling Model (because it lacks the according Model annotation)!"); - // next use provider will be queried - return ProviderOutcome.failure(); - } // try to instantiate class via Sling Models (first via request, then via resource) if (modelFactory.canCreateFromAdaptable(request, cls)) { obj = modelFactory.createModel(request, cls); -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
