You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by wa...@apache.org on 2019/12/11 14:39:39 UTC
[dubbo-php-framework] 25/31: update
This is an automated email from the ASF dual-hosted git repository.
wangxin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-php-framework.git
commit 4f59f46d29f67d6400bcd2f2abd139d5cb2975bb
Author: wangjinxi <wa...@che001.com>
AuthorDate: Wed Jul 17 13:36:45 2019 +0800
update
---
common/protocol/fsof/DubboParser.php | 11 ++++++-----
consumer/Type.php | 32 +++++++++++++++++++++++++++++++-
2 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/common/protocol/fsof/DubboParser.php b/common/protocol/fsof/DubboParser.php
index b812fae..921e912 100644
--- a/common/protocol/fsof/DubboParser.php
+++ b/common/protocol/fsof/DubboParser.php
@@ -4,6 +4,7 @@ namespace com\fenqile\fsof\common\protocol\fsof;
use com\fenqile\fsof\consumer\Type;
use Icecave\Flax\Serialization\Encoder;
use Icecave\Flax\DubboParser as Decoder;
+use com\fenqile\fsof\consumer\ConsumerException;
/**
*
@@ -185,10 +186,10 @@ class DubboParser
} else if (self::DUBBO_PROTOCOL_SERIALIZE_HESSIAN2 == $response->getSerialization()) {
$this->parseResponseBodyForHessian2($response);
} else {
- throw new \Exception(sprintf('返回的序列化类型:(%s), 不支持解析!', $response->getSerialization()));
+ throw new ConsumerException(sprintf('返回的序列化类型:(%s), 不支持解析!', $response->getSerialization()));
}
} else {
- throw new \Exception($response->getFullData());
+ throw new ConsumerException($response->getFullData());
}
return $response;
}
@@ -210,11 +211,11 @@ class DubboParser
case self::RESPONSE_WITH_EXCEPTION:
$exception = json_decode($content, true);
if (is_array($exception) && array_key_exists('message', $exception)) {
- throw new \Exception($exception['message']);
+ throw new ConsumerException($exception['message']);
} else if (is_string($exception)) {
- throw new \Exception($exception);
+ throw new ConsumerException($exception);
} else {
- throw new \Exception("provider occur error");
+ throw new ConsumerException("provider occur error");
}
break;
default:
diff --git a/consumer/Type.php b/consumer/Type.php
index 3000d5b..673d507 100644
--- a/consumer/Type.php
+++ b/consumer/Type.php
@@ -13,6 +13,8 @@ class Type
const STRING = 6;
const BOOL = 7;
const BOOLEAN = 7;
+ const ARRAYLIST = 8;
+ const MAP = 9;
const adapter = [
Type::SHORT => 'S',
@@ -21,7 +23,9 @@ class Type
Type::FLOAT => 'F',
Type::DOUBLE => 'D',
Type::BOOLEAN => 'Z',
- Type::STRING => 'Ljava/lang/String;'
+ Type::STRING => 'Ljava/lang/String;',
+ Type::ARRAYLIST => 'Ljava/util/ArrayList;',
+ Type::MAP => 'Ljava/util/Map;'
];
public function __construct($type, $value)
@@ -130,6 +134,28 @@ class Type
}
/**
+ * Arraylist type
+ *
+ * @param arraylist $value
+ * @return Type
+ */
+ public static function arrayList($value)
+ {
+ return new self(self::ARRAYLIST, $value);
+ }
+
+ /**
+ * Map type
+ *
+ * @param map $value
+ * @return Type
+ */
+ public static function map($value)
+ {
+ return new self(self::MAP, $value);
+ }
+
+ /**
* Object type
*
* @param integer $value
@@ -176,6 +202,10 @@ class Type
case Type::BOOLEAN:
$value = (bool)$type->value;
break;
+ case Type::ARRAYLIST:
+ case Type::MAP:
+ $value = (array)$type->value;
+ break;
case Type::STRING:
default:
$value = (string)$type->value;