Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generic#invoke (go to java) #122

Merged
merged 34 commits into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
22498ac
Merge pull request #1 from apache/master
pantianying Jul 4, 2019
47c4d20
Merge pull request #2 from apache/develop
pantianying Jul 4, 2019
9751266
add go to java generic
pantianying Jul 4, 2019
6cde06a
fix test
pantianying Jul 4, 2019
25b1512
update
pantianying Jul 4, 2019
e216bcb
优化
pantianying Jul 5, 2019
2cf9399
改成和java一样的使用方式
pantianying Jul 5, 2019
4df2f94
fix
pantianying Jul 5, 2019
e545dd0
add license
pantianying Jul 5, 2019
48073dd
change file name
pantianying Jul 5, 2019
5e0ebf7
fix、and jsonrpc has no genericComsumer
pantianying Jul 5, 2019
79775de
Merge pull request #3 from apache/develop
pantianying Jul 10, 2019
0b111a5
Merge pull request #5 from apache/develop
pantianying Jul 15, 2019
4dbeb2a
fix bug with Temporary disposal
pantianying Jul 15, 2019
7f00a83
Merge branch 'master' of https://github.com/pantianying/dubbo-go
pantianying Jul 15, 2019
09b9130
update
pantianying Jul 16, 2019
81b8c35
change annotation
pantianying Jul 17, 2019
96f5554
add generic filter
pantianying Jul 30, 2019
e9d7d86
Merge remote-tracking branch 'apache/develop'
pantianying Jul 30, 2019
74e16bb
add ut
pantianying Jul 30, 2019
428fad4
ut be compatible with go 1.11
pantianying Jul 30, 2019
31c898f
add Generic tag
pantianying Jul 31, 2019
d77c8e3
Merge branch 'develop' into master
pantianying Jul 31, 2019
6e5df6c
fix
pantianying Jul 31, 2019
a1e9a4d
fix fmt
pantianying Jul 31, 2019
068983b
add generic config.Load support
pantianying Aug 2, 2019
c3d2c9c
fix bug
pantianying Aug 2, 2019
754252b
add hessain.Object to genericfilter
pantianying Aug 2, 2019
d7be686
add support
pantianying Aug 2, 2019
4271bcc
fix
pantianying Aug 2, 2019
1faca0c
generic filter add slice support
pantianying Aug 3, 2019
cd1d707
change code style
pantianying Aug 3, 2019
57cbc46
fix code
pantianying Aug 5, 2019
0c6e36c
fix bug
pantianying Aug 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/general/dubbo/go-client/app/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func test3() {

time.Sleep(3 * time.Second)
println("\n\n\nstart to generic invoke")
resp, err := referenceConfig.GetRPCService().(*config.GenericService).Invoke([]interface{}{"GetUser", []string{"java.lang.String"}, []hessian.Object{"A003"}})
resp, err := referenceConfig.GetRPCService().(*config.GenericService).Invoke([]interface{}{"GetUser", []string{"java.lang.String"}, "A003"})
pantianying marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
panic(err)
}
Expand Down
19 changes: 14 additions & 5 deletions filter/impl/generic_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package impl

import (
hessian "github.com/apache/dubbo-go-hessian2"
pantianying marked this conversation as resolved.
Show resolved Hide resolved
"reflect"
"strings"
)
Expand All @@ -42,10 +43,14 @@ func init() {
type GenericFilter struct{}

func (ef *GenericFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
if invocation.MethodName() == constant.GENERIC {
var newArguments = invocation.Arguments()
for i := range newArguments {
newArguments[i] = struct2MapAll(newArguments[i])
if invocation.MethodName() == constant.GENERIC && len(invocation.Arguments()) == 3 {
var (
oldArguments = invocation.Arguments()
)
newArguments := []interface{}{
oldArguments[0],
oldArguments[1],
hessian.Object(struct2MapAll(oldArguments[2])),
}
newInvocation := invocation2.NewRPCInvocation(invocation.MethodName(), newArguments, invocation.Attachments())
return invoker.Invoke(newInvocation)
Expand All @@ -61,9 +66,13 @@ func GetGenericFilter() filter.Filter {
return &GenericFilter{}
}
func struct2MapAll(obj interface{}) map[string]interface{} {
result := make(map[string]interface{})
if obj == nil {
return result
}
t := reflect.TypeOf(obj)
v := reflect.ValueOf(obj)
result := make(map[string]interface{})

if reflect.TypeOf(obj).Kind() == reflect.Struct {
for i := 0; i < t.NumField(); i++ {
if v.Field(i).Kind() == reflect.Struct {
Expand Down