incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r896032 - in /sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl: AbstractRepositoryEventHandler.java JobEventHandler.java TimedJobHandler.java
Date Tue, 05 Jan 2010 13:17:50 GMT
Author: cziegeler
Date: Tue Jan  5 13:17:49 2010
New Revision: 896032

URL: http://svn.apache.org/viewvc?rev=896032&view=rev
Log:
Minor performance improvement: get root node only once and store it

Modified:
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java?rev=896032&r1=896031&r2=896032&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
Tue Jan  5 13:17:49 2010
@@ -97,6 +97,9 @@
      *  Sling settings service. */
     protected SlingSettingsService settingsService;
 
+    /** The root node for writing. */
+    private Node writeRootNode;
+
     public static String APPLICATION_ID;
 
     /**
@@ -164,6 +167,7 @@
         } catch (InterruptedException e) {
             this.ignoreException(e);
         }
+        this.writeRootNode = null;
     }
 
     /**
@@ -187,9 +191,10 @@
      */
     protected void startWriterSession() throws RepositoryException {
         this.writerSession = this.createSession();
-        if ( this.repositoryPath != null ) {
-            this.ensureRepositoryPath();
-        }
+        this.writeRootNode = JcrResourceUtil.createPath(this.repositoryPath,
+                EventHelper.NODETYPE_FOLDER,
+                EventHelper.NODETYPE_ORDERED_FOLDER,
+                this.writerSession, true);
     }
 
     /**
@@ -209,23 +214,17 @@
     }
 
     /**
-     * Check if the repository path already exists. If not, create it.
+     * Return the node type for the event.
      */
-    protected Node ensureRepositoryPath()
-    throws RepositoryException {
-        final Node node = JcrResourceUtil.createPath(this.repositoryPath,
-                                   EventHelper.NODETYPE_FOLDER,
-                                   EventHelper.NODETYPE_ORDERED_FOLDER,
-                                   this.writerSession, true);
-
-        return node;
+    protected String getEventNodeType() {
+        return EventHelper.EVENT_NODE_TYPE;
     }
 
     /**
-     * Return the node type for the event.
+     * Get the root node from the writer session.
      */
-    protected String getEventNodeType() {
-        return EventHelper.EVENT_NODE_TYPE;
+    protected Node getWriterRootNode() {
+        return this.writeRootNode;
     }
 
     /**
@@ -238,7 +237,7 @@
     protected Node writeEvent(Event e, String suggestedName)
     throws RepositoryException {
         // create new node with name of topic
-        final Node rootNode = this.ensureRepositoryPath();
+        final Node rootNode = this.getWriterRootNode();
 
         final String nodeType = this.getEventNodeType();
         final String nodeName;

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java?rev=896032&r1=896031&r2=896032&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
Tue Jan  5 13:17:49 2010
@@ -463,7 +463,7 @@
                         }
                         try {
                             // let's first search for an existing node with the same id
-                            final Node parentNode = this.ensureRepositoryPath();
+                            final Node parentNode = this.getWriterRootNode();
                             Node foundNode = null;
                             if ( parentNode.hasNode(nodePath) ) {
                                 foundNode = parentNode.getNode(nodePath);

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java?rev=896032&r1=896031&r2=896032&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java
Tue Jan  5 13:17:49 2010
@@ -195,7 +195,7 @@
     protected String persistEvent(final Event event, final ScheduleInfo scheduleInfo) {
         try {
             // get parent node
-            final Node parentNode = this.ensureRepositoryPath();
+            final Node parentNode = this.getWriterRootNode();
             final String nodeName = scheduleInfo.jobId;
             // is there already a node?
             final Node foundNode = parentNode.hasNode(nodeName) ? parentNode.getNode(nodeName)
: null;



Mime
View raw message