Update of /var/cvs/src/org/mmbase/module/core
In directory james.mmbase.org:/tmp/cvs-serv13533/src/org/mmbase/module/core

Modified Files:
        ClusterBuilder.java MMObjectNode.java 
Log Message:
Use Cache classes not in bridge only in core. Cache classes will start MMbase 
even when MMbase is shutting down.



See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/module/core


Index: ClusterBuilder.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/module/core/ClusterBuilder.java,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -b -r1.93 -r1.94
--- ClusterBuilder.java 3 Feb 2008 17:33:57 -0000       1.93
+++ ClusterBuilder.java 13 Jun 2008 09:58:26 -0000      1.94
@@ -13,7 +13,9 @@
 import java.util.Map.Entry;
 
 import org.mmbase.module.corebuilders.*;
+import org.mmbase.cache.MultilevelCache;
 import org.mmbase.core.CoreField;
+import org.mmbase.bridge.BridgeException;
 import org.mmbase.bridge.Field;
 import org.mmbase.core.util.Fields;
 import org.mmbase.util.functions.*;
@@ -50,7 +52,7 @@
  * @author Rico Jansen
  * @author Pierre van Rooden
  * @author Rob van Maris
- * @version $Id: ClusterBuilder.java,v 1.93 2008/02/03 17:33:57 nklasens Exp $
+ * @version $Id: ClusterBuilder.java,v 1.94 2008/06/13 09:58:26 nklasens Exp $
  * @see ClusterNode
  */
 public class ClusterBuilder extends VirtualBuilder {
@@ -173,7 +175,7 @@
         for (Entry<String, Object> entry : node.getValues().entrySet()) {
             String key = entry.getKey();
             if (key.endsWith(".name")) {
-                if (s.length() != 0) {
+                if (sb.length() != 0) {
                     sb.append(", ");
                 }
                 sb.append(entry.getValue());
@@ -430,6 +432,42 @@
     /**
      * Executes query, returns results as [EMAIL PROTECTED] ClusterNode 
clusternodes} or MMObjectNodes if the
      * query is a Node-query.
+     * This method uses the MultilevelCache for query results
+     *
+     * @param query The query.
+     * @return The clusternodes.
+     * @since MMBase-1.7
+     */
+    public List<MMObjectNode> getClusterNodes(SearchQuery query) {
+
+        // start multilevel cache
+        MultilevelCache multilevelCache = MultilevelCache.getCache();
+        // check multilevel cache if needed
+        List<MMObjectNode> resultList = null;
+        if (query.getCachePolicy().checkPolicy(query)) {
+            resultList = multilevelCache.get(query);
+        }
+        // if unavailable, obtain from database
+        if (resultList == null) {
+            log.debug("result list is null, getting from database");
+            try {
+                resultList = getClusterNodesFromQueryHandler(query);
+            } catch (SearchQueryException sqe) {
+                throw new BridgeException(query.toString() + ":" + 
sqe.getMessage(), sqe);
+            }
+            if (query.getCachePolicy().checkPolicy(query)) {
+                multilevelCache.put(query, resultList);
+            }
+        }
+
+        return resultList;
+    }
+
+    /**
+     * Executes query, returns results as [EMAIL PROTECTED] ClusterNode 
clusternodes} or MMObjectNodes if the
+     * query is a Node-query. 
+     * The results are retrieved directly from storage without the 
MultilevelCache
+     * [EMAIL PROTECTED] #getClusterNodes(SearchQuery)} which uses the 
MultilevelCache
      *
      * @param query The query.
      * @return The clusternodes.
@@ -438,13 +476,12 @@
      * @since MMBase-1.7
      * @see org.mmbase.storage.search.SearchQueryHandler#getNodes
      */
-    public List<MMObjectNode> getClusterNodes(SearchQuery query) throws 
SearchQueryException {
-
+    public List<MMObjectNode> getClusterNodesFromQueryHandler(SearchQuery 
query)
+            throws SearchQueryException {
         // TODO (later): implement maximum set by maxNodesFromQuery?
         // Execute query, return results.
 
         return mmb.getSearchQueryHandler().getNodes(query, this);
-
     }
 
     /**


Index: MMObjectNode.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/module/core/MMObjectNode.java,v
retrieving revision 1.218
retrieving revision 1.219
diff -u -b -r1.218 -r1.219
--- MMObjectNode.java   12 Jun 2008 09:46:21 -0000      1.218
+++ MMObjectNode.java   13 Jun 2008 09:58:26 -0000      1.219
@@ -40,7 +40,7 @@
  * @author Eduard Witteveen
  * @author Michiel Meeuwissen
  * @author Ernst Bunders
- * @version $Id: MMObjectNode.java,v 1.218 2008/06/12 09:46:21 michiel Exp $
+ * @version $Id: MMObjectNode.java,v 1.219 2008/06/13 09:58:26 nklasens Exp $
  */
 
 public class MMObjectNode implements org.mmbase.util.SizeMeasurable, 
java.io.Serializable  {
@@ -511,7 +511,7 @@
     }
 
     /**
-     * If a node is still 'new' you must persistify it with [EMAIL PROTECTED] 
#insert}, and otherwise with [EMAIL PROTECTED] #commit}.
+     * If a node is still 'new' you must persistify it with [EMAIL PROTECTED] 
#insert(String)}, and otherwise with [EMAIL PROTECTED] #commit()}.
      * @since MMBase-1.8
      */
     public boolean isNew() {
@@ -1445,8 +1445,8 @@
     /**
      * Sets the node's alias.
      * The code only sets a (memory) property, it does not actually add the 
alias to the database.
-     * Only works for uninserted Nodes. So this is actually only used for 
application import.
-     * No need to use this. Use [EMAIL PROTECTED] MMObjectBuilder#createAlias}.
+     * Only works for un-inserted Nodes. So this is actually only used for 
application import.
+     * No need to use this. Use [EMAIL PROTECTED] 
MMObjectBuilder#createAlias(int, String)}.
      */
     public void setAlias(String alias) {
         if (aliases == null) aliases = new HashSet<String>();
@@ -1608,7 +1608,7 @@
             List<MMObjectNode> v = relatedCache.get(query);
             if (v == null) {
                 try {
-                    v = clusterBuilder.getClusterNodes(query);
+                    v = clusterBuilder.getClusterNodesFromQueryHandler(query);
                     relatedCache.put(query, v);
                 } catch (SearchQueryException sqe) {
                     log.error(sqe.toString());
@@ -1635,11 +1635,11 @@
     /**
      * Loop through the virtuals vector, group all same nodes based on parent 
and fetch the real nodes from those parents
      *
-     * @param List  of virtual nodes (only type.number and type.otype fields 
are set)
-     * @param type, needed to retreive the otype, which is set in node as type 
+ ".otype"
+     * @param virtuals  of virtual nodes (only type.number and type.otype 
fields are set)
+     * @param type needed to retreive the otype, which is set in node as type 
+ ".otype"
      * @returns List of real nodes
      *
-     * @see getRelatedNodes(String type)
+     * @see #getRelatedNodes(String type)
      * @since MMBase-1.6.2
      */
     private List<MMObjectNode> getRealNodes(List<MMObjectNode> virtuals, 
String type) {
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to