|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Cloud |
|
17 * @subpackage QueueService |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 */ |
|
21 |
|
22 require_once 'Zend/Cloud/AbstractFactory.php'; |
|
23 |
|
24 /** |
|
25 * @category Zend |
|
26 * @package Zend_Cloud |
|
27 * @subpackage QueueService |
|
28 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
29 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
30 */ |
|
31 class Zend_Cloud_QueueService_Factory extends Zend_Cloud_AbstractFactory |
|
32 { |
|
33 const QUEUE_ADAPTER_KEY = 'queue_adapter'; |
|
34 |
|
35 /** |
|
36 * @var string Interface which adapter must implement to be considered valid |
|
37 */ |
|
38 protected static $_adapterInterface = 'Zend_Cloud_QueueService_Adapter'; |
|
39 |
|
40 /** |
|
41 * Constructor |
|
42 * |
|
43 * @return void |
|
44 */ |
|
45 private function __construct() |
|
46 { |
|
47 // private ctor - should not be used |
|
48 } |
|
49 |
|
50 /** |
|
51 * Retrieve QueueService adapter |
|
52 * |
|
53 * @param array $options |
|
54 * @return void |
|
55 */ |
|
56 public static function getAdapter($options = array()) |
|
57 { |
|
58 $adapter = parent::_getAdapter(self::QUEUE_ADAPTER_KEY, $options); |
|
59 if (!$adapter) { |
|
60 require_once 'Zend/Cloud/QueueService/Exception.php'; |
|
61 throw new Zend_Cloud_QueueService_Exception('Class must be specified using the \'' . |
|
62 self::QUEUE_ADAPTER_KEY . '\' key'); |
|
63 } elseif (!$adapter instanceof self::$_adapterInterface) { |
|
64 require_once 'Zend/Cloud/QueueService/Exception.php'; |
|
65 throw new Zend_Cloud_QueueService_Exception( |
|
66 'Adapter must implement \'' . self::$_adapterInterface . '\'' |
|
67 ); |
|
68 } |
|
69 return $adapter; |
|
70 } |
|
71 } |