[xoops-cvslog 4396] CVS update: xoops2jp/html/kernel

Back to archive index

Minahito minah****@users*****
2006年 8月 30日 (水) 19:05:51 JST


Index: xoops2jp/html/kernel/XCube_Service.class.php
diff -u /dev/null xoops2jp/html/kernel/XCube_Service.class.php:1.1.2.1
--- /dev/null	Wed Aug 30 19:05:51 2006
+++ xoops2jp/html/kernel/XCube_Service.class.php	Wed Aug 30 19:05:51 2006
@@ -0,0 +1,171 @@
+<?php
+/**
+ * @package XCube
+ * @version $Id: XCube_Service.class.php,v 1.1.2.1 2006/08/30 10:05:51 minahito Exp $
+ */
+
+/**
+ * MACRO.
+ */
+function S_PUBLIC_FUNC($definition)
+{
+	$ret = null;
+	
+	$pos = strpos($definition, '(');
+	if ($pos > 0) {
+		$func_nameArr = explode(' ', substr($definition, 0, $pos));
+		$func_paramArr = explode(',', substr($definition, $pos + 1, -1));
+		$params = array();
+		foreach ($func_paramArr as $t_param) {
+			$t_str = explode(' ', trim($t_param));
+			$params[trim($t_str[1])] = trim($t_str[0]);
+		}
+		
+		$ret = array();
+		$ret['name'] = trim($func_nameArr[1]);
+		$ret['in'] = $params;
+		$ret['out'] = trim($func_nameArr[0]);
+	}
+	
+	return $ret;
+}
+
+/**
+ * This class is a collection for functions.
+ */
+class XCube_Service
+{
+	/**
+	 * @var string
+	 */
+	var $mServiceName = "";
+	
+	/**
+	 * @var string
+	 */
+	var $mNameSpace = "";
+	
+	/**
+	 * A name of this class for PHP4.
+	 * @var string
+	 */
+	var $mClassName = "XCube_Service";
+	
+	/**
+	 * @var XCube_ActionStrategy
+	 */
+	var $_mActionStrategy = null;
+	
+	var $_mTypes = array();
+	
+	var $_mFunctions = array();
+	
+	function XCube_Service()
+	{
+	}
+	
+	function prepare()
+	{
+	}
+	
+	function addType($className)
+	{
+		$this->_mTypes[] = $className;
+	}
+	
+	function addFunction()
+	{
+		$args = func_get_args();
+		if (func_num_args() == 3) {
+			$this->_addFunctionStandard($args[0], $args[1], $args[2]);
+		}
+		elseif (func_num_args() == 1 && is_array($args[0])) {
+			$this->_addFunctionStandard($args[0]['name'], $args[0]['in'], $args[0]['out']);
+		}
+	}
+	
+	function _addFunctionStandard($name, $in, $out)
+	{
+		$this->_mFunctions[$name] = array(
+			'out' => $out,
+			'name' => $name,
+			'in' => $in
+		);
+	}
+
+	/**
+	 * @var   string          $name
+	 * @param XCube_Procedure $procedure
+	 */	
+	function register($name, &$procedure)
+	{
+	}
+}
+
+/**
+ * *An experiment class*
+ * This class is the adapter of a service class.
+ * I give a caller the interface that resembled NUSOAP.
+ */
+class XCube_AbstractServiceClient
+{
+	var $mService;
+	var $mClientErrorStr;
+	
+	var $mUser = null;
+	
+	function XCube_AbstractServiceClient(&$service)
+	{
+		$this->mService =& $service;
+	}
+	
+	function prepare()
+	{
+	}
+	
+	function setUser(&$user)
+	{
+		$this->mUser =& $user;
+	}
+
+	function call()
+	{
+	}
+	
+	function getOperationData($operation)
+	{
+	}
+
+	function setError($message)
+	{
+		$this->mClientErrorStr=$message;
+	}
+
+	function getError()
+	{
+		return !empty($this->mClientErrorStr) ? $this->mClientErrorStr : $this->mService->mErrorStr;
+	}
+}
+
+class XCube_ServiceClient extends XCube_AbstractServiceClient
+{
+	function call($operation, $params)
+	{
+		$this->mClientErrorStr = null;
+		
+		if(!is_object($this->mService)) {
+			$this->mClientErrorStr = "This instance is not connected to service";
+			return null;
+		}
+		
+		if (isset($this->mService->_mFunctions[$operation])) {
+			return call_user_func_array(array($this->mService, $operation), array($this->mUser, $params));
+		}
+		else {
+			$this->mClientErrorStr = "operation $operation not present.";
+			return null;
+		}
+	}
+}
+
+?>
\ No newline at end of file
Index: xoops2jp/html/kernel/XCube_Object.class.php
diff -u /dev/null xoops2jp/html/kernel/XCube_Object.class.php:1.1.2.1
--- /dev/null	Wed Aug 30 19:05:51 2006
+++ xoops2jp/html/kernel/XCube_Object.class.php	Wed Aug 30 19:05:51 2006
@@ -0,0 +1,29 @@
+<?php
+
+function S_PUBLIC_VAR($definition)
+{
+	$t_str = explode(' ', trim($definition));
+	return array('name' => trim($t_str[1]), 'type' => trim($t_str[0]));
+}
+
+class XCube_Object
+{
+	/**
+	 * Member property
+	 */
+	var $mProperty = array();
+	
+	/**
+	 * Return member property information. This member function is called in
+	 * the initialize of object and service. This member function has to be
+	 * a static function.
+	 *
+	 * @static
+	 * @return array
+	 */
+	function getPropertyDefinition()
+	{
+	}
+}
+
+?>
\ No newline at end of file
Index: xoops2jp/html/kernel/XCube_ServiceManager.class.php
diff -u /dev/null xoops2jp/html/kernel/XCube_ServiceManager.class.php:1.1.2.1
--- /dev/null	Wed Aug 30 19:05:51 2006
+++ xoops2jp/html/kernel/XCube_ServiceManager.class.php	Wed Aug 30 19:05:51 2006
@@ -0,0 +1,158 @@
+<?php
+/**
+ * @package XCube
+ * @version $Id: XCube_ServiceManager.class.php,v 1.1.2.1 2006/08/30 10:05:51 minahito Exp $
+ */
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+
+require_once XOOPS_ROOT_PATH . "/kernel/XCube_Delegate.class.php";
+
+class XCube_ServiceUtils
+{
+	function isXSD($typeName)
+	{
+		if ($typeName == 'string' || $typeName == 'int') {
+			return true;
+		}
+		
+		return false;
+	}
+}
+
+/**
+ * This class manages XCube_Service instances, searches these, creates a much
+ * client instance. Now, the purpose of this class is for inside of own XOOPS
+ * site. In other words, this class doesn't work for publishing web services.
+ * About these separated working, the core team shall examine.
+ * 
+ * XCube namespace can't contain the SOAP library directly. Delegate mechanism
+ * is good for this class. This class creates a client instance which to
+ * connect to a service, with following the kind of the service. For example, 
+ * if the specified service is really web service, SOAP client has to be
+ * created. But, if the service is a virtual service of XCube, virtual client
+ * has to be created.
+ */
+class XCube_ServiceManager
+{
+	/**
+	 * Array of XCube_Service instances.
+	 * 
+	 * @var Array
+	 */
+	var $mServices = array();
+	
+	/**
+	 * @var XCube_Delegate
+	 * @param &$client
+	 * @param $service
+	 */
+	var $mCreateClient = null;
+	
+	/**
+	 * @var XCube_Delegate
+	 */
+	var $mCreateServer = null;
+	
+	function XCube_ServiceManager()
+	{
+		$this->mCreateClient =& new XCube_Delegate();
+		$this->mCreateClient->register("XCube_ServiceManager.CreateClient");
+		
+		$this->mCreateServer =& new XCube_Delegate();
+		$this->mCreateServer->register("XCube_ServiceManager.CreateServer");
+	}
+	
+	/**
+	 * Add service object. $name must be unique in the list of service. If the 
+	 * service which has the same name, is a member of the list, return false.
+	 * 
+	 * @param $name string
+	 * @param $service XCube_Service
+	 * @return bool
+	 */
+	function addService($name, &$service)
+	{
+		if (isset($this->mServices[$name])) {
+			return false;
+		}
+		
+		$this->mServices[$name] =& $service;
+		
+		return true;
+	}
+
+	/**
+	 * Add WSDL URL. $name must be unique in the list of service. If the
+	 * service which has the same name, is a member of the list, return false.
+	 * 
+	 */	
+	function addWSDL($name, $url)
+	{
+		if (isset($this->mServices[$name])) {
+			return false;
+		}
+		
+		$this->mServices[$name] =& $url;
+		
+		return true;
+	}
+	
+	/**
+	 * This member function will be removed at beta version.
+	 * 
+	 * @deprecated
+	 * @see XCube_ServiceManager::addService()
+	 */
+	function addXCubeService($name, &$service)
+	{
+		return $this->addService($name, $service);
+	}
+	
+	function &getService($name)
+	{
+		$ret = null;
+
+		if (isset($this->mServices[$name])) {
+			return $this->mServices[$name];
+		}
+
+		return $ret;
+	}
+	
+	/**
+	 * This member function will be removed at beta version.
+	 * 
+	 * @deprecated
+	 * @see XCube_ServiceManager::getService()
+	 */
+	function &searchXCubeService($name)
+	{
+		return $this->getService($name);
+	}
+
+	/**
+	 * Create client instance which to connect to a service, with following the
+	 * kind of the service. Then return that instance. For example, if the
+	 * specified service is really web service, SOAP client has to be created.
+	 * But, if the service is a virtual service of XCube, virtual client has to
+	 * be created.
+	 */
+	function &createClient(&$service)
+	{
+		$client = null;
+		$this->mCreateClient->call(new XCube_Ref($client), new XCube_Ref($service));
+		
+		return $client;
+	}
+	
+	function &createServer(&$service)
+	{
+		$server = null;
+		$this->mCreateServer->call(new XCube_Ref($server), new XCube_Ref($service));
+		
+		return $server;
+	}
+}
+
+?>
\ No newline at end of file


xoops-cvslog メーリングリストの案内
Back to archive index