diff options
author | Brion Vibber <brion@pobox.com> | 2010-01-14 00:19:25 -0800 |
---|---|---|
committer | Brion Vibber <brion@status.net> | 2010-01-14 13:21:48 -0800 |
commit | 7211896b2f64707ac2755d81bb774fba823552c4 (patch) | |
tree | 35e4d0a90aea76f18710f8e8903bda6fe005e78c /lib/stompqueuemanager.php | |
parent | e8abb0c2ed7219dbcca4e879db36584c3d026bc0 (diff) |
Keep handler registration per-site to fix queue registration in mixed config environment
Diffstat (limited to 'lib/stompqueuemanager.php')
-rw-r--r-- | lib/stompqueuemanager.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php index 3090e0bfb..a7d735d1c 100644 --- a/lib/stompqueuemanager.php +++ b/lib/stompqueuemanager.php @@ -66,10 +66,57 @@ class StompQueueManager extends QueueManager * * @fixme possibly actually do subscription here to save another * loop over all sites later? + * @fixme possibly don't assume it's the current site */ public function addSite($server) { $this->sites[] = $server; + $this->initialize(); + } + + + /** + * Instantiate the appropriate QueueHandler class for the given queue. + * + * @param string $queue + * @return mixed QueueHandler or null + */ + function getHandler($queue) + { + $handlers = $this->handlers[common_config('site', 'server')]; + if (isset($handlers[$queue])) { + $class = $handlers[$queue]; + if (class_exists($class)) { + return new $class(); + } else { + common_log(LOG_ERR, "Nonexistent handler class '$class' for queue '$queue'"); + } + } else { + common_log(LOG_ERR, "Requested handler for unkown queue '$queue'"); + } + return null; + } + + /** + * Get a list of all registered queue transport names. + * + * @return array of strings + */ + function getQueues() + { + return array_keys($this->handlers[common_config('site', 'server')]); + } + + /** + * Register a queue transport name and handler class for your plugin. + * Only registered transports will be reliably picked up! + * + * @param string $transport + * @param string $class + */ + public function connect($transport, $class) + { + $this->handlers[common_config('site', 'server')][$transport] = $class; } /** |