|
|
@@ -63,10 +63,10 @@ class Zend_Amf_Server implements Zend_Server_Interface
|
|
|
protected $_methods = array();
|
|
|
|
|
|
/**
|
|
|
- * Array of directories to search for loading classes dynamically
|
|
|
- * @var array
|
|
|
+ * Loader for classes in added directories
|
|
|
+ * @var Zend_Loader_PluginLoader
|
|
|
*/
|
|
|
- protected $_directories = array();
|
|
|
+ protected $_loader;
|
|
|
|
|
|
/**
|
|
|
* @var bool Production flag; whether or not to return exception messages
|
|
|
@@ -261,6 +261,20 @@ class Zend_Amf_Server implements Zend_Server_Interface
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Get PluginLoader for the Server
|
|
|
+ *
|
|
|
+ * @return Zend_Loader_PluginLoader
|
|
|
+ */
|
|
|
+ protected function getLoader()
|
|
|
+ {
|
|
|
+ if(empty($this->_loader)) {
|
|
|
+ require_once 'Zend/Loader/PluginLoader.php';
|
|
|
+ $this->_loader = new Zend_Loader_PluginLoader();
|
|
|
+ }
|
|
|
+ return $this->_loader;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Loads a remote class or method and executes the function and returns
|
|
|
* the result
|
|
|
*
|
|
|
@@ -281,19 +295,9 @@ class Zend_Amf_Server implements Zend_Server_Interface
|
|
|
if (!isset($this->_table[$qualifiedName])) {
|
|
|
// if source is null a method that was not defined was called.
|
|
|
if ($source) {
|
|
|
- $classPath = array();
|
|
|
- $path = explode('.', $source);
|
|
|
- $className = array_pop($path);
|
|
|
- $uriclasspath = implode('/', $path);
|
|
|
-
|
|
|
- // Take the user supplied directories and add the unique service path to the end.
|
|
|
- foreach ($this->_directories as $dir) {
|
|
|
- $classPath[] = $dir . $uriclasspath;
|
|
|
- }
|
|
|
-
|
|
|
- require_once('Zend/Loader.php');
|
|
|
+ $className = str_replace(".", "_", $source);
|
|
|
try {
|
|
|
- Zend_Loader::loadClass($className, $classPath);
|
|
|
+ $this->getLoader()->load($className);
|
|
|
} catch (Exception $e) {
|
|
|
require_once 'Zend/Amf/Server/Exception.php';
|
|
|
throw new Zend_Amf_Server_Exception('Class "' . $className . '" does not exist');
|
|
|
@@ -358,7 +362,8 @@ class Zend_Amf_Server implements Zend_Server_Interface
|
|
|
{
|
|
|
require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
|
|
|
switch($message->operation) {
|
|
|
- case Zend_Amf_Value_Messaging_CommandMessage::CLIENT_PING_OPERATION :
|
|
|
+ case Zend_Amf_Value_Messaging_CommandMessage::DISCONNECT_OPERATION :
|
|
|
+ case Zend_Amf_Value_Messaging_CommandMessage::CLIENT_PING_OPERATION :
|
|
|
$return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
|
|
|
break;
|
|
|
case Zend_Amf_Value_Messaging_CommandMessage::LOGIN_OPERATION :
|
|
|
@@ -772,12 +777,13 @@ class Zend_Amf_Server implements Zend_Server_Interface
|
|
|
|
|
|
/**
|
|
|
* Creates an array of directories in which services can reside.
|
|
|
- *
|
|
|
+ * TODO: add support for prefixes?
|
|
|
+ *
|
|
|
* @param string $dir
|
|
|
*/
|
|
|
public function addDirectory($dir)
|
|
|
{
|
|
|
- $this->_directories[] = $dir;
|
|
|
+ $this->getLoader()->addPrefixPath("", $dir);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -787,7 +793,7 @@ class Zend_Amf_Server implements Zend_Server_Interface
|
|
|
*/
|
|
|
public function getDirectory()
|
|
|
{
|
|
|
- return $this->_directories;
|
|
|
+ return $this->getLoader()->getPaths("");
|
|
|
}
|
|
|
|
|
|
/**
|