2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4 // +----------------------------------------------------------------------+
5 // | Akelos Framework - http://www.akelos.org |
6 // +----------------------------------------------------------------------+
7 // | Copyright (c) 2002-2006, Akelos Media, S.L. & Bermi Ferrer Martinez |
8 // | Released under the GNU Lesser General Public License, see LICENSE.txt|
9 // +----------------------------------------------------------------------+
12 * @package ActionWebservice
14 * @author Bermi Ferrer <bermi a.t akelos c.om>
15 * @copyright Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
16 * @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html>
19 class AkActionWebServiceServer
extends AkObject
21 var $_available_drivers = array('xml_rpc');
23 var $_services = array();
25 function __construct($server_driver)
27 $server_driver = AkInflector
::underscore($server_driver);
28 if(in_array($server_driver, $this->_available_drivers
)){
29 $server_class_name = 'Ak'.AkInflector
::camelize($server_driver).'Server';
30 require_once(AK_LIB_DIR
.DS
.'AkActionWebService'.DS
.'Servers'.DS
.$server_class_name.'.php');
32 $this->_Server
=& new $server_class_name($this);
35 trigger_error(Ak
::t('Invalid Web Service driver provided. Available Drivers are: %drivers', array('%drivers'=>join(', ',$this->_available_drivers
))), E_USER_WARNING
);
39 function addService($service)
41 $service_file = AkInflector
::underscore($service);
42 if(substr($service_file,-8) != '_service'){
43 $service_file = $service_file.'_service';
45 $service_model = AkInflector
::camelize($service_file);
46 $service_name_space = substr($service_file,0,-8);
48 if(empty($this->_services
[$service_name_space])){
50 require_once(AK_MODELS_DIR
.DS
.$service_file.'.php');
52 if(!class_exists($service_model)){
53 trigger_error(Ak
::t('Could not find class for the service %service at %models_dir', array('%service'=>$service_model, '%models_dir' => AK_MODELS_DIR
), E_USER_ERROR
));
56 $this->_services
[$service_name_space] =& new $service_model();
62 if(method_exists($this->_Server
, 'init')){
63 $args = func_get_args();
64 call_user_func_array(array(&$this->_Server
, 'init'), $args);
70 $this->_Server
->serve();