You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2007/09/20 14:51:26 UTC

svn commit: r577727 - /incubator/sling/trunk/jackrabbit-api/src/main/java/org/apache/sling/jcr/internal/loader/Loader.java

Author: cziegeler
Date: Thu Sep 20 05:51:25 2007
New Revision: 577727

URL: http://svn.apache.org/viewvc?rev=577727&view=rev
Log:
Reduce log output. If node type registration fails, log this only once - but log success of a retry.

Modified:
    incubator/sling/trunk/jackrabbit-api/src/main/java/org/apache/sling/jcr/internal/loader/Loader.java

Modified: incubator/sling/trunk/jackrabbit-api/src/main/java/org/apache/sling/jcr/internal/loader/Loader.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jackrabbit-api/src/main/java/org/apache/sling/jcr/internal/loader/Loader.java?rev=577727&r1=577726&r2=577727&view=diff
==============================================================================
--- incubator/sling/trunk/jackrabbit-api/src/main/java/org/apache/sling/jcr/internal/loader/Loader.java (original)
+++ incubator/sling/trunk/jackrabbit-api/src/main/java/org/apache/sling/jcr/internal/loader/Loader.java Thu Sep 20 05:51:25 2007
@@ -65,13 +65,13 @@
     }
 
     public void registerBundle(Bundle bundle) {
-        if (this.registerBundleInternal(bundle)) {
+        if (this.registerBundleInternal(bundle, false)) {
             // handle delayed bundles, might help now
             int currentSize = -1;
             for (int i=this.delayedBundles.size(); i > 0 && currentSize != this.delayedBundles.size() && !this.delayedBundles.isEmpty(); i--) {
                 for (Iterator<Bundle> di=this.delayedBundles.iterator(); di.hasNext(); ) {
                     Bundle delayed = di.next();
-                    if (this.registerBundleInternal(delayed)) {
+                    if (this.registerBundleInternal(delayed, true)) {
                         di.remove();
                     }
                 }
@@ -89,24 +89,29 @@
         }
     }
 
-    private boolean registerBundleInternal (Bundle bundle) {
+    private boolean registerBundleInternal (Bundle bundle, boolean isRetry) {
         try {
-            if (this.registerNodeTypes(bundle)) {
+            if (this.registerNodeTypes(bundle, isRetry)) {
                 return true;
             }
         } catch (RepositoryException re) {
-            log.error("Cannot register node types for bundle {}: {}",
-                bundle.getSymbolicName(), re);
+            if ( isRetry ) {
+                log.error("Cannot register node types for bundle {}: {}",
+                    bundle.getSymbolicName(), re);
+            } else {
+                log.debug("Retrying to register node types failed for bundle {}: {}",
+                        bundle.getSymbolicName(), re);
+            }
         }
 
         return false;
     }
 
-    private boolean registerNodeTypes(Bundle bundle) throws RepositoryException {
+    private boolean registerNodeTypes(Bundle bundle, boolean isRetry) throws RepositoryException {
         // TODO: define header referring to mapper files
         String typesHeader = (String) bundle.getHeaders().get(NODETYPES_BUNDLE_HEADER);
         if (typesHeader == null) {
-            // no components in the bundle, return with success
+            // no node types in the bundle, return with success
             log.debug("registerNodeTypes: Bundle {} has no nodetypes",
                 bundle.getSymbolicName());
             return true;
@@ -121,27 +126,37 @@
 
                 URL mappingURL = bundle.getEntry(nodeTypeFile);
                 if (mappingURL == null) {
-                    log.warn("Mapping {} not found in bundle {}", nodeTypeFile, bundle.getSymbolicName());
+                    // if we are retrying we already logged this message once, so we won't log it again
+                    if ( !isRetry ) {
+                        log.warn("Custom node type definition {} not found in bundle {}", nodeTypeFile, bundle.getSymbolicName());
+                    }
                     continue;
                 }
 
                 InputStream ins = null;
                 try {
-                    // laod the descriptors
+                    // laod the node types
                     ins = mappingURL.openStream();
                     NodeTypeLoader.registerNodeType(session, ins);
+                    // log a message if retry is successful
+                    if ( isRetry ) {
+                        log.info("Retrytring to register node types from {} in bundle {} succeeded.",
+                           new Object[]{ nodeTypeFile, bundle.getSymbolicName()});
+                    }
                 } catch (IOException ioe) {
                     success = false;
-//                    log.error("Cannot read node types " + nodeTypeFile
-//                        + " from bundle " + bundle.getSymbolicName(), ioe);
-                    log.warn("Cannot read node types {} from bundle {}: {}",
-                        new Object[]{ nodeTypeFile, bundle.getSymbolicName(), ioe });
+                    // if we are retrying we already logged this message once, so we won't log it again
+                    if ( !isRetry ) {
+                        log.warn("Cannot read node types {} from bundle {}: {}",
+                            new Object[]{ nodeTypeFile, bundle.getSymbolicName(), ioe });
+                    }
                 } catch (Exception e) {
                     success = false;
-//                    log.error("Error loading node types " + nodeTypeFile
-//                        + " from bundle " + bundle.getSymbolicName(), e);
-                    log.error("Error loading node types {} from bundle {}: {}",
-                        new Object[]{ nodeTypeFile, bundle.getSymbolicName(), e });
+                    // if we are retrying we already logged this message once, so we won't log it again
+                    if ( !isRetry ) {
+                        log.error("Error loading node types {} from bundle {}: {}",
+                            new Object[]{ nodeTypeFile, bundle.getSymbolicName(), e });
+                    }
                 } finally {
                     if (ins != null) {
                         try {