You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by sa...@apache.org on 2011/12/14 09:10:39 UTC

svn commit: r1214094 - /directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AbstractEvaluator.java

Author: saya
Date: Wed Dec 14 08:10:38 2011
New Revision: 1214094

URL: http://svn.apache.org/viewvc?rev=1214094&view=rev
Log:
add abstract evaluator for search engine to do entry lookup and initialize txn manager and execution manager instances

Added:
    directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AbstractEvaluator.java

Added: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AbstractEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AbstractEvaluator.java?rev=1214094&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AbstractEvaluator.java (added)
+++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AbstractEvaluator.java Wed Dec 14 08:10:38 2011
@@ -0,0 +1,69 @@
+
+package org.apache.directory.server.xdbm.search.impl;
+
+import java.util.UUID;
+
+import org.apache.directory.server.core.api.partition.OperationExecutionManager;
+import org.apache.directory.server.core.api.partition.Partition;
+import org.apache.directory.server.core.api.partition.index.MasterTable;
+import org.apache.directory.server.core.api.txn.TxnLogManager;
+import org.apache.directory.server.core.shared.partition.OperationExecutionManagerFactory;
+import org.apache.directory.server.core.shared.txn.TxnManagerFactory;
+import org.apache.directory.server.xdbm.search.Evaluator;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.filter.ExprNode;
+import org.apache.directory.shared.ldap.model.name.Dn;
+
+
+public abstract class AbstractEvaluator<T extends ExprNode> implements Evaluator<T>
+{
+    /** The backend */
+    protected final Partition db;
+    
+    /** Txn log manager */
+    protected TxnLogManager txnLogManager;
+    
+    /** Master table */
+    private MasterTable masterTable;
+    
+    /** Operation execution manager */
+    protected OperationExecutionManager executionManager;
+    
+    /** Txn and Operation Execution Factories */
+    protected TxnManagerFactory txnManagerFactory;
+    protected OperationExecutionManagerFactory executionManagerFactory;
+    
+    
+    public AbstractEvaluator( Partition db, TxnManagerFactory txnManagerFactory,
+        OperationExecutionManagerFactory executionManagerFactory ) throws Exception
+    {
+        this.db = db;
+        txnLogManager = txnManagerFactory.txnLogManagerInstance();
+        masterTable = txnLogManager.wrap( db.getSuffixDn(), db.getMasterTable() );
+        executionManager = executionManagerFactory.instance();
+        
+        this.txnManagerFactory = txnManagerFactory;
+        this.executionManagerFactory = executionManagerFactory;
+    }
+    
+    
+    public AbstractEvaluator()
+    {
+        // If no partition is there, we wont initialize the txn and operation execution manager
+        db = null;
+    }
+    
+    
+    protected Entry getEntry( UUID id ) throws Exception
+    {
+        Entry entry = masterTable.get( id );
+        
+        if ( entry != null )
+        {
+            Dn dn = executionManager.buildEntryDn( db, id );
+            entry.setDn( dn );
+        }
+        
+        return entry;
+    }
+}