incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r699368 - in /incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript: ./ helper/ wrapper/
Date Fri, 26 Sep 2008 15:36:03 GMT
Author: fmeschbe
Date: Fri Sep 26 08:36:03 2008
New Revision: 699368

URL: http://svn.apache.org/viewvc?rev=699368&view=rev
Log:
SLING-634 Provide service interface (RhinoHostObjectProvider) to extend
Rhino and export SlingWrapper to enable extensions to implement
proper wrappers

Added:
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/RhinoHostObjectProvider.java
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/SlingWrapper.java
      - copied, changed from r688978, incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingWrapper.java
Removed:
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingWrapper.java
Modified:
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingContext.java
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingGlobal.java
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableCalendar.java
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptablePrintWriter.java
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableProperty.java
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableResource.java

Added: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/RhinoHostObjectProvider.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/RhinoHostObjectProvider.java?rev=699368&view=auto
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/RhinoHostObjectProvider.java
(added)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/RhinoHostObjectProvider.java
Fri Sep 26 08:36:03 2008
@@ -0,0 +1,80 @@
+/*
+ * 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.javascript;
+
+import org.mozilla.javascript.Scriptable;
+
+/**
+ * The <code>RhinoHostObjectProvider</code> defines the service interface to
+ * inject additional ECMAScript host objects as well as to make classes and
+ * packages known.
+ */
+public interface RhinoHostObjectProvider {
+
+    /**
+     * Returns an array of classes implementing the Rhino
+     * <code>Scriptable</code> interface. These classes will be registered
+     * with the global scope as host objects and may then be used in any
+     * server-side ECMAScript scripts.
+     * <p>
+     * Implementations may return <code>null</code> instead of an empty array
+     * if they do not provide any host objects.
+     */
+    Class<? extends Scriptable>[] getHostObjectClasses();
+
+    /**
+     * Returns an array of classes, which are transparently converted into
+     * ECMAScript host objects in the global scope.
+     * <p>
+     * Normally any Java class may be used within ECMAScript but it must be
+     * prefixed with <code>Packages</code> and the fully qualified package
+     * name of the class. For example to use the class
+     * <code>org.slf4j.Log</code> in an ECMAScript it must be noted as
+     * <code>Packages.org.slf4j.Log</code>. By registering the
+     * <code>org.slf4j.Log</code> as an imported class, it may simply be
+     * referred to as <code>Log</code> (provided there is no other object of
+     * that name, of course).
+     * <p>
+     * Implementations may return <code>null</code> instead of an empty array
+     * if they do not provide any imported classes.
+     */
+    Class<?>[] getImportedClasses();
+
+    /**
+     * Returns an array of Java package names to define name spaces in the
+     * global scope.
+     * <p>
+     * Normally any Java class may be used within ECMAScript but it must be
+     * prefixed with <code>Packages</code> and the fully qualified package
+     * name of the class. For example to use the class
+     * <code>org.slf4j.Log</code> in an ECMAScript it must be noted as
+     * <code>Packages.org.slf4j.Log</code>. By registering the
+     * <code>org.slf4j</code> package as an imported package, it may simply be
+     * referred to as <code>Log</code> (provided there is no other object of
+     * that name, of course).
+     * <p>
+     * The difference between importing packages and importing classes is that
+     * for a package import to work, the package must be visible to the
+     * ECMAScript bundle.
+     * <p>
+     * Implementations may return <code>null</code> instead of an empty array
+     * if they do not provide any package names.
+     */
+    String[] getImportedPackages();
+}

Copied: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/SlingWrapper.java
(from r688978, incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingWrapper.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/SlingWrapper.java?p2=incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/SlingWrapper.java&p1=incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingWrapper.java&r1=688978&r2=699368&rev=699368&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingWrapper.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/SlingWrapper.java
Fri Sep 26 08:36:03 2008
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.scripting.javascript.helper;
+package org.apache.sling.scripting.javascript;
 
 import org.mozilla.javascript.Wrapper;
 

Modified: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingContext.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingContext.java?rev=699368&r1=699367&r2=699368&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingContext.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingContext.java
Fri Sep 26 08:36:03 2008
@@ -19,6 +19,7 @@
 package org.apache.sling.scripting.javascript.helper;
 
 import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ImporterTopLevel;
 import org.mozilla.javascript.ScriptableObject;
 
 /**
@@ -33,6 +34,11 @@
             boolean sealed) {
         ScriptableObject rootScope = super.initStandardObjects(scope, sealed);
 
+        // prepare the ImporterToplevel host object because it will be
+        // used as top level scope for the RhinoJavaScriptEngine but is
+        // not initialized with the rest of the standard objects
+        ImporterTopLevel.init(this, rootScope, sealed);
+        
         // add Sling global objects
         SlingGlobal.init(rootScope, sealed);
 

Modified: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingGlobal.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingGlobal.java?rev=699368&r1=699367&r2=699368&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingGlobal.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingGlobal.java
Fri Sep 26 08:36:03 2008
@@ -30,7 +30,7 @@
 import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.api.scripting.SlingBindings;
 import org.apache.sling.api.scripting.SlingScriptHelper;
-import org.apache.sling.scripting.javascript.RhinoJavaScriptEngineFactory;
+import org.apache.sling.scripting.javascript.internal.RhinoJavaScriptEngineFactory;
 import org.apache.sling.scripting.javascript.io.EspReader;
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.IdFunctionCall;

Modified: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableCalendar.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableCalendar.java?rev=699368&r1=699367&r2=699368&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableCalendar.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableCalendar.java
Fri Sep 26 08:36:03 2008
@@ -20,7 +20,7 @@
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 
-import org.apache.sling.scripting.javascript.helper.SlingWrapper;
+import org.apache.sling.scripting.javascript.SlingWrapper;
 import org.mozilla.javascript.ScriptRuntime;
 import org.mozilla.javascript.Scriptable;
 import org.mozilla.javascript.Undefined;

Modified: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptablePrintWriter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptablePrintWriter.java?rev=699368&r1=699367&r2=699368&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptablePrintWriter.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptablePrintWriter.java
Fri Sep 26 08:36:03 2008
@@ -22,7 +22,7 @@
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.sling.api.scripting.SlingBindings;
-import org.apache.sling.scripting.javascript.helper.SlingWrapper;
+import org.apache.sling.scripting.javascript.SlingWrapper;
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.Function;
 import org.mozilla.javascript.ScriptRuntime;

Modified: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableProperty.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableProperty.java?rev=699368&r1=699367&r2=699368&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableProperty.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableProperty.java
Fri Sep 26 08:36:03 2008
@@ -22,7 +22,7 @@
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 
-import org.apache.sling.scripting.javascript.helper.SlingWrapper;
+import org.apache.sling.scripting.javascript.SlingWrapper;
 import org.mozilla.javascript.ScriptRuntime;
 import org.mozilla.javascript.Scriptable;
 import org.mozilla.javascript.Undefined;

Modified: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableResource.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableResource.java?rev=699368&r1=699367&r2=699368&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableResource.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableResource.java
Fri Sep 26 08:36:03 2008
@@ -17,7 +17,7 @@
 package org.apache.sling.scripting.javascript.wrapper;
 
 import org.apache.sling.api.resource.Resource;
-import org.apache.sling.scripting.javascript.helper.SlingWrapper;
+import org.apache.sling.scripting.javascript.SlingWrapper;
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.Function;
 import org.mozilla.javascript.ScriptRuntime;



Mime
View raw message