Skip to content

Commit

Permalink
feat: optimize code (#11671)
Browse files Browse the repository at this point in the history
  • Loading branch information
aamingaa authored Feb 27, 2023
1 parent c4d6f94 commit a70cc27
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.dubbo.rpc.cluster;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

Expand All @@ -33,7 +34,7 @@ public interface ConfiguratorFactory {
* @param url - configurator url.
* @return configurator instance.
*/
@Adaptive("protocol")
@Adaptive(CommonConstants.PROTOCOL_KEY)
Configurator getConfigurator(URL url);

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.dubbo.rpc.cluster;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

Expand All @@ -42,6 +43,6 @@ public interface RouterFactory {
* @param url url
* @return router instance
*/
@Adaptive("protocol")
@Adaptive(CommonConstants.PROTOCOL_KEY)
Router getRouter(URL url);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.dubbo.rpc.cluster.router.state;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

Expand All @@ -29,6 +30,6 @@ public interface StateRouterFactory {
* @return router instance
* @since 3.0
*/
@Adaptive("protocol")
@Adaptive(CommonConstants.PROTOCOL_KEY)
<T> StateRouter<T> getRouter(Class<T> interfaceClass, URL url);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.dubbo.common.extension;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.StringUtils;
Expand Down Expand Up @@ -268,7 +269,7 @@ private String generateExtNameAssignment(String[] value, boolean hasInvocation)
for (int i = value.length - 1; i >= 0; --i) {
if (i == value.length - 1) {
if (null != defaultExtName) {
if (!"protocol".equals(value[i])) {
if (!CommonConstants.PROTOCOL_KEY.equals(value[i])) {
if (hasInvocation) {
getNameCode = String.format("url.getMethodParameter(methodName, \"%s\", \"%s\")", value[i], defaultExtName);
} else {
Expand All @@ -278,7 +279,7 @@ private String generateExtNameAssignment(String[] value, boolean hasInvocation)
getNameCode = String.format("( url.getProtocol() == null ? \"%s\" : url.getProtocol() )", defaultExtName);
}
} else {
if (!"protocol".equals(value[i])) {
if (!CommonConstants.PROTOCOL_KEY.equals(value[i])) {
if (hasInvocation) {
getNameCode = String.format("url.getMethodParameter(methodName, \"%s\", \"%s\")", value[i], defaultExtName);
} else {
Expand All @@ -289,7 +290,7 @@ private String generateExtNameAssignment(String[] value, boolean hasInvocation)
}
}
} else {
if (!"protocol".equals(value[i])) {
if (!CommonConstants.PROTOCOL_KEY.equals(value[i])) {
if (hasInvocation) {
getNameCode = String.format("url.getMethodParameter(methodName, \"%s\", \"%s\")", value[i], defaultExtName);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
package com.alibaba.dubbo.rpc.cluster;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.rpc.cluster.Configurator;

@Deprecated
public interface ConfiguratorFactory extends org.apache.dubbo.rpc.cluster.ConfiguratorFactory {
@Adaptive("protocol")
@Adaptive(CommonConstants.PROTOCOL_KEY)
com.alibaba.dubbo.rpc.cluster.Configurator getConfigurator(com.alibaba.dubbo.common.URL url);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.dubbo.metrics.report;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.ExtensionScope;
import org.apache.dubbo.common.extension.SPI;
Expand All @@ -34,6 +35,6 @@ public interface MetricsReporterFactory {
* @param url URL
* @return Metrics reporter implementation.
*/
@Adaptive({"protocol"})
@Adaptive({CommonConstants.PROTOCOL_KEY})
MetricsReporter createMetricsReporter(URL url);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.dubbo.monitor;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;

Expand All @@ -32,7 +33,7 @@ public interface MonitorFactory {
* @param url
* @return monitor
*/
@Adaptive("protocol")
@Adaptive(CommonConstants.PROTOCOL_KEY)
Monitor getMonitor(URL url);

}

0 comments on commit a70cc27

Please sign in to comment.