-
Notifications
You must be signed in to change notification settings - Fork 26.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support exclude fastjson2 or hessian2 serialization dependencies (#13441
) * Support exclude fastjson2 or hessian2 serialization dependencies * Fix style * Support check * Fix test cases * lint * Fix test cases * Style
- Loading branch information
Showing
12 changed files
with
181 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...nfig-api/src/test/java/org/apache/dubbo/config/utils/TestPreferSerializationProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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 org.apache.dubbo.config.utils; | ||
|
||
import org.apache.dubbo.common.serialization.PreferSerializationProvider; | ||
|
||
public class TestPreferSerializationProvider implements PreferSerializationProvider { | ||
@Override | ||
public String getPreferSerialization() { | ||
return "fastjson2,hessian2"; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...i/src/main/java/org/apache/dubbo/common/serialize/SerializationScopeModelInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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 org.apache.dubbo.common.serialize; | ||
|
||
import org.apache.dubbo.common.serialize.support.PreferSerializationProviderImpl; | ||
import org.apache.dubbo.rpc.model.ApplicationModel; | ||
import org.apache.dubbo.rpc.model.FrameworkModel; | ||
import org.apache.dubbo.rpc.model.ModuleModel; | ||
import org.apache.dubbo.rpc.model.ScopeModelInitializer; | ||
|
||
public class SerializationScopeModelInitializer implements ScopeModelInitializer { | ||
@Override | ||
public void initializeFrameworkModel(FrameworkModel frameworkModel) { | ||
frameworkModel.getBeanFactory().registerBean(PreferSerializationProviderImpl.class); | ||
} | ||
|
||
@Override | ||
public void initializeApplicationModel(ApplicationModel applicationModel) {} | ||
|
||
@Override | ||
public void initializeModuleModel(ModuleModel moduleModel) {} | ||
} |
42 changes: 42 additions & 0 deletions
42
.../main/java/org/apache/dubbo/common/serialize/support/PreferSerializationProviderImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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 org.apache.dubbo.common.serialize.support; | ||
|
||
import org.apache.dubbo.common.serialization.PreferSerializationProvider; | ||
import org.apache.dubbo.common.serialize.Serialization; | ||
import org.apache.dubbo.rpc.model.FrameworkModel; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class PreferSerializationProviderImpl implements PreferSerializationProvider { | ||
private final String preferSerialization; | ||
|
||
public PreferSerializationProviderImpl(FrameworkModel frameworkModel) { | ||
List<String> defaultSerializations = Arrays.asList("fastjson2", "hessian2"); | ||
this.preferSerialization = defaultSerializations.stream() | ||
.filter(s -> | ||
frameworkModel.getExtensionLoader(Serialization.class).hasExtension(s)) | ||
.collect(Collectors.joining(",")); | ||
} | ||
|
||
@Override | ||
public String getPreferSerialization() { | ||
return preferSerialization; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...c/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.model.ScopeModelInitializer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
serialization-api=org.apache.dubbo.common.serialize.SerializationScopeModelInitializer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters