sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r628828 - in /incubator/sling/trunk: osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/misc/ scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/ scripting/javascript/src/main/java/org/apa...
Date Mon, 18 Feb 2008 17:29:03 GMT
Author: cziegeler
Date: Mon Feb 18 09:28:47 2008
New Revision: 628828

URL: http://svn.apache.org/viewvc?rev=628828&view=rev
Log:
Code cleanup.

Modified:
    incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/misc/ConfigurationRender.java
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingWrapFactory.java
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableItemMap.java
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.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
    incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java
    incubator/sling/trunk/sling/servlets-standard/src/main/java/org/apache/sling/servlets/standard/FileServlet.java
    incubator/sling/trunk/sling/servlets-standard/src/main/java/org/apache/sling/servlets/standard/ReferenceServlet.java

Modified: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/misc/ConfigurationRender.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/misc/ConfigurationRender.java?rev=628828&r1=628827&r2=628828&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/misc/ConfigurationRender.java
(original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/misc/ConfigurationRender.java
Mon Feb 18 09:28:47 2008
@@ -45,13 +45,11 @@
 import org.apache.sling.osgi.console.web.Render;
 import org.apache.sling.osgi.console.web.internal.BaseManagementPlugin;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.component.ComponentContext;
 import org.osgi.service.prefs.BackingStoreException;
 import org.osgi.service.prefs.Preferences;
 import org.osgi.service.prefs.PreferencesService;

Modified: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingWrapFactory.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingWrapFactory.java?rev=628828&r1=628827&r2=628828&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingWrapFactory.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/helper/SlingWrapFactory.java
Mon Feb 18 09:28:47 2008
@@ -44,6 +44,7 @@
      *            object based on its class, staticType will be used instead.
      * @return the wrapped value which shall not be null
      */
+    @SuppressWarnings("unchecked")
     @Override
     public Scriptable wrapAsJavaObject(Context cx, Scriptable scope,
             Object javaObject, Class staticType) {
@@ -67,7 +68,7 @@
         if(result==null) {
             result = super.wrapAsJavaObject(cx, scope, javaObject, staticType);
         }
-        
+
         return result;
     }
 

Modified: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableItemMap.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableItemMap.java?rev=628828&r1=628827&r2=628828&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableItemMap.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableItemMap.java
Mon Feb 18 09:28:47 2008
@@ -23,7 +23,6 @@
 import java.util.Map;
 
 import javax.jcr.Item;
-import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 
 import org.mozilla.javascript.ScriptRuntime;
@@ -91,9 +90,7 @@
     public Object get(String name, Scriptable start) {
         Item item = items.get(name);
         Object result = Undefined.instance;
-        if (item instanceof Property) {
-            result = ScriptRuntime.toObject(this, (Property)item);
-        } else if (item != null) {
+        if (item != null) {
             result = ScriptRuntime.toObject(this, item);
         }
 

Modified: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java?rev=628828&r1=628827&r2=628828&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java
Mon Feb 18 09:28:47 2008
@@ -54,7 +54,7 @@
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     private Node node;
-    
+
     public ScriptableNode() {
     }
 
@@ -74,7 +74,7 @@
     public Class<?> [] getWrappedClasses() {
         return WRAPPED_CLASSES;
     }
-    
+
     public Object jsFunction_addNode(String path, String primaryType) throws RepositoryException
{
         Node n = null;
         if(primaryType == null || "undefined".equals(primaryType)) {
@@ -82,11 +82,11 @@
         } else {
             n = node.addNode(path, primaryType);
         }
-        
+
         final Object result = ScriptRuntime.toObject(this, n);
         return result;
     }
-    
+
     public Object jsFunction_getNode(String path) throws RepositoryException {
         return ScriptRuntime.toObject(this, node.getNode(path));
     }
@@ -252,7 +252,7 @@
     public boolean jsFunction_getModified() {
         return node.isModified();
     }
-    
+
     /**
      * Gets the value of a (Javascript) property or child node. If there is a single single-value
      * JCR property of this node, return its string value. If there are multiple properties
@@ -266,13 +266,13 @@
         if(fromSuperclass != Scriptable.NOT_FOUND) {
             return fromSuperclass;
         }
-        
+
         if(node == null) {
             return Undefined.instance;
         }
 
         final List<Scriptable> items = new ArrayList<Scriptable>();
-        
+
         // Add all matching nodes to result
         try {
             NodeIterator it = node.getNodes(name);
@@ -356,6 +356,7 @@
         return ids.toArray();
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public Object getDefaultValue(Class typeHint) {
         try {
@@ -383,7 +384,7 @@
             return node.toString();
         }
     }
-    
+
     // ---------- Wrapper interface --------------------------------------------
 
     // returns the wrapped node

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=628828&r1=628827&r2=628828&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
Mon Feb 18 09:28:47 2008
@@ -31,7 +31,7 @@
 
     public static final String CLASSNAME = "Property";
     public static final Class<?> [] WRAPPED_CLASSES = { Property.class };
-    
+
     private Property property;
 
     public ScriptableProperty() {
@@ -56,7 +56,7 @@
     public Class<?> [] getWrappedClasses() {
         return WRAPPED_CLASSES;
     }
-    
+
     public Object jsGet_value() {
         try {
             return property.getValue();
@@ -209,6 +209,7 @@
         return property.isModified();
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public Object getDefaultValue(Class typeHint) {
         return toString();
@@ -222,7 +223,7 @@
             return property.toString();
         }
     }
-    
+
     //---------- Wrapper interface --------------------------------------------
 
     public Object unwrap() {

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=628828&r1=628827&r2=628828&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
Mon Feb 18 09:28:47 2008
@@ -56,7 +56,7 @@
     public Class<?> [] getWrappedClasses() {
         return WRAPPED_CLASSES;
     }
-    
+
     @Override
     public String getClassName() {
         return CLASSNAME;
@@ -98,7 +98,7 @@
     public Object jsGet_meta() {
         return jsFunction_getMetadata();
     }
-    
+
     // TODO a wrapper would be more convenient than an Iterator,
     // but in my tests ScriptableItemMap didn't seem to allow
     // proper wrapping of its elements: javascript constructor
@@ -106,11 +106,11 @@
     public Iterator<Resource> jsGet_children() {
         return resource.getResourceResolver().listChildren(resource);
     }
-    
+
     public Object jsFunction_getResourceResolver() {
         return toJS(resource.getResourceResolver());
     }
-    
+
     public Object jsGet_resourceResolver() {
         return jsFunction_getResourceResolver();
     }
@@ -123,15 +123,15 @@
         while (arg instanceof Wrapper) {
             arg = ((Wrapper) arg).unwrap();
         }
-        
+
         // try to get the Class object for the argument
         Class<?> adapter = null;
         if (arg instanceof Class) {
-            
+
             adapter = (Class<?>) arg;
-            
+
         } else if (arg != null && arg != Undefined.instance) {
-            
+
             // try loading the class from the String
             String className = ScriptRuntime.toString(arg);
             try {
@@ -143,17 +143,18 @@
             } catch (Exception e) {
                 // TODO: log exception
             }
-            
+
         }
-        
+
         if (adapter != null) {
             ScriptableResource sr = (ScriptableResource) thisObj;
             return sr.toJS(sr.resource.adaptTo(adapter));
         }
-        
+
         return Undefined.instance;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public Object getDefaultValue(Class typeHint) {
         return resource.getPath();
@@ -171,12 +172,12 @@
     }
 
     //---------- Internal helper ----------------------------------------------
-    
+
     private Object toJS(Object javaObject) {
         if (javaObject == null) {
             return Undefined.instance;
         }
-        
+
         return ScriptRuntime.toObject(this, javaObject);
     }
 }

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java?rev=628828&r1=628827&r2=628828&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java
(original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java
Mon Feb 18 09:28:47 2008
@@ -247,7 +247,7 @@
         }
 
         // setting the Sling request and response
-        RequestData requestData = new RequestData(this,
+        final RequestData requestData = new RequestData(this,
             getResourceResolverFactory().getResourceResolver(session),
             servletRequest, servletResponse);
         SlingHttpServletRequest request = requestData.getSlingRequest();
@@ -283,8 +283,7 @@
 
             // if we have request data and a non-null active servlet name
             // we assume, that this is the name of the causing servlet
-            if (requestData != null
-                && requestData.getActiveServletName() != null) {
+            if (requestData.getActiveServletName() != null) {
                 request.setAttribute(ERROR_SERVLET_NAME,
                     requestData.getActiveServletName());
             }
@@ -307,8 +306,7 @@
 
             // if we have request data and a non-null active servlet name
             // we assume, that this is the name of the causing servlet
-            if (requestData != null
-                && requestData.getActiveServletName() != null) {
+            if (requestData.getActiveServletName() != null) {
                 request.setAttribute(ERROR_SERVLET_NAME,
                     requestData.getActiveServletName());
             }
@@ -317,9 +315,7 @@
             getErrorHandler().handleError(t, request, response);
 
         } finally {
-            if (requestData != null) {
-                requestData.dispose();
-            }
+            requestData.dispose();
 
             session.logout();
         }

Modified: incubator/sling/trunk/sling/servlets-standard/src/main/java/org/apache/sling/servlets/standard/FileServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlets-standard/src/main/java/org/apache/sling/servlets/standard/FileServlet.java?rev=628828&r1=628827&r2=628828&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlets-standard/src/main/java/org/apache/sling/servlets/standard/FileServlet.java
(original)
+++ incubator/sling/trunk/sling/servlets-standard/src/main/java/org/apache/sling/servlets/standard/FileServlet.java
Mon Feb 18 09:28:47 2008
@@ -21,7 +21,6 @@
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletException;
 
-import org.apache.sling.api.SlingException;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.resource.Resource;

Modified: incubator/sling/trunk/sling/servlets-standard/src/main/java/org/apache/sling/servlets/standard/ReferenceServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlets-standard/src/main/java/org/apache/sling/servlets/standard/ReferenceServlet.java?rev=628828&r1=628827&r2=628828&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlets-standard/src/main/java/org/apache/sling/servlets/standard/ReferenceServlet.java
(original)
+++ incubator/sling/trunk/sling/servlets-standard/src/main/java/org/apache/sling/servlets/standard/ReferenceServlet.java
Mon Feb 18 09:28:47 2008
@@ -21,7 +21,6 @@
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletException;
 
-import org.apache.sling.api.SlingException;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.resource.Resource;



Mime
View raw message