Author: bdelacretaz
Date: Thu Dec 5 01:42:06 2013
New Revision: 1547989
URL: http://svn.apache.org/r1547989
Log:
Move Scriptable objects to impl
Added:
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableProperties.java
(with props)
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableResourceProperties.java
(with props)
Removed:
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/api/ScriptableProperties.java
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/api/ScriptableResourceProperties.java
Modified:
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/api/SlingRequestContext.java
Modified:
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/api/SlingRequestContext.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/api/SlingRequestContext.java?rev=1547989&r1=1547988&r2=1547989&view=diff
==============================================================================
---
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/api/SlingRequestContext.java
(original)
+++
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/api/SlingRequestContext.java
Thu Dec 5 01:42:06 2013
@@ -21,6 +21,8 @@ package org.apache.sling.requestcontext.
import javax.servlet.http.HttpServletRequest;
import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.requestcontext.impl.ScriptableProperties;
+import org.apache.sling.requestcontext.impl.ScriptableResourceProperties;
import org.mozilla.javascript.Scriptable;
/** Intelligent Request Context meant to be provided in
Added:
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableProperties.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableProperties.java?rev=1547989&view=auto
==============================================================================
---
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableProperties.java
(added)
+++
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableProperties.java
Thu Dec 5 01:42:06 2013
@@ -0,0 +1,56 @@
+/*
+ * 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.requestcontext.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+
+@SuppressWarnings("serial")
+public class ScriptableProperties extends ScriptableObject {
+
+ private final Map<String, Object> properties = new HashMap<String,
Object>();
+ private boolean isReadOnly;
+
+ @Override
+ public String getClassName() {
+ return getClass().getName();
+ }
+
+ protected void setReadOnly(boolean b) {
+ isReadOnly = b;
+ }
+
+ @Override
+ public Object get(String name, Scriptable start) {
+ final Object result = properties.get(name);
+ return result != null ? result : NOT_FOUND;
+ }
+
+ @Override
+ public void put(String name, Scriptable start, Object value) {
+ if(isReadOnly) {
+ throw new IllegalArgumentException("Read-only object, property is
not modifiable:" + name);
+ }
+ properties.put(name, value);
+ }
+
+}
Propchange:
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableProperties.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableProperties.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added:
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableResourceProperties.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableResourceProperties.java?rev=1547989&view=auto
==============================================================================
---
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableResourceProperties.java
(added)
+++
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableResourceProperties.java
Thu Dec 5 01:42:06 2013
@@ -0,0 +1,45 @@
+/*
+ * 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.requestcontext.impl;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ValueMap;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+
+@SuppressWarnings("serial")
+public class ScriptableResourceProperties extends ScriptableObject {
+
+ private final ValueMap valueMap;
+
+ public ScriptableResourceProperties(Resource r) {
+ valueMap = r.adaptTo(ValueMap.class);
+ }
+
+ @Override
+ public String getClassName() {
+ return getClass().getName();
+ }
+
+ @Override
+ public Object get(String name, Scriptable start) {
+ final Object result = valueMap == null ? null : valueMap.get(name);
+ return result != null ? result : NOT_FOUND;
+ }
+}
Propchange:
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableResourceProperties.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/whiteboard/bdelacretaz/request-context/src/main/java/org/apache/sling/requestcontext/impl/ScriptableResourceProperties.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL