Rework Factory mechanism for Horde_Lock based on a *lot* of discussion
authorBen Klang <ben@alkaloid.net>
Sun, 3 Oct 2010 01:53:00 +0000 (21:53 -0400)
committerBen Klang <ben@alkaloid.net>
Sun, 3 Oct 2010 02:06:27 +0000 (22:06 -0400)
framework/Core/lib/Horde/Core/Binder/Lock.php [deleted file]
framework/Core/lib/Horde/Core/Factory/Lock.php [new file with mode: 0644]
framework/Core/lib/Horde/Registry.php
framework/Core/package.xml
framework/Lock/lib/Horde/Lock.php
framework/Lock/lib/Horde/Lock/Base.php [deleted file]
framework/Lock/lib/Horde/Lock/Null.php
framework/Lock/lib/Horde/Lock/Sql.php
framework/Lock/package.xml

diff --git a/framework/Core/lib/Horde/Core/Binder/Lock.php b/framework/Core/lib/Horde/Core/Binder/Lock.php
deleted file mode 100644 (file)
index 3fad1b2..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/**
- * @category Horde
- * @package  Core
- */
-class Horde_Core_Binder_Lock implements Horde_Injector_Binder
-{
-    public function create(Horde_Injector $injector)
-    {
-        $driver = empty($GLOBALS['conf']['lock']['driver'])
-            ? 'Null'
-            : $GLOBALS['conf']['lock']['driver'];
-
-        if (strcasecmp($driver, 'None') === 0) {
-            $driver = 'Null';
-        }
-
-        $params = Horde::getDriverConfig('lock', $driver);
-        $params['logger'] = $injector->getInstance('Horde_Log_Logger');
-
-        if (strcasecmp($driver, 'Sql') === 0) {
-            $params['db'] = $injector->getInstance('Horde_Db')->getDb('horde', 'lock');
-        }
-
-        return Horde_Lock::factory($driver, $params);
-    }
-
-    public function equals(Horde_Injector_Binder $binder)
-    {
-        return false;
-    }
-
-}
diff --git a/framework/Core/lib/Horde/Core/Factory/Lock.php b/framework/Core/lib/Horde/Core/Factory/Lock.php
new file mode 100644 (file)
index 0000000..d53b1cc
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Factory for creating Horde_Lock objects
+ *
+ * Copyright 2010 Horde LLC <http://horde.org>
+ * 
+ * @category Horde
+ * @package  Core
+ */
+
+class Horde_Core_Factory_Lock extends Horde_Core_Factory
+{
+    /**
+     * Attempts to return a concrete instance based on the configured driver.
+     *
+     * @return Horde_Lock  The newly created concrete instance.
+     * @throws Horde_Lock_Exception
+     */
+    public function create(Horde_Injector $injector)
+    {
+        $driver = empty($GLOBALS['conf']['lock']['driver'])
+            ? 'Null'
+            : $GLOBALS['conf']['lock']['driver'];
+
+        if (strcasecmp($driver, 'None') === 0) {
+            $driver = 'Null';
+        }
+
+        $params = Horde::getDriverConfig('lock', $driver);
+        $params['logger'] = $injector->getInstance('Horde_Log_Logger');
+
+        if (strcasecmp($driver, 'Sql') === 0) {
+            $params['db'] = $injector->getInstance('Horde_Db')->getDb('horde', 'lock');
+        }
+
+        $driver = Horde_String::ucfirst(basename($driver));
+        $class = __CLASS__ . '_' . $driver;
+
+        if (class_exists($class)) {
+            return new $class($params);
+        }
+
+        throw new Horde_Lock_Exception('Horde_Lock driver (' . $class . ') not found');
+    }
+}
\ No newline at end of file
index b814d50..75506ee 100644 (file)
@@ -278,7 +278,6 @@ class Horde_Registry
             'Horde_History' => 'Horde_Core_Binder_History',
             'Horde_Http_Client' => 'Horde_Core_Binder_HttpClient',
             'Horde_Ldap' => 'Horde_Core_Binder_Ldap',
-            'Horde_Lock' => 'Horde_Core_Binder_Lock',
             'Horde_Log_Logger' => 'Horde_Core_Binder_Logger',
             'Horde_LoginTasks' => 'Horde_Core_Binder_LoginTasks',
             'Horde_Mail' => 'Horde_Core_Binder_Mail',
@@ -333,6 +332,10 @@ class Horde_Registry
                 'Horde_Core_Factory_KolabStorage',
                 'getStorage',
             ),
+            'Horde_Lock' => array(
+                'Horde_Core_Factory_Lock',
+                'create',
+            ),
             'Horde_View' => array(
                 'Horde_Core_Factory_View',
                 'create',
index 7c4380a..9eb8aaa 100644 (file)
@@ -23,8 +23,8 @@ Application Framework.</description>
   <email>slusarz@horde.org</email>
   <active>yes</active>
  </developer>
- <date>2010-07-01</date>
- <time>12:29:52</time>
+ <date>2010-10-02</date>
+ <time>21:51:26</time>
  <version>
   <release>0.1.0</release>
   <api>0.1.0</api>
@@ -34,7 +34,8 @@ Application Framework.</description>
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Add Horde::addInlineJsVars().
+ <notes>
+* Add Horde::addInlineJsVars().
  * Remove Horde::nocacheUrl() and Horde::url() (Ticket #9160).
  * Absorb horde/Ui package.
  * Absorb horde/Ajax package.
@@ -67,8 +68,8 @@ Application Framework.</description>
     <file name="open_html_helper.js" role="horde" />
     <file name="prefs.js" role="horde" />
     <file name="prettyautocomplete.js" role="horde" />
-    <file name="spellchecker.js" role="horde" />
     <file name="sourceselect.js" role="horde" />
+    <file name="spellchecker.js" role="horde" />
     <file name="tooltips.js" role="horde" />
    </dir> <!-- /js -->
    <dir name="lib">
@@ -79,11 +80,11 @@ Application Framework.</description>
      <dir name="Core">
       <dir name="Ajax">
        <dir name="Imple">
-        <file name="AutoCompleter.php" role="php" />
-        <file name="SpellChecker.php" role="php" />
         <dir name="Geocoder">
          <file name="Geonames.php" role="php" />
         </dir> <!-- /lib/Horde/Core/Ajax/Imple/Geocoder -->
+        <file name="AutoCompleter.php" role="php" />
+        <file name="SpellChecker.php" role="php" />
        </dir> <!-- /lib/Horde/Core/Ajax/Imple -->
        <file name="Application.php" role="php" />
        <file name="Imple.php" role="php" />
@@ -124,10 +125,10 @@ Application Framework.</description>
        <file name="HttpClient.php" role="php" />
        <file name="Identity.php" role="php" />
        <file name="Ldap.php" role="php" />
-       <file name="Lock.php" role="php" />
        <file name="Logger.php" role="php" />
        <file name="LoginTasks.php" role="php" />
        <file name="Mail.php" role="php" />
+       <file name="Mapper.php" role="php" />
        <file name="Memcache.php" role="php" />
        <file name="MimeViewer.php" role="php" />
        <file name="Notification.php" role="php" />
@@ -165,6 +166,7 @@ Application Framework.</description>
        <file name="KolabSession.php" role="php" />
        <file name="KolabStorage.php" role="php" />
        <file name="Ldap.php" role="php" />
+       <file name="Lock.php" role="php" />
        <file name="LoginTasks.php" role="php" />
        <file name="MimeViewer.php" role="php" />
        <file name="Prefs.php" role="php" />
@@ -203,7 +205,6 @@ Application Framework.</description>
        <file name="Identity.php" role="php" />
        <file name="Ui.php" role="php" />
       </dir> <!-- /lib/Horde/Core/Prefs -->
-      <file name="Sidebar.php" role="php" />
       <dir name="Text">
        <dir name="Filter">
         <file name="Bbcode.php" role="php" />
@@ -232,6 +233,7 @@ Application Framework.</description>
        <file name="VarRenderer.php" role="php" />
        <file name="Widget.php" role="php" />
       </dir> <!-- /lib/Horde/Core/Ui -->
+      <file name="Sidebar.php" role="php" />
      </dir> <!-- /lib/Horde/Core -->
      <dir name="Exception">
       <file name="HookNotSet.php" role="php" />
@@ -413,11 +415,12 @@ Application Framework.</description>
    <install as="Horde/Registry.php" name="lib/Horde/Registry.php" />
    <install as="Horde/Themes.php" name="lib/Horde/Themes.php" />
    <install as="Horde/Config/Form.php" name="lib/Horde/Config/Form.php" />
+   <install as="Horde/Core/Sidebar.php" name="lib/Horde/Core/Sidebar.php" />
+   <install as="Horde/Core/Ajax/Application.php" name="lib/Horde/Core/Ajax/Application.php" />
+   <install as="Horde/Core/Ajax/Imple.php" name="lib/Horde/Core/Ajax/Imple.php" />
    <install as="Horde/Core/Ajax/Imple/AutoCompleter.php" name="lib/Horde/Core/Ajax/Imple/AutoCompleter.php" />
    <install as="Horde/Core/Ajax/Imple/SpellChecker.php" name="lib/Horde/Core/Ajax/Imple/SpellChecker.php" />
    <install as="Horde/Core/Ajax/Imple/Geocoder/Geonames.php" name="lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php" />
-   <install as="Horde/Core/Ajax/Application.php" name="lib/Horde/Core/Ajax/Application.php" />
-   <install as="Horde/Core/Ajax/Imple.php" name="lib/Horde/Core/Ajax/Imple.php" />
    <install as="Horde/Core/Auth/Application.php" name="lib/Horde/Core/Auth/Application.php" />
    <install as="Horde/Core/Auth/Ldap.php" name="lib/Horde/Core/Auth/Ldap.php" />
    <install as="Horde/Core/Auth/Msad.php" name="lib/Horde/Core/Auth/Msad.php" />
@@ -445,10 +448,10 @@ Application Framework.</description>
    <install as="Horde/Core/Binder/HttpClient.php" name="lib/Horde/Core/Binder/HttpClient.php" />
    <install as="Horde/Core/Binder/Identity.php" name="lib/Horde/Core/Binder/Identity.php" />
    <install as="Horde/Core/Binder/Ldap.php" name="lib/Horde/Core/Binder/Ldap.php" />
-   <install as="Horde/Core/Binder/Lock.php" name="lib/Horde/Core/Binder/Lock.php" />
    <install as="Horde/Core/Binder/Logger.php" name="lib/Horde/Core/Binder/Logger.php" />
    <install as="Horde/Core/Binder/LoginTasks.php" name="lib/Horde/Core/Binder/LoginTasks.php" />
    <install as="Horde/Core/Binder/Mail.php" name="lib/Horde/Core/Binder/Mail.php" />
+   <install as="Horde/Core/Binder/Mapper.php" name="lib/Horde/Core/Binder/Mapper.php" />
    <install as="Horde/Core/Binder/Memcache.php" name="lib/Horde/Core/Binder/Memcache.php" />
    <install as="Horde/Core/Binder/MimeViewer.php" name="lib/Horde/Core/Binder/MimeViewer.php" />
    <install as="Horde/Core/Binder/Notification.php" name="lib/Horde/Core/Binder/Notification.php" />
@@ -459,8 +462,8 @@ Application Framework.</description>
    <install as="Horde/Core/Binder/ShareFactory.php" name="lib/Horde/Core/Binder/ShareFactory.php" />
    <install as="Horde/Core/Binder/Template.php" name="lib/Horde/Core/Binder/Template.php" />
    <install as="Horde/Core/Binder/TextFilter.php" name="lib/Horde/Core/Binder/TextFilter.php" />
-   <install as="Horde/Core/Binder/Tree.php" name="lib/Horde/Core/Binder/Tree.php" />
    <install as="Horde/Core/Binder/Token.php" name="lib/Horde/Core/Binder/Token.php" />
+   <install as="Horde/Core/Binder/Tree.php" name="lib/Horde/Core/Binder/Tree.php" />
    <install as="Horde/Core/Binder/Twitter.php" name="lib/Horde/Core/Binder/Twitter.php" />
    <install as="Horde/Core/Binder/Vfs.php" name="lib/Horde/Core/Binder/Vfs.php" />
    <install as="Horde/Core/Controller/NotFound.php" name="lib/Horde/Core/Controller/NotFound.php" />
@@ -482,6 +485,7 @@ Application Framework.</description>
    <install as="Horde/Core/Factory/KolabSession.php" name="lib/Horde/Core/Factory/KolabSession.php" />
    <install as="Horde/Core/Factory/KolabStorage.php" name="lib/Horde/Core/Factory/KolabStorage.php" />
    <install as="Horde/Core/Factory/Ldap.php" name="lib/Horde/Core/Factory/Ldap.php" />
+   <install as="Horde/Core/Factory/Lock.php" name="lib/Horde/Core/Factory/Lock.php" />
    <install as="Horde/Core/Factory/LoginTasks.php" name="lib/Horde/Core/Factory/LoginTasks.php" />
    <install as="Horde/Core/Factory/MimeViewer.php" name="lib/Horde/Core/Factory/MimeViewer.php" />
    <install as="Horde/Core/Factory/Prefs.php" name="lib/Horde/Core/Factory/Prefs.php" />
@@ -501,7 +505,6 @@ Application Framework.</description>
    <install as="Horde/Core/Prefs/Identity.php" name="lib/Horde/Core/Prefs/Identity.php" />
    <install as="Horde/Core/Prefs/Ui.php" name="lib/Horde/Core/Prefs/Ui.php" />
    <install as="Horde/Core/Prefs/Ui/Widgets.php" name="lib/Horde/Core/Prefs/Ui/Widgets.php" />
-   <install as="Horde/Core/Sidebar.php" name="lib/Horde/Core/Sidebar.php" />
    <install as="Horde/Core/Text/Filter/Bbcode.php" name="lib/Horde/Core/Text/Filter/Bbcode.php" />
    <install as="Horde/Core/Text/Filter/Emails.php" name="lib/Horde/Core/Text/Filter/Emails.php" />
    <install as="Horde/Core/Text/Filter/Emoticons.php" name="lib/Horde/Core/Text/Filter/Emoticons.php" />
@@ -509,8 +512,6 @@ Application Framework.</description>
    <install as="Horde/Core/Tree/Html.php" name="lib/Horde/Core/Tree/Html.php" />
    <install as="Horde/Core/Tree/Javascript.php" name="lib/Horde/Core/Tree/Javascript.php" />
    <install as="Horde/Core/Tree/Simplehtml.php" name="lib/Horde/Core/Tree/Simplehtml.php" />
-   <install as="Horde/Core/Ui/VarRenderer/Html.php" name="lib/Horde/Core/Ui/VarRenderer/Html.php" />
-   <install as="Horde/Core/Ui/VarRenderer/TablesetHtml.php" name="lib/Horde/Core/Ui/VarRenderer/TablesetHtml.php" />
    <install as="Horde/Core/Ui/FlagImage.php" name="lib/Horde/Core/Ui/FlagImage.php" />
    <install as="Horde/Core/Ui/JsCalendar.php" name="lib/Horde/Core/Ui/JsCalendar.php" />
    <install as="Horde/Core/Ui/Language.php" name="lib/Horde/Core/Ui/Language.php" />
@@ -520,6 +521,8 @@ Application Framework.</description>
    <install as="Horde/Core/Ui/TagCloud.php" name="lib/Horde/Core/Ui/TagCloud.php" />
    <install as="Horde/Core/Ui/VarRenderer.php" name="lib/Horde/Core/Ui/VarRenderer.php" />
    <install as="Horde/Core/Ui/Widget.php" name="lib/Horde/Core/Ui/Widget.php" />
+   <install as="Horde/Core/Ui/VarRenderer/Html.php" name="lib/Horde/Core/Ui/VarRenderer/Html.php" />
+   <install as="Horde/Core/Ui/VarRenderer/TablesetHtml.php" name="lib/Horde/Core/Ui/VarRenderer/TablesetHtml.php" />
    <install as="Horde/Exception/HookNotSet.php" name="lib/Horde/Exception/HookNotSet.php" />
    <install as="Horde/Registry/Api.php" name="lib/Horde/Registry/Api.php" />
    <install as="Horde/Registry/Application.php" name="lib/Horde/Registry/Application.php" />
@@ -528,6 +531,13 @@ Application Framework.</description>
    <install as="Horde/Themes/Element.php" name="lib/Horde/Themes/Element.php" />
    <install as="Horde/Themes/Image.php" name="lib/Horde/Themes/Image.php" />
    <install as="Horde/Themes/Sound.php" name="lib/Horde/Themes/Sound.php" />
+   <install as="Horde/Core/AllTests.php" name="test/Horde/Core/AllTests.php" />
+   <install as="Horde/Core/Autoload.php" name="test/Horde/Core/Autoload.php" />
+   <install as="Horde/Core/phpunit.xml" name="test/Horde/Core/phpunit.xml" />
+   <install as="Horde/Core/url.phpt" name="test/Horde/Core/url.phpt" />
+   <install as="Horde/Core/Binder/CacheTest.php" name="test/Horde/Core/Binder/CacheTest.php" />
+   <install as="Horde/Core/Factory/KolabServerTest.php" name="test/Horde/Core/Factory/KolabServerTest.php" />
+   <install as="Horde/Core/Factory/KolabSessionTest.php" name="test/Horde/Core/Factory/KolabSessionTest.php" />
   </filelist>
  </phprelease>
  <changelog>
@@ -571,10 +581,14 @@ Initial packaging
     <release>beta</release>
     <api>beta</api>
    </stability>
-   <date>2010-07-01</date>
+   <date>2010-10-02</date>
    <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
    <notes>
-* Import application auth driver from horde/Auth.
+* Add Horde::addInlineJsVars().
+ * Remove Horde::nocacheUrl() and Horde::url() (Ticket #9160).
+ * Absorb horde/Ui package.
+ * Absorb horde/Ajax package.
+ * Import application auth driver from horde/Auth.
  * Import signup code from horde/Auth.
  * Import Horde backend driver from horde/LoginTasks.
  * Import perms UI handling class from horde/Perms.
index 92219c8..dcc0b19 100644 (file)
@@ -3,12 +3,12 @@
  * The Horde_Lock class provides an API to create, store, check and expire locks
  * based on a given resource URI.
  *
- * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
+ * Copyright 2008-2010 Horde LLC (http://www.horde.org/)
  *
  * See the enclosed file COPYING for license information (LGPL). If you did
  * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
  *
- * @author   Ben Klang <ben@alkaloid.net>
+ * @author   Ben Klang <bklang@horde.org>
  * @category Horde
  * @package  Lock
  */
@@ -19,27 +19,128 @@ class Horde_Lock
     const TYPE_SHARED = 2;
 
     /**
-     * Attempts to return a concrete instance based on $driver.
+     * Driver parameters.
      *
-     * @param mixed $driver  The type of concrete subclass to return.
-     *                       This is based on the storage driver ($driver).
-     *                       The code is dynamically included.
-     * @param array $params  A hash containing any additional configuration or
-     *                       connection parameters a subclass might need.
+     * @var array
+     */
+    protected $_params;
+
+    /**
+     * Logger.
      *
-     * @return Horde_Lock_Base  The newly created concrete instance.
-     * @throws Horde_Lock_Exception
+     * @var Horde_Log_Logger
      */
-    static public function factory($driver, $params = array())
-    {
-        $driver = Horde_String::ucfirst(basename($driver));
-        $class = __CLASS__ . '_' . $driver;
+    protected $_logger;
 
-        if (class_exists($class)) {
-            return new $class($params);
+    /**
+     * Constructor.
+     *
+     * @param array $params  Configuration parameters:
+     * <pre>
+     * 'logger' - (Horde_Log_Logger) A logger instance.
+     * </pre>
+     */
+    public function __construct($params = array())
+    {
+        if (!empty($params['logger'])) {
+            $this->_logger = $params['logger'];
+            unset($params['logger']);
         }
 
-        throw new Horde_Lock_Exception('Horde_Lock driver (' . $class . ') not found');
+        $this->_params = $params;
     }
 
+    /**
+     * Return an array of information about the requested lock.
+     *
+     * @param string $lockid  Lock ID to look up.
+     *
+     * @return array  Lock information.
+     * @throws Horde_Lock_Exception
+     */
+    abstract public function getLockInfo($lockid);
+
+    /**
+     * Return a list of valid locks with the option to limit the results
+     * by principal, scope and/or type.
+     *
+     * @param string $scope      The scope of the lock.  Typically the name of
+     *                           the application requesting the lock or some
+     *                           other identifier used to group locks together.
+     * @param string $principal  Principal for which to check for locks
+     * @param integer $type      Only return locks of the given type.
+     *                           Defaults to null, or all locks
+     *
+     * @return array  Array of locks with the ID as the key and the lock details
+     *                as the value. If there are no current locks this will
+     *                return an empty array.
+     * @throws Horde_Lock_Exception
+     */
+    abstract public function getLocks($scope = null, $principal = null,
+                                      $type = null);
+
+    /**
+     * Extend the valid lifetime of a valid lock to now + $extend.
+     *
+     * @param string $lockid   Lock ID to reset. Must be a valid, non-expired
+     *                         lock.
+     * @param integer $extend  Extend lock this many seconds from now.
+     *
+     * @return boolean  Returns true on success.
+     * @throws Horde_Lock_Exception
+     */
+    abstract public function resetLock($lockid, $extend);
+
+    /**
+     * Sets a lock on the requested principal and returns the generated lock
+     * ID. NOTE: No security checks are done in the Horde_Lock API. It is
+     * expected that the calling application has done all necessary security
+     * checks before requesting a lock be granted.
+     *
+     * @param string $requestor  User ID of the lock requestor.
+     * @param string $scope      The scope of the lock.  Typically the name of
+     *                           the application requesting the lock or some
+     *                           other identifier used to group locks
+     *                           together.
+     * @param string $principal  A principal on which a lock should be
+     *                           granted. The format can be any string but is
+     *                           suggested to be in URI form.
+     * @param integer $lifetime  Time (in seconds) for which the lock will be
+     *                           considered valid.
+     * @param string exclusive   One of Horde_Lock::TYPE_SHARED or
+     *                           Horde_Lock::TYPE_EXCLUSIVE.
+     *                           - An exclusive lock will be enforced strictly
+     *                             and must be interpreted to mean that the
+     *                             resource can not be modified. Only one
+     *                             exclusive lock per principal is allowed.
+     *                           - A shared lock is one that notifies other
+     *                             potential lock requestors that the resource
+     *                             is in use. This lock can be overridden
+     *                             (cleared or replaced with a subsequent
+     *                             call to setLock()) by other users. Multiple
+     *                             users may request (and will be granted) a
+     *                             shared lock on a given principal. All locks
+     *                             will be considered valid until they are
+     *                             cleared or expire.
+     *
+     * @return mixed   A string lock ID.
+     * @throws Horde_Lock_Exception
+     */
+    abstract public function setLock($requestor, $scope, $principal,
+                                     $lifetime = 1,
+                                     $exclusive = Horde_Lock::TYPE_SHARED);
+
+    /**
+     * Removes a lock given the lock ID.
+     * NOTE: No security checks are done in the Horde_Lock API.  It is
+     * expected that the calling application has done all necessary security
+     * checks before requesting a lock be cleared.
+     *
+     * @param string $lockid  The lock ID as generated by a previous call
+     *                        to setLock()
+     *
+     * @return boolean  Returns true on success.
+     * @throws Horde_Lock_Exception
+     */
+    abstract public function clearLock($lockid);
 }
diff --git a/framework/Lock/lib/Horde/Lock/Base.php b/framework/Lock/lib/Horde/Lock/Base.php
deleted file mode 100644 (file)
index b9b3e5a..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-<?php
-/**
- * The Horde_Lock_Base class defines the Horde_Lock driver API.
- *
- * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you did
- * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
- *
- * @author   Ben Klang <ben@alkaloid.net>
- * @category Horde
- * @package  Lock
- */
-abstract class Horde_Lock_Base
-{
-    /**
-     * Driver parameters.
-     *
-     * @var array
-     */
-    protected $_params;
-
-    /**
-     * Logger.
-     *
-     * @var Horde_Log_Logger
-     */
-    protected $_logger;
-
-    /**
-     * Constructor.
-     *
-     * @param array $params  Configuration parameters:
-     * <pre>
-     * 'logger' - (Horde_Log_Logger) A logger instance.
-     * </pre>
-     */
-    public function __construct($params = array())
-    {
-        if (!empty($params['logger'])) {
-            $this->_logger = $params['logger'];
-            unset($params['logger']);
-        }
-
-        $this->_params = $params;
-    }
-
-    /**
-     * Return an array of information about the requested lock.
-     *
-     * @param string $lockid  Lock ID to look up.
-     *
-     * @return array  Lock information.
-     * @throws Horde_Lock_Exception
-     */
-    abstract public function getLockInfo($lockid);
-
-    /**
-     * Return a list of valid locks with the option to limit the results
-     * by principal, scope and/or type.
-     *
-     * @param string $scope      The scope of the lock.  Typically the name of
-     *                           the application requesting the lock or some
-     *                           other identifier used to group locks together.
-     * @param string $principal  Principal for which to check for locks
-     * @param integer $type      Only return locks of the given type.
-     *                           Defaults to null, or all locks
-     *
-     * @return array  Array of locks with the ID as the key and the lock details
-     *                as the value. If there are no current locks this will
-     *                return an empty array.
-     * @throws Horde_Lock_Exception
-     */
-    abstract public function getLocks($scope = null, $principal = null,
-                                      $type = null);
-
-    /**
-     * Extend the valid lifetime of a valid lock to now + $extend.
-     *
-     * @param string $lockid   Lock ID to reset. Must be a valid, non-expired
-     *                         lock.
-     * @param integer $extend  Extend lock this many seconds from now.
-     *
-     * @return boolean  Returns true on success.
-     * @throws Horde_Lock_Exception
-     */
-    abstract public function resetLock($lockid, $extend);
-
-    /**
-     * Sets a lock on the requested principal and returns the generated lock
-     * ID. NOTE: No security checks are done in the Horde_Lock API. It is
-     * expected that the calling application has done all necessary security
-     * checks before requesting a lock be granted.
-     *
-     * @param string $requestor  User ID of the lock requestor.
-     * @param string $scope      The scope of the lock.  Typically the name of
-     *                           the application requesting the lock or some
-     *                           other identifier used to group locks
-     *                           together.
-     * @param string $principal  A principal on which a lock should be
-     *                           granted. The format can be any string but is
-     *                           suggested to be in URI form.
-     * @param integer $lifetime  Time (in seconds) for which the lock will be
-     *                           considered valid.
-     * @param string exclusive   One of Horde_Lock::TYPE_SHARED or
-     *                           Horde_Lock::TYPE_EXCLUSIVE.
-     *                           - An exclusive lock will be enforced strictly
-     *                             and must be interpreted to mean that the
-     *                             resource can not be modified. Only one
-     *                             exclusive lock per principal is allowed.
-     *                           - A shared lock is one that notifies other
-     *                             potential lock requestors that the resource
-     *                             is in use. This lock can be overridden
-     *                             (cleared or replaced with a subsequent
-     *                             call to setLock()) by other users. Multiple
-     *                             users may request (and will be granted) a
-     *                             shared lock on a given principal. All locks
-     *                             will be considered valid until they are
-     *                             cleared or expire.
-     *
-     * @return mixed   A string lock ID.
-     * @throws Horde_Lock_Exception
-     */
-    abstract public function setLock($requestor, $scope, $principal,
-                                     $lifetime = 1,
-                                     $exclusive = Horde_Lock::TYPE_SHARED);
-
-    /**
-     * Removes a lock given the lock ID.
-     * NOTE: No security checks are done in the Horde_Lock API.  It is
-     * expected that the calling application has done all necessary security
-     * checks before requesting a lock be cleared.
-     *
-     * @param string $lockid  The lock ID as generated by a previous call
-     *                        to setLock()
-     *
-     * @return boolean  Returns true on success.
-     * @throws Horde_Lock_Exception
-     */
-    abstract public function clearLock($lockid);
-
-}
index b180a84..a49e3c1 100644 (file)
@@ -11,7 +11,7 @@
  * @category Horde
  * @package  Lock
  */
-class Horde_Lock_Null extends Horde_Lock_Base
+class Horde_Lock_Null extends Horde_Lock
 {
     /**
      * Return an array of information about the requested lock.
index d874e8b..6e9479f 100644 (file)
  * );
  * </pre>
  *
- * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
+ * Copyright 2008-2010 Horde LLC (http://www.horde.org/)
  *
  * See the enclosed file COPYING for license information (LGPL). If you did
  * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
  *
- * @author   Ben Klang <ben@alkaloid.net>
+ * @author   Ben Klang <bklang@horde.org>
  * @category Horde
  * @package  Lock
  */
-class Horde_Lock_Sql extends Horde_Lock_Base
+class Horde_Lock_Sql extends Horde_Lock
 {
     /**
      * Handle for the current database connection.
index 0b3f464..acad2fa 100644 (file)
@@ -1,21 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<package packagerversion="1.4.9" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
-http://pear.php.net/dtd/tasks-1.0.xsd
-http://pear.php.net/dtd/package-2.0
-http://pear.php.net/dtd/package-2.0.xsd">
+<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
  <name>Lock</name>
  <channel>pear.horde.org</channel>
  <summary>Horde Resource Locking System</summary>
- <description>The Lock:: class provides the Horde resource locking system.
- </description>
+ <description>The Lock:: class provides the Horde resource locking system.</description>
  <lead>
   <name>Ben Klang</name>
   <user>bklang</user>
   <email>ben@alkaloid.net</email>
   <active>yes</active>
  </lead>
- <date>2008-05-05</date>
- <time>22:54:46</time>
+ <date>2010-10-02</date>
+ <time>21:09:53</time>
  <version>
   <release>0.0.1</release>
   <api>0.0.1</api>
@@ -25,23 +21,23 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <api>alpha</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Add Null driver.
+ <notes>
+* Add Null driver.
 * Initial release
  </notes>
  <contents>
<dir name="/">
 <dir baseinstalldir="/" name="/">
    <dir name="lib">
     <dir name="Horde">
      <dir name="Lock">
-      <file name="Base.php" role="php" />
       <file name="Exception.php" role="php" />
       <file name="Null.php" role="php" />
       <file name="Sql.php" role="php" />
-     </dir> <!-- /lib/Horde/Lock -->
+     </dir> <!-- //lib/Horde/Lock -->
      <file name="Lock.php" role="php" />
-    </dir> <!-- /lib/Horde -->
-  </dir> <!-- /lib -->
- </dir> <!-- / -->
+    </dir> <!-- //lib/Horde -->
+   </dir> <!-- //lib -->
 </dir> <!-- / -->
  </contents>
  <dependencies>
   <required>
@@ -80,11 +76,28 @@ http://pear.php.net/dtd/package-2.0.xsd">
  </dependencies>
  <phprelease>
   <filelist>
-   <install name="lib/Horde/Lock/Base.php" as="Horde/Lock/Base.php" />
-   <install name="lib/Horde/Lock/Exception.php" as="Horde/Lock/Exception.php" />
-   <install name="lib/Horde/Lock/Null.php" as="Horde/Lock/Null.php" />
-   <install name="lib/Horde/Lock/Sql.php" as="Horde/Lock/Sql.php" />
-   <install name="lib/Horde/Lock.php" as="Horde/Lock.php" />
+   <install as="Horde/Lock.php" name="lib/Horde/Lock.php" />
+   <install as="Horde/Lock/Exception.php" name="lib/Horde/Lock/Exception.php" />
+   <install as="Horde/Lock/Null.php" name="lib/Horde/Lock/Null.php" />
+   <install as="Horde/Lock/Sql.php" name="lib/Horde/Lock/Sql.php" />
   </filelist>
  </phprelease>
+ <changelog>
+  <release>
+   <version>
+    <release>0.0.1</release>
+    <api>0.0.1</api>
+   </version>
+   <stability>
+    <release>alpha</release>
+    <api>alpha</api>
+   </stability>
+   <date>2010-10-02</date>
+   <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
+   <notes>
+* Add Null driver.
+* Initial release
+   </notes>
+  </release>
+ </changelog>
 </package>