You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ju...@apache.org on 2010/01/25 21:03:16 UTC

svn commit: r902962 - in /sling/trunk: bundles/commons/json/ bundles/commons/json/src/main/java/org/apache/sling/commons/json/groovy/internal/ launchpad/testing/src/test/resources/integration-test/

Author: justin
Date: Mon Jan 25 20:03:15 2010
New Revision: 902962

URL: http://svn.apache.org/viewvc?rev=902962&view=rev
Log:
SLING-1320 - adding script binding for JSONGroovyBuilder

Added:
    sling/trunk/bundles/commons/json/src/main/java/org/apache/sling/commons/json/groovy/internal/
    sling/trunk/bundles/commons/json/src/main/java/org/apache/sling/commons/json/groovy/internal/JSONGroovyBuilderBindingsValuesProvider.java
Modified:
    sling/trunk/bundles/commons/json/pom.xml
    sling/trunk/launchpad/testing/src/test/resources/integration-test/builder.groovy

Modified: sling/trunk/bundles/commons/json/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/json/pom.xml?rev=902962&r1=902961&r2=902962&view=diff
==============================================================================
--- sling/trunk/bundles/commons/json/pom.xml (original)
+++ sling/trunk/bundles/commons/json/pom.xml Mon Jan 25 20:03:15 2010
@@ -44,11 +44,15 @@
         <plugins>
             <plugin>
                 <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
-                        <Import-Package>groovy.*;resolution:=optional,*</Import-Package>
+                        <Import-Package>groovy.*;resolution:=optional,org.apache.sling.scripting.api.*;resolution:=optional,*</Import-Package>
                         <Export-Package>
                             org.apache.sling.commons.json.*;version=${pom.version}
                         </Export-Package>
@@ -82,6 +86,12 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.scripting.api</artifactId>
+            <version>2.0.3-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>

Added: sling/trunk/bundles/commons/json/src/main/java/org/apache/sling/commons/json/groovy/internal/JSONGroovyBuilderBindingsValuesProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/json/src/main/java/org/apache/sling/commons/json/groovy/internal/JSONGroovyBuilderBindingsValuesProvider.java?rev=902962&view=auto
==============================================================================
--- sling/trunk/bundles/commons/json/src/main/java/org/apache/sling/commons/json/groovy/internal/JSONGroovyBuilderBindingsValuesProvider.java (added)
+++ sling/trunk/bundles/commons/json/src/main/java/org/apache/sling/commons/json/groovy/internal/JSONGroovyBuilderBindingsValuesProvider.java Mon Jan 25 20:03:15 2010
@@ -0,0 +1,44 @@
+/*
+ * 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.commons.json.groovy.internal;
+
+import javax.script.Bindings;
+
+import org.apache.sling.commons.json.groovy.JSONGroovyBuilder;
+import org.apache.sling.scripting.api.BindingsValuesProvider;
+
+/**
+ * BindingsValuesProvider which binds an instance of JSONGroovyBuilder.
+ *
+ * @scr.component immediate="true" metatype="no"
+ * @scr.service
+ *
+ * @scr.property name="service.description" value="JSONGroovyBuilder BindingsValuesProvider"
+ * @scr.property name="service.vendor" value="The Apache Software Foundation"
+ *
+ * @scr.property name="javax.script.name" value="groovy"
+ */
+public class JSONGroovyBuilderBindingsValuesProvider implements BindingsValuesProvider {
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addBindings(Bindings bindings) {
+        bindings.put("jsonBuilder", new JSONGroovyBuilder());
+    }
+
+}

Modified: sling/trunk/launchpad/testing/src/test/resources/integration-test/builder.groovy
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/resources/integration-test/builder.groovy?rev=902962&r1=902961&r2=902962&view=diff
==============================================================================
--- sling/trunk/launchpad/testing/src/test/resources/integration-test/builder.groovy (original)
+++ sling/trunk/launchpad/testing/src/test/resources/integration-test/builder.groovy Mon Jan 25 20:03:15 2010
@@ -17,8 +17,6 @@
  * under the License.
  */
 
-builder = new org.apache.sling.commons.json.groovy.JSONGroovyBuilder()
-
-out.write builder.json {
+out.write jsonBuilder.json {
     text currentNode.getProperty("text").string
 } as String