forked from alibaba/nacos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Server ability init login with SPI. (alibaba#7174)
* Move ability classes. * Add ServerAbilityInitializer and RemoteAbilityInitializer * Add NamingAbilityInitializer. * Use ServerAbilityInitializer replace old init ability. * For pmd.
- Loading branch information
1 parent
f51985e
commit 76aeb18
Showing
23 changed files
with
417 additions
and
87 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
32 changes: 32 additions & 0 deletions
32
api/src/main/java/com/alibaba/nacos/api/ability/initializer/AbilityInitializer.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,32 @@ | ||
/* | ||
* Copyright 1999-2021 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed 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.alibaba.nacos.api.ability.initializer; | ||
|
||
/** | ||
* Nacos ability initializer. | ||
* | ||
* @author xiweng.yy | ||
*/ | ||
public interface AbilityInitializer<A> { | ||
|
||
/** | ||
* Initialize target type abilities content. | ||
* | ||
* @param abilities abilities | ||
*/ | ||
void initialize(A abilities); | ||
} |
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
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
32 changes: 32 additions & 0 deletions
32
core/src/main/java/com/alibaba/nacos/core/ability/RemoteAbilityInitializer.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,32 @@ | ||
/* | ||
* Copyright 1999-2021 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed 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.alibaba.nacos.core.ability; | ||
|
||
import com.alibaba.nacos.api.ability.ServerAbilities; | ||
|
||
/** | ||
* Server ability initializer for remote. | ||
* | ||
* @author xiweng.yy | ||
*/ | ||
public class RemoteAbilityInitializer implements ServerAbilityInitializer { | ||
|
||
@Override | ||
public void initialize(ServerAbilities abilities) { | ||
abilities.getRemoteAbility().setSupportRemoteConnection(true); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
core/src/main/java/com/alibaba/nacos/core/ability/ServerAbilityInitializer.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 @@ | ||
/* | ||
* Copyright 1999-2021 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed 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.alibaba.nacos.core.ability; | ||
|
||
import com.alibaba.nacos.api.ability.ServerAbilities; | ||
import com.alibaba.nacos.api.ability.initializer.AbilityInitializer; | ||
|
||
/** | ||
* Nacos server ability initializer. | ||
* | ||
* @author xiweng.yy | ||
*/ | ||
public interface ServerAbilityInitializer extends AbilityInitializer<ServerAbilities> { | ||
|
||
/** | ||
* Initialize server abilities content. | ||
* | ||
* @param abilities server abilities | ||
*/ | ||
@Override | ||
void initialize(ServerAbilities abilities); | ||
} |
51 changes: 51 additions & 0 deletions
51
core/src/main/java/com/alibaba/nacos/core/ability/ServerAbilityInitializerHolder.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,51 @@ | ||
/* | ||
* Copyright 1999-2021 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed 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.alibaba.nacos.core.ability; | ||
|
||
import com.alibaba.nacos.common.spi.NacosServiceLoader; | ||
import com.alibaba.nacos.core.utils.Loggers; | ||
|
||
import java.util.Collection; | ||
import java.util.HashSet; | ||
|
||
/** | ||
* Nacos server ability initializer holder. | ||
* | ||
* @author xiweng.yy | ||
*/ | ||
public class ServerAbilityInitializerHolder { | ||
|
||
private static final ServerAbilityInitializerHolder INSTANCE = new ServerAbilityInitializerHolder(); | ||
|
||
private final Collection<ServerAbilityInitializer> initializers; | ||
|
||
private ServerAbilityInitializerHolder() { | ||
initializers = new HashSet<>(); | ||
for (ServerAbilityInitializer each : NacosServiceLoader.load(ServerAbilityInitializer.class)) { | ||
Loggers.CORE.info("Load {} for ServerAbilityInitializer", each.getClass().getCanonicalName()); | ||
initializers.add(each); | ||
} | ||
} | ||
|
||
public static ServerAbilityInitializerHolder getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
public Collection<ServerAbilityInitializer> getInitializers() { | ||
return initializers; | ||
} | ||
} |
Oops, something went wrong.