Skip to content
Permalink
Browse files
improve: rename time_util,list_util
  • Loading branch information
DLive committed May 24, 2019
1 parent ebcb929 commit ae887cf0cb18d6aa9e3e25f6ba363232ca9aa4be
Showing 15 changed files with 25 additions and 25 deletions.
@@ -216,7 +216,7 @@ encode(object, Input, State) when is_record(Input, object) ->
encode(class_object,Input,State)->
[NativeType|Values] = tuple_to_list(Input),
{ClassEncodingBin, EncodedRef, NewState} =
case type_encoding:visit(NativeType,State) of
case dubbo_type_encoding:visit(NativeType,State) of
{ref, Ref} ->
%% encode_object(type_information, {ref, Ref}, State);
%% todo need check
@@ -14,7 +14,7 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%------------------------------------------------------------------------------
-module(java_type_defined).
-module(dubbo_java_type_defined).
-include("java_type.hrl").
%% API
-export([get_list/0]).
@@ -14,7 +14,7 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%------------------------------------------------------------------------------
-module(lists_util).
-module(dubbo_lists_util).
%% API
-export([join/2, del_duplicate/1]).

@@ -96,7 +96,7 @@ gen_provider_parameter(Providerconfig) ->
{<<"executes">>, integer_to_binary(Providerconfig#provider_config.executes)},
{<<"methods">>, Method2},
{<<"side">>, Providerconfig#provider_config.side},
{<<"timestamp">>, integer_to_binary(time_util:timestamp_ms())}
{<<"timestamp">>, integer_to_binary(dubbo_time_util:timestamp_ms())}
],
List2 = [io_lib:format("~ts=~ts", [Key, Value]) || {Key, Value} <- List],
lists:flatten(string:join(List2, "&")).
@@ -261,7 +261,7 @@ string_encode(Data) when is_tuple(Data) ->
[Name | _] = tuple_to_list(Data),
%% Size = record_info(size, Name),
%% Fields = record_info(fields, Name),
case type_register:lookup_native_type(Name) of
case dubbo_type_register:lookup_native_type(Name) of
undefined ->
<<"data encode error">>;
#type_def{fieldnames = Fields, foreign_type = _ForeignType} ->
@@ -14,7 +14,7 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%------------------------------------------------------------------------------
-module(time_util).
-module(dubbo_time_util).

-include_lib("kernel/include/file.hrl").

@@ -14,7 +14,7 @@
% limitations under the License.
% ---------------------------------------------------------------------------

-module(type_decoding).
-module(dubbo_type_decoding).
-include("hessian.hrl").

%% The encoding state contains all of the statically known tuple types.
@@ -14,7 +14,7 @@
% limitations under the License.
% ---------------------------------------------------------------------------

-module(type_encoding).
-module(dubbo_type_encoding).

-include("hessian.hrl").

@@ -88,4 +88,4 @@ assign_reference(TypeDef = #type_def{native_type = Key},
{NewCount, NewTypeDef, #encoding_state{pool = NewPool, count = NewCount}}.

get_deftype_public_pool(NativeType) ->
type_register:lookup_native_type(NativeType).
dubbo_type_register:lookup_native_type(NativeType).
@@ -14,7 +14,7 @@
% limitations under the License.
% ---------------------------------------------------------------------------

-module(type_register).
-module(dubbo_type_register).
%% API
-export([init/0, regiest_foreign_native/1, lookup_foreign_type/1, lookup_native_type/1]).
-include("hessian.hrl").
@@ -47,7 +47,7 @@ java_to_native(Data, _) ->

get_deftype(ForeignType) ->

case type_register:lookup_foreign_type(ForeignType) of
case dubbo_type_register:lookup_foreign_type(ForeignType) of
undefined ->
logger:debug("get deftype undefined ~p", [ForeignType]),
false;
@@ -62,15 +62,15 @@ get_deftype(ForeignType) ->
pre_process_typedef(NativeType, ForeignType, FieldsNames) ->
Type = #type_def{native_type = NativeType, foreign_type = ForeignType, fieldnames = FieldsNames},
%% Type2=type_decoding:hash_store(Type),
type_register:regiest_foreign_native(Type),
dubbo_type_register:regiest_foreign_native(Type),
logger:debug("pre_process_typedef ~p,~p", [NativeType, ForeignType]),
ok.


jsonobj_to_native(Type, JsonObj, State) ->
ClassName = java_desc_name_to_dot(Type),
%% todo need recursion transfer
case type_register:lookup_foreign_type(ClassName) of
case dubbo_type_register:lookup_foreign_type(ClassName) of
undefined ->
JsonObj;
#type_def{fieldnames = Fields, native_type = NativeType} ->
@@ -254,7 +254,7 @@ check_and_create_path(Pid, RootPath, [{Item, CreateType} | Rst]) ->

gen_consumer_node_info(Consumer) ->
%% revision参数字段的作用是什么? 暂时不添加
Methods = lists_util:join(Consumer#consumer_config.methods, <<",">>),
Methods = dubbo_lists_util:join(Consumer#consumer_config.methods, <<",">>),
Value = io_lib:format(<<"consumer://~s/~s?application=~s&category=~s&check=~p&default.timeout=~p&dubbo=~s&interface=~s&methods=~s&side=~s&timestamp=~p">>,
[dubbo_common_fun:local_ip_v4_str(),
Consumer#consumer_config.interface,
@@ -266,7 +266,7 @@ gen_consumer_node_info(Consumer) ->
Consumer#consumer_config.interface,
Methods,
Consumer#consumer_config.side,
time_util:timestamp_ms()
dubbo_time_util:timestamp_ms()
]),
list_to_binary(Value).

@@ -41,13 +41,13 @@ stop(_State) ->
env_init() ->
ets:new(?PROVIDER_IMPL_TABLE, [public, named_table]),
dubbo_traffic_control:init(),
type_register:init(),
dubbo_type_register:init(),
register_type_list().
%% type_decoding:init().


register_type_list() ->
List = java_type_defined:get_list(),
List = dubbo_java_type_defined:get_list(),
lists:map(
fun({NativeType, ForeignType, Fields}) ->
dubbo_type_transfer:pre_process_typedef(NativeType, ForeignType, Fields)
@@ -23,16 +23,16 @@ request_gen_test() ->
?assert(is_integer(Id)).

string_join_test() ->
Result1 = lists_util:join([<<"a">>, <<"b">>], <<",">>),
Result1 = dubbo_lists_util:join([<<"a">>, <<"b">>], <<",">>),
?assertEqual(Result1, <<"a,b">>),

Result2 = lists_util:join([], <<",">>),
Result2 = dubbo_lists_util:join([], <<",">>),
?assertEqual(Result2, <<"">>),

Result3 = lists_util:join([<<"a">>, "b", ttt], <<",">>),
Result3 = dubbo_lists_util:join([<<"a">>, "b", ttt], <<",">>),
?assertEqual(Result3, <<"a,b">>),
ok.

list_dup_test() ->
R = lists_util:del_duplicate([a, b, a]),
R = dubbo_lists_util:del_duplicate([a, b, a]),
?assertEqual(length(R), 2).
@@ -17,9 +17,9 @@
-module(dubbo_service_user_impl).


-behaviour(user2).
-behaviour(userOperator).

-include_lib("dubbo_service.hrl").
-include_lib("dubbo_sample_service.hrl").
-include_lib("dubboerl/include/hessian.hrl").
-include_lib("dubboerl/include/dubbo.hrl").
%% API
@@ -28,12 +28,12 @@ object_test() ->
TypeDefA = #type_def{foreign_type = ForeignTypeA,
native_type = de_TestReq,
fieldnames = record_info(fields, de_TestReq)},
EncodingState0 = type_encoding:enlist(TypeDefA),
EncodingState0 = dubbo_type_encoding:enlist(TypeDefA),
RequestArg0 = #de_TestReq{name = <<"nameinfo">>, nick = <<"nickname">>, age = 10},

{Bin, State0} = cotton_hessian:encode(RequestArg0, EncodingState0),

type_register:init(),
dubbo_type_register:init(),
dubbo_type_transfer:pre_process_typedef(de_TestReq, <<"com.ifcoder.demo.bean.UserInfoRequest">>, record_info(fields, de_TestReq)),
{<<>>, Data, State2} = cotton_hessian:decode(Bin, cotton_hessian:init()),
DecodeResult = dubbo_type_transfer:java_to_native(Data, State2),

0 comments on commit ae887cf

Please sign in to comment.