Author: radu
Date: Thu Sep 17 14:07:19 2015
New Revision: 1703629

URL: http://svn.apache.org/r1703629
Log:
SLING-5036 - Optimise the ModelsFactoryUseProvider to fail as early as possible 
if it cannot provide an object

* renamed ModelsFactoryUseProvider to SlingModelsUseProvider
* delayed all bindings retrievals until they're absolutely necessary
* removed bindings merging - models can get their arguments through request 
attributes if they're adaptable from SlingHttpServletRequest
* updated the test setup to take into account the SlingModelsUseProvider (both 
IT and performance)

Added:
    
sling/trunk/bundles/scripting/sightly/models-use-provider/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java
      - copied, changed from r1703628, 
sling/trunk/bundles/scripting/sightly/models-use-provider/src/main/java/org/apache/sling/scripting/sightly/models/impl/ModelFactoryUseProvider.java
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/adaptable/package-info.java
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/TestModel.java
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/package-info.java
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/use/package-info.java
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightlyperf/test/sly-java-slingmodels.html
Removed:
    
sling/trunk/bundles/scripting/sightly/models-use-provider/src/main/java/org/apache/sling/scripting/sightly/models/impl/ModelFactoryUseProvider.java
Modified:
    sling/trunk/bundles/scripting/sightly/pom.xml
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/RequestModel.java
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/use/use.html
    
sling/trunk/bundles/scripting/sightly/testing/src/main/provisioning/model.txt
    
sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java
    
sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/performance/PerformanceIT.java

Copied: 
sling/trunk/bundles/scripting/sightly/models-use-provider/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java
 (from r1703628, 
sling/trunk/bundles/scripting/sightly/models-use-provider/src/main/java/org/apache/sling/scripting/sightly/models/impl/ModelFactoryUseProvider.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/models-use-provider/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java?p2=sling/trunk/bundles/scripting/sightly/models-use-provider/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java&p1=sling/trunk/bundles/scripting/sightly/models-use-provider/src/main/java/org/apache/sling/scripting/sightly/models/impl/ModelFactoryUseProvider.java&r1=1703628&r2=1703629&rev=1703629&view=diff
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/models-use-provider/src/main/java/org/apache/sling/scripting/sightly/models/impl/ModelFactoryUseProvider.java
 (original)
+++ 
sling/trunk/bundles/scripting/sightly/models-use-provider/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java
 Thu Sep 17 14:07:19 2015
@@ -1,30 +1,29 @@
-/*
+/*******************************************************************************
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
+ 
******************************************************************************/
 package org.apache.sling.scripting.sightly.models.impl;
 
-
 import java.util.HashMap;
 import java.util.Map;
-
+import java.util.regex.Pattern;
 import javax.script.Bindings;
-import javax.script.SimpleBindings;
 import javax.servlet.ServletRequest;
 
 import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
 import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
@@ -41,83 +40,104 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
+ * <p>
  * Sightly {@link UseProvider} which will instantiate a referenced Sling Model.
- * For that it tries to use the {@link ModelFactory#createModel(Object, 
Class)} first with the adaptable {@link Resource} 
+ * </p>
+ * <p>
+ * For that it tries to use the {@link ModelFactory#createModel(Object, 
Class)} first with the adaptable {@link Resource}
  * then with the adaptable {@link SlingHttpServletRequest}.
  * It will always fail with an exception (i.e. no other {@code UseProvider} is 
asked afterwards and the exception is being rethrown)
  * in case the following two preconditions are fulfilled:
  * <ol>
- * <li>the given identifier specifies a class which can be loaded by the 
DynamicClassLoader</li>
- * <li>the loaded class has a Model annotation</li>
+ * <li>the given identifier specifies a class which can be loaded by a {@link 
org.apache.sling.commons.classloader.DynamicClassLoader}</li>
+ * <li>the loaded class has a {@link 
org.apache.sling.models.annotations.Model} annotation</li>
  * </ol>
- * In case any of those preconditions are not fulfilled the other registered 
UseProviders are used!
+ * </p>
+ * <p>
+ * <p>
+ * In case any of those preconditions are not fulfilled the other registered 
{@link UseProvider}s will be queried.
+ * </p>
  */
 @Component
 @Service
-/*
- * must have a higher priority than 
org.apache.sling.scripting.sightly.impl.engine.extension.use.JavaUseProvider 
but lower than 
- * 
org.apache.sling.scripting.sightly.impl.engine.extension.use.RenderUnitProvider 
to kick in 
- * before the JavaUseProvider but after the RenderUnitProvider
- */
-@Property(name = Constants.SERVICE_RANKING, intValue = { 95 }) 
-public class ModelFactoryUseProvider implements UseProvider {
+@Properties({
+    @Property(
+        name = Constants.SERVICE_RANKING,
+        label = "Service Ranking",
+        description =
+            "The Service Ranking value acts as the priority with which this 
Use Provider is queried to return an Use-object. A" +
+                "higher value represents a higher priority.",
+        /**
+         * Must have a higher priority than {@link 
org.apache.sling.scripting.sightly.impl.engine.extension.use.JavaUseProvider} 
but lower
+         * than {@link 
org.apache.sling.scripting.sightly.impl.engine.extension.use.RenderUnitProvider}
 to kick in before the
+         * JavaUseProvider but after the RenderUnitProvider.
+         */
+        intValue = 95
+    )
+})
+public class SlingModelsUseProvider implements UseProvider {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(SlingModelsUseProvider.class);
+    private static final Pattern JAVA_PATTERN = Pattern.compile(
+        
"([[\\p{L}&&[^\\p{Lu}]]_$][\\p{L}\\p{N}_$]*\\.)*[\\p{Lu}_$][\\p{L}\\p{N}_$]*");
+
 
-    private static final Logger log = 
LoggerFactory.getLogger(ModelFactoryUseProvider.class);
-    
     @Reference
-    ModelFactory modelFactory;
-    
+    private ModelFactory modelFactory = null;
+
     @Reference
     private DynamicClassLoaderManager dynamicClassLoaderManager = null;
-    
+
     @Override
     public ProviderOutcome provide(final String identifier, final 
RenderContext renderContext, final Bindings arguments) {
+        if (!JAVA_PATTERN.matcher(identifier).matches()) {
+            LOGGER.debug("Identifier {} does not match a Java class name 
pattern.", identifier);
+            return ProviderOutcome.failure();
+        }
         final Class<?> cls;
         try {
             cls = 
dynamicClassLoaderManager.getDynamicClassLoader().loadClass(identifier);
-        } catch(ClassNotFoundException e) {
-            log.debug("Could not find class with the given name {}: {}", 
identifier, e.getMessage());
+        } catch (ClassNotFoundException e) {
+            LOGGER.debug("Could not find class with the given name {}: {}", 
identifier, e.getMessage());
             // 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)!");
+            LOGGER.debug("{} is not a Sling Model.");
             // 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);
-        if (resource == null) {
-            return ProviderOutcome.failure(new IllegalStateException("Could 
not get resource from bindings"));
-        }
-        SlingHttpServletRequest request = (SlingHttpServletRequest) 
bindings.get(SlingBindings.REQUEST);
+        SlingHttpServletRequest request = (SlingHttpServletRequest) 
globalBindings.get(SlingBindings.REQUEST);
         if (request == null) {
-            return ProviderOutcome.failure(new IllegalStateException("Could 
not get request from bindings"));
+            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 {
             // try to instantiate class via Sling Models (first via request, 
then via resource)
             if (modelFactory.canCreateFromAdaptable(request, cls)) {
-                obj = modelFactory.createModel(request, cls);
-            } else if (modelFactory.canCreateFromAdaptable(resource, cls)) {
-                obj = modelFactory.createModel(resource, cls);
-            } else {
-                return ProviderOutcome.failure(new 
IllegalStateException("Could not adapt the given Sling Model from neither 
resource nor request: " + cls));
+                return 
ProviderOutcome.notNullOrFailure(modelFactory.createModel(request, cls));
+            }
+            Resource resource = (Resource) 
globalBindings.get(SlingBindings.RESOURCE);
+            if (resource == null) {
+                return ProviderOutcome.failure(new 
IllegalStateException("Could not get resource from bindings."));
+            }
+            if (modelFactory.canCreateFromAdaptable(resource, cls)) {
+                return 
ProviderOutcome.notNullOrFailure(modelFactory.createModel(resource, cls));
             }
+            return ProviderOutcome.failure(
+                new IllegalStateException("Could not adapt the given Sling 
Model from neither request nor resource: " + cls));
         } catch (Throwable e) {
             return ProviderOutcome.failure(e);
         } finally {
             resetRequestAttribute(request, overrides);
+
         }
-        return ProviderOutcome.notNullOrFailure(obj);
     }
 
-    private Map<String, Object> setRequestAttributes(final ServletRequest 
request,
-            final Bindings arguments) {
+    private Map<String, Object> setRequestAttributes(final ServletRequest 
request, final Bindings arguments) {
         Map<String, Object> overrides = new HashMap<String, Object>();
         for (Map.Entry<String, Object> entry : arguments.entrySet()) {
             String key = entry.getKey();
@@ -125,8 +145,7 @@ public class ModelFactoryUseProvider imp
             Object oldValue = request.getAttribute(key);
             if (oldValue != null) {
                 overrides.put(key, oldValue);
-            }
-            else {
+            } else {
                 overrides.put(key, null);
             }
             request.setAttribute(key, value);
@@ -134,24 +153,15 @@ public class ModelFactoryUseProvider imp
         return overrides;
     }
 
-    private void resetRequestAttribute(final ServletRequest request,
-            final Map<String, Object> overrides) {
+    private void resetRequestAttribute(final ServletRequest request, final 
Map<String, Object> overrides) {
         for (Map.Entry<String, Object> entry : overrides.entrySet()) {
             String key = entry.getKey();
             Object value = entry.getValue();
             if (value == null) {
                 request.removeAttribute(key);
-            }
-            else {
+            } else {
                 request.setAttribute(key, value);
             }
         }
     }
-
-    private SimpleBindings merge(Bindings former, Bindings latter) {
-        SimpleBindings bindings = new SimpleBindings();
-        bindings.putAll(former);
-        bindings.putAll(latter);
-        return bindings;
-    }
 }

Modified: sling/trunk/bundles/scripting/sightly/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/pom.xml?rev=1703629&r1=1703628&r2=1703629&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/sightly/pom.xml (original)
+++ sling/trunk/bundles/scripting/sightly/pom.xml Thu Sep 17 14:07:19 2015
@@ -52,10 +52,10 @@
     <modules>
         <module>engine</module>
         <module>js-use-provider</module>
+        <module>models-use-provider</module>
         <module>repl</module>
         <module>testing-content</module>
         <module>testing</module>
-        <module>models-use-provider</module>
     </modules>
 
 </project>

Added: 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/adaptable/package-info.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/adaptable/package-info.java?rev=1703629&view=auto
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/adaptable/package-info.java
 (added)
+++ 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/adaptable/package-info.java
 Thu Sep 17 14:07:19 2015
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ 
******************************************************************************/
+
+@Version("1.0.4")
+package org.apache.sling.scripting.sightly.testing.adaptable;
+
+import aQute.bnd.annotation.Version;
\ No newline at end of file

Modified: 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/RequestModel.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/RequestModel.java?rev=1703629&r1=1703628&r2=1703629&view=diff
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/RequestModel.java
 (original)
+++ 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/RequestModel.java
 Thu Sep 17 14:07:19 2015
@@ -23,18 +23,24 @@ import javax.inject.Named;
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.Source;
 import org.apache.sling.models.annotations.Via;
 
 @Model(adaptables = SlingHttpServletRequest.class)
 public class RequestModel {
 
-    @Inject
-    @Via("resource")
-    @Named("jcr:title")
+    @Inject @Via("resource") @Named("jcr:title")
     private String title;
 
+    @Inject @Named("argument")
+    // get it from request attributes
+    private String requestArgument;
+
     public String getTitle() {
         return title != null ? title : "FAILED";
     }
 
+    public String getRequestArgument() {
+        return requestArgument != null ? requestArgument : "FAILED";
+    }
 }

Added: 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/TestModel.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/TestModel.java?rev=1703629&view=auto
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/TestModel.java
 (added)
+++ 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/TestModel.java
 Thu Sep 17 14:07:19 2015
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ 
******************************************************************************/
+package org.apache.sling.scripting.sightly.testing.models;
+
+import java.util.Iterator;
+import javax.inject.Inject;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Default;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.Optional;
+
+@Model(adaptables = Resource.class)
+public class TestModel {
+
+    @Inject
+    private String text;
+
+    @Inject @Optional
+    private String tag;
+
+    @Inject @Default(booleanValues = false)
+    private boolean includeChildren;
+
+    private Resource resource;
+
+    public TestModel(Resource resource) {
+        this.resource = resource;
+    }
+
+    public String getText() {
+        return text;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public boolean getIncludeChildren() {
+        return includeChildren;
+    }
+
+    public String getStartTag() {
+        if (tag == null) {
+            return null;
+        }
+        return "<" + tag + ">";
+    }
+
+    public String getEndTag() {
+        if (tag == null) {
+            return null;
+        }
+        return "</" + tag + ">";
+    }
+
+    public Iterator<Resource> getChildren() {
+        return resource.listChildren();
+    }
+
+}

Added: 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/package-info.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/package-info.java?rev=1703629&view=auto
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/package-info.java
 (added)
+++ 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/models/package-info.java
 Thu Sep 17 14:07:19 2015
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ 
******************************************************************************/
+
+@Version("1.1.0")
+package org.apache.sling.scripting.sightly.testing.models;
+
+import aQute.bnd.annotation.Version;
\ No newline at end of file

Added: 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/use/package-info.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/use/package-info.java?rev=1703629&view=auto
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/use/package-info.java
 (added)
+++ 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/java/org/apache/sling/scripting/sightly/testing/use/package-info.java
 Thu Sep 17 14:07:19 2015
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ 
******************************************************************************/
+
+@Version("1.0.0")
+package org.apache.sling.scripting.sightly.testing.use;
+
+import aQute.bnd.annotation.Version;
\ No newline at end of file

Modified: 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/use/use.html
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/use/use.html?rev=1703629&r1=1703628&r2=1703629&view=diff
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/use/use.html
 (original)
+++ 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/use/use.html
 Thu Sep 17 14:07:19 2015
@@ -22,7 +22,9 @@
         <title>Sightly Use-API - Sling implementation</title>
     </head>
     <body>
-        <div id="reqmodel" 
data-sly-use.reqmodel="org.apache.sling.scripting.sightly.testing.models.RequestModel">${reqmodel.title}</div>
+        <div id="reqmodel" 
data-sly-use.reqmodel="${'org.apache.sling.scripting.sightly.testing.models.RequestModel'
 @
+            argument='SUCCESS'}">${reqmodel.title}</div>
+        <div id="reqmodel-reqarg">${reqmodel.requestArgument}</div>
         <div id="resmodel" 
data-sly-use.resmodel="org.apache.sling.scripting.sightly.testing.models.ResourceModel">${resmodel.title}</div>
         <div id="reqadapt"
              
data-sly-use.reqadapt="org.apache.sling.scripting.sightly.testing.adaptable.RequestAdapterUseObject">${reqadapt.title}</div>

Added: 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightlyperf/test/sly-java-slingmodels.html
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightlyperf/test/sly-java-slingmodels.html?rev=1703629&view=auto
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightlyperf/test/sly-java-slingmodels.html
 (added)
+++ 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightlyperf/test/sly-java-slingmodels.html
 Thu Sep 17 14:07:19 2015
@@ -0,0 +1,27 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+<div 
data-sly-use.test="org.apache.sling.scripting.sightly.testing.models.TestModel" 
data-sly-unwrap>
+    ${test.tag != null ? test.startTag : '' @ context = "unsafe"}
+    ${test.text @ context = "text"}
+    ${test.tag != null ? test.endTag : '' @ context = "unsafe"}
+    <div data-sly-include="mode.jsp" data-sly-unwrap=""></div>
+    <ul data-sly-test="${test.includeChildren}" 
data-sly-list.child="${test.children}">
+        <li data-sly-resource="${child.path}"></li>
+    </ul>
+</div>

Modified: 
sling/trunk/bundles/scripting/sightly/testing/src/main/provisioning/model.txt
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing/src/main/provisioning/model.txt?rev=1703629&r1=1703628&r2=1703629&view=diff
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing/src/main/provisioning/model.txt 
(original)
+++ 
sling/trunk/bundles/scripting/sightly/testing/src/main/provisioning/model.txt 
Thu Sep 17 14:07:19 2015
@@ -22,6 +22,7 @@
   org.apache.sling/org.apache.sling.launchpad/8-SNAPSHOT/slingstart
   org.apache.sling/org.apache.sling.scripting.sightly/1.0.5-SNAPSHOT
   
org.apache.sling/org.apache.sling.scripting.sightly.js.provider/1.0.11-SNAPSHOT
+  
org.apache.sling/org.apache.sling.scripting.sightly.models.provider/1.0.0-SNAPSHOT
   org.apache.sling/org.apache.sling.scripting.sightly.repl/1.0.1-SNAPSHOT
   
org.apache.sling/org.apache.sling.scripting.sightly.testing-content/1.0.5-SNAPSHOT
 

Modified: 
sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java?rev=1703629&r1=1703628&r2=1703629&view=diff
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java
 (original)
+++ 
sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java
 Thu Sep 17 14:07:19 2015
@@ -52,6 +52,7 @@ public class SlingSpecificsSightlyIT {
         String url = launchpadURL + SLING_USE;
         String pageContent = client.getStringContent(url, 200);
         assertEquals("SUCCESS", HTMLExtractor.innerHTML(url, pageContent, 
"#reqmodel"));
+        assertEquals("SUCCESS", HTMLExtractor.innerHTML(url, pageContent, 
"#reqmodel-reqarg"));
         assertEquals("SUCCESS", HTMLExtractor.innerHTML(url, pageContent, 
"#resmodel"));
         
     }

Modified: 
sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/performance/PerformanceIT.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/performance/PerformanceIT.java?rev=1703629&r1=1703628&r2=1703629&view=diff
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/performance/PerformanceIT.java
 (original)
+++ 
sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/performance/PerformanceIT.java
 Thu Sep 17 14:07:19 2015
@@ -103,14 +103,20 @@ public class PerformanceIT {
             HttpStatus.SC_OK);
     }
 
+    @PerformanceTest(runinvocations = INVOCATIONS, warmupinvocations = 
WARMUP_INVOCATIONS, threshold = 2)
+    public void test5SlyJavaSlingModels() {
+        
getStringContent("/sightlyperf/loop.html?selector=sly-java-slingmodels&count=" 
+ CONTENT_LOOP_COUNT,
+            HttpStatus.SC_OK);
+    }
+
     @PerformanceTest(runinvocations = INVOCATIONS, warmupinvocations = 
WARMUP_INVOCATIONS, threshold = 4)
-    public void test5SlyJSAsync() {
+    public void test6SlyJSAsync() {
         getStringContent("/sightlyperf/loop.html?selector=sly-js-async&count=" 
+ CONTENT_LOOP_COUNT,
                 HttpStatus.SC_OK);
     }
 
     @PerformanceTest(runinvocations = INVOCATIONS, warmupinvocations = 
WARMUP_INVOCATIONS, threshold = 4)
-    public void test6SlyJSSync() {
+    public void test7SlyJSSync() {
         getStringContent("/sightlyperf/loop.html?selector=sly-js-sync&count=" 
+ CONTENT_LOOP_COUNT,
             HttpStatus.SC_OK);
     }


Reply via email to