-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Skip serialization of jvm invocation in ark #370
Changes from 15 commits
4984964
d5c82e4
86b885e
c36ae52
24c893c
5a74e09
b43a63e
ca4c93b
96abe95
e787335
5f3ecd6
bc823be
b67c2f3
bd4272e
11be85c
f190434
f2ec0e8
052d946
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,10 @@ | |
<xsd:attribute name="registry" type="xsd:string" use="optional"/> | ||
<xsd:attribute name="serialize-type" type="xsd:string" use="optional"/> | ||
</xsd:complexType> | ||
<!-- binding.jvm im reference --> | ||
<xsd:complexType name="BBindingJvmReference"> | ||
<xsd:attribute name="serialize" type="xsd:boolean" default="false" use="optional"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个为啥默认是false There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reference 默认不走序列化,service 默认走序列化. 只有两者都为 false 是,才会走直接调用模式。 服务端如果设置不走序列化,需要将相关类导出,而客户端无需变更代码。 只有当引用服务的应用配置了 deny-import 相关类,此时,客户端可能需要强制设置走序列化方式. |
||
</xsd:complexType> | ||
<!-- binding.bolt in reference --> | ||
<xsd:complexType name="BBindingTRReference"> | ||
<xsd:complexContent> | ||
|
@@ -141,6 +145,10 @@ | |
</xsd:extension> | ||
</xsd:complexContent> | ||
</xsd:complexType> | ||
<!--jvm service--> | ||
<xsd:complexType name="BBindingJvmService"> | ||
<xsd:attribute name="serialize" type="xsd:boolean" default="true" use="optional"/> | ||
</xsd:complexType> | ||
<!-- binding.bolt in service --> | ||
<xsd:complexType name="BBindingTRService"> | ||
<xsd:complexContent> | ||
|
@@ -567,7 +575,7 @@ | |
<xsd:complexContent> | ||
<xsd:extension base="beans:identifiedType"> | ||
<xsd:all minOccurs="0" maxOccurs="1"> | ||
<xsd:element name="binding.jvm" minOccurs="0"/> | ||
<xsd:element name="binding.jvm" type="BBindingJvmReference" minOccurs="0"/> | ||
<xsd:element name="binding.bolt" type="BBindingTRReference" minOccurs="0"/> | ||
<xsd:element name="binding.rest" type="RestBindingTRReference" minOccurs="0"/> | ||
<xsd:element name="binding.dubbo" type="DubboBindingTRReference" minOccurs="0"/> | ||
|
@@ -590,7 +598,7 @@ | |
<xsd:complexContent> | ||
<xsd:extension base="beans:identifiedType"> | ||
<xsd:all minOccurs="0" maxOccurs="1"> | ||
<xsd:element name="binding.jvm" minOccurs="0"/> | ||
<xsd:element name="binding.jvm" type="BBindingJvmService" minOccurs="0"/> | ||
<xsd:element name="binding.bolt" type="BBindingTRService" minOccurs="0"/> | ||
<xsd:element name="binding.rest" type="RestBindingTRService" minOccurs="0"/> | ||
<xsd:element name="binding.dubbo" type="DubboBindingTRService" minOccurs="0"/> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,8 +33,18 @@ public class JvmBinding extends AbstractBinding { | |
*/ | ||
public static BindingType JVM_BINDING_TYPE = new BindingType("jvm"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里的 "jvm" 字符串也换成下面的 XmlConstants 常量吧。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已替换 |
||
|
||
private JvmBindingParam jvmBindingParam = new JvmBindingParam(); | ||
|
||
public JvmBinding() { | ||
} | ||
|
||
public JvmBindingParam getJvmBindingParam() { | ||
return jvmBindingParam; | ||
} | ||
|
||
public JvmBinding setJvmBindingParam(JvmBindingParam jvmBindingParam) { | ||
this.jvmBindingParam = jvmBindingParam; | ||
return this; | ||
} | ||
|
||
/** | ||
|
@@ -85,4 +95,10 @@ public HealthResult healthCheck() { | |
healthResult.setHealthy(isHealthy); | ||
return healthResult; | ||
} | ||
|
||
public static class XmlConstants { | ||
public static String SERIALIZE = "serialize"; | ||
public static String SUPPORT_TAG_NAME = "binding.jvm"; | ||
public static String BINDING_TYPE = "jvm"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alipay.sofa.runtime.service.binding; | ||
|
||
import com.alipay.sofa.runtime.api.annotation.SofaReference; | ||
import com.alipay.sofa.runtime.api.annotation.SofaReferenceBinding; | ||
import com.alipay.sofa.runtime.api.annotation.SofaService; | ||
import com.alipay.sofa.runtime.api.annotation.SofaServiceBinding; | ||
import com.alipay.sofa.runtime.api.binding.BindingType; | ||
import com.alipay.sofa.runtime.spi.service.BindingConverter; | ||
import com.alipay.sofa.runtime.spi.service.BindingConverterContext; | ||
import org.w3c.dom.Element; | ||
|
||
/** | ||
* @author qilong.zql | ||
* @since 3.1.3 | ||
*/ | ||
public class JvmBindingConverter implements BindingConverter<JvmBindingParam, JvmBinding> { | ||
@Override | ||
public JvmBinding convert(JvmBindingParam bindingParam, | ||
BindingConverterContext bindingConverterContext) { | ||
return new JvmBinding().setJvmBindingParam(bindingParam); | ||
} | ||
|
||
@Override | ||
public JvmBinding convert(Element element, BindingConverterContext bindingConverterContext) { | ||
JvmBindingParam jvmBindingParam = new JvmBindingParam(); | ||
if (element != null) { | ||
jvmBindingParam.setSerialize(Boolean.TRUE.toString().equalsIgnoreCase( | ||
element.getAttribute(JvmBinding.XmlConstants.SERIALIZE))); | ||
} | ||
return new JvmBinding().setJvmBindingParam(jvmBindingParam); | ||
} | ||
|
||
@Override | ||
public JvmBinding convert(SofaService sofaServiceAnnotation, | ||
SofaServiceBinding sofaServiceBindingAnnotation, | ||
BindingConverterContext bindingConverterContext) { | ||
if (JvmBinding.XmlConstants.BINDING_TYPE.equals(sofaServiceBindingAnnotation.bindingType())) { | ||
JvmBindingParam jvmBindingParam = new JvmBindingParam(); | ||
jvmBindingParam.setSerialize(sofaServiceBindingAnnotation.serialize()); | ||
return new JvmBinding().setJvmBindingParam(jvmBindingParam); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public JvmBinding convert(SofaReference sofaReferenceAnnotation, | ||
SofaReferenceBinding sofaReferenceBindingAnnotation, | ||
BindingConverterContext bindingConverterContext) { | ||
if (JvmBinding.XmlConstants.BINDING_TYPE.equals(sofaReferenceBindingAnnotation | ||
.bindingType())) { | ||
JvmBindingParam jvmBindingParam = new JvmBindingParam(); | ||
jvmBindingParam.setSerialize(sofaReferenceBindingAnnotation.serialize()); | ||
return new JvmBinding().setJvmBindingParam(jvmBindingParam); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public BindingType supportBindingType() { | ||
return JvmBinding.JVM_BINDING_TYPE; | ||
} | ||
|
||
@Override | ||
public String supportTagName() { | ||
return JvmBinding.XmlConstants.SUPPORT_TAG_NAME; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alipay.sofa.runtime.service.binding; | ||
|
||
import com.alipay.sofa.runtime.api.binding.BindingType; | ||
import com.alipay.sofa.runtime.api.client.param.BindingParam; | ||
|
||
/** | ||
* @author qilong.zql | ||
* @since 3.1.2 | ||
*/ | ||
public class JvmBindingParam implements BindingParam { | ||
|
||
private boolean serialize = true; | ||
|
||
@Override | ||
public BindingType getBindingType() { | ||
return JvmBinding.JVM_BINDING_TYPE; | ||
} | ||
|
||
/** | ||
* whether ignore serialize when invoke across ClassLoader. | ||
* | ||
* @return | ||
*/ | ||
public boolean isSerialize() { | ||
return serialize; | ||
} | ||
|
||
/** | ||
* Set whether ignore serialize when invoke across ClassLoader. | ||
* | ||
* @param serialize | ||
*/ | ||
public JvmBindingParam setSerialize(boolean serialize) { | ||
this.serialize = serialize; | ||
return this; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im 是什么意思?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo , 已改。