/** * Serve a request * @param boolean send headers * @return boolean FALSE if failed (invalid request - see errors) * @access public */ function serve($sendHeaders = TRUE) { require_once JPSPAN . 'Monitor.php'; $M =& JPSpan_Monitor::instance(); $this->calledClass = NULL; $this->calledMethod = NULL; if ($_SERVER['REQUEST_METHOD'] != 'POST') { trigger_error('Invalid HTTP request method: ' . $_SERVER['REQUEST_METHOD'], E_USER_ERROR); return FALSE; } if ($this->resolveCall()) { $M->setRequestInfo('class', $this->calledClass); $M->setRequestInfo('method', $this->calledMethod); if (FALSE !== ($Handler =& $this->getHandler($this->calledClass))) { $args = array(); $M->setRequestInfo('args', $args); if ($this->getArgs($args)) { $M->setRequestInfo('args', $args); $response = call_user_func_array(array(&$Handler, $this->calledMethod), $args); } else { $response = call_user_func(array(&$Handler, $this->calledMethod)); } require_once JPSPAN . 'Serializer.php'; $M->setResponseInfo('payload', $response); $M->announceSuccess(); $response = JPSpan_Serializer::serialize($response); if ($sendHeaders) { header('Content-Length: ' . strlen($response)); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . 'GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); } echo $response; return TRUE; } else { trigger_error('Invalid handle for: ' . $this->calledClass, E_USER_ERROR); return FALSE; } } return FALSE; }
/** * Called from setValue. Sets the value of all children of * an object * @param mixed value * @return void * @access protected */ function setChildValues($value) { $properties = get_object_vars($value); foreach (array_keys($properties) as $property) { $this->children[$property] =& JPSpan_Serializer::reflect($value->{$property}); } }