Use constants instead of literals (#7962)
* Use constants instead of literals * Remove unused variables * Remove unnecessary modifiers * Use constants instead of literals
This commit is contained in:
parent
e18d4d0085
commit
a799dd9528
|
|
@ -382,7 +382,7 @@ public final class ClassGenerator {
|
|||
return getCtClass(c.getDeclaringClass()).getConstructor(ReflectUtils.getDesc(c));
|
||||
}
|
||||
|
||||
public static interface DC {
|
||||
public interface DC {
|
||||
|
||||
} // dynamic class tag interface.
|
||||
}
|
||||
|
|
@ -16,12 +16,13 @@
|
|||
*/
|
||||
package org.apache.dubbo.common.compiler;
|
||||
|
||||
import org.apache.dubbo.common.compiler.support.JavassistCompiler;
|
||||
import org.apache.dubbo.common.extension.SPI;
|
||||
|
||||
/**
|
||||
* Compiler. (SPI, Singleton, ThreadSafe)
|
||||
*/
|
||||
@SPI("javassist")
|
||||
@SPI(JavassistCompiler.NAME)
|
||||
public interface Compiler {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
public class JavassistCompiler extends AbstractCompiler {
|
||||
|
||||
public static final String NAME = "javassist";
|
||||
|
||||
private static final Pattern IMPORT_PATTERN = Pattern.compile("import\\s+([\\w\\.\\*]+);\n");
|
||||
|
||||
private static final Pattern EXTENDS_PATTERN = Pattern.compile("\\s+extends\\s+([\\w\\.]+)[^\\{]*\\{\n");
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ import java.util.Set;
|
|||
*/
|
||||
public class JdkCompiler extends AbstractCompiler {
|
||||
|
||||
public static final String NAME = "jdk";
|
||||
|
||||
private final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
|
||||
private final DiagnosticCollector<JavaFileObject> diagnosticCollector = new DiagnosticCollector<JavaFileObject>();
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.dubbo.common.threadpool;
|
|||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.Adaptive;
|
||||
import org.apache.dubbo.common.extension.SPI;
|
||||
import org.apache.dubbo.common.threadpool.support.fixed.FixedThreadPool;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.THREADPOOL_KEY;
|
|||
/**
|
||||
* ThreadPool
|
||||
*/
|
||||
@SPI("fixed")
|
||||
@SPI(FixedThreadPool.NAME)
|
||||
public interface ThreadPool {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ public class DefaultExecutorRepository implements ExecutorRepository {
|
|||
|
||||
private ScheduledExecutorService serviceExporterExecutor;
|
||||
|
||||
private ScheduledExecutorService reconnectScheduledExecutor;
|
||||
|
||||
private ConcurrentMap<String, ConcurrentMap<Integer, ExecutorService>> data = new ConcurrentHashMap<>();
|
||||
|
||||
|
|
@ -60,8 +59,6 @@ public class DefaultExecutorRepository implements ExecutorRepository {
|
|||
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("Dubbo-framework-scheduler"));
|
||||
scheduledExecutors.addItem(scheduler);
|
||||
}
|
||||
//
|
||||
// reconnectScheduledExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("Dubbo-reconnect-scheduler"));
|
||||
serviceExporterExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Dubbo-exporter-scheduler"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
|
|||
*/
|
||||
public class CachedThreadPool implements ThreadPool {
|
||||
|
||||
public static final String NAME = "cached";
|
||||
|
||||
@Override
|
||||
public Executor getExecutor(URL url) {
|
||||
String name = url.getParameter(THREAD_NAME_KEY, DEFAULT_THREAD_NAME);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
|
|||
*/
|
||||
public class EagerThreadPool implements ThreadPool {
|
||||
|
||||
public static final String NAME = "eager";
|
||||
|
||||
@Override
|
||||
public Executor getExecutor(URL url) {
|
||||
String name = url.getParameter(THREAD_NAME_KEY, DEFAULT_THREAD_NAME);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
|
|||
*/
|
||||
public class FixedThreadPool implements ThreadPool {
|
||||
|
||||
public static final String NAME = "fixed";
|
||||
|
||||
@Override
|
||||
public Executor getExecutor(URL url) {
|
||||
String name = url.getParameter(THREAD_NAME_KEY, DEFAULT_THREAD_NAME);
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
|
|||
*/
|
||||
public class LimitedThreadPool implements ThreadPool {
|
||||
|
||||
public static final String NAME = "limited";
|
||||
|
||||
@Override
|
||||
public Executor getExecutor(URL url) {
|
||||
String name = url.getParameter(THREAD_NAME_KEY, DEFAULT_THREAD_NAME);
|
||||
|
|
|
|||
|
|
@ -16,18 +16,21 @@
|
|||
*/
|
||||
package org.apache.dubbo.cache;
|
||||
|
||||
import org.apache.dubbo.cache.support.lru.LruCacheFactory;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.Adaptive;
|
||||
import org.apache.dubbo.common.extension.SPI;
|
||||
import org.apache.dubbo.rpc.Invocation;
|
||||
|
||||
import static org.apache.dubbo.common.constants.FilterConstants.CACHE_KEY;
|
||||
|
||||
/**
|
||||
* Interface needs to be implemented by all the cache store provider.Along with implementing <b>CacheFactory</b> interface
|
||||
* entry needs to be added in org.apache.dubbo.cache.CacheFactory file in a classpath META-INF sub directories.
|
||||
*
|
||||
* @see Cache
|
||||
*/
|
||||
@SPI("lru")
|
||||
@SPI(LruCacheFactory.NAME)
|
||||
public interface CacheFactory {
|
||||
|
||||
/**
|
||||
|
|
@ -37,7 +40,7 @@ public interface CacheFactory {
|
|||
* @param invocation
|
||||
* @return Instance of Cache containing cached value against method url and invocation.
|
||||
*/
|
||||
@Adaptive("cache")
|
||||
@Adaptive(CACHE_KEY)
|
||||
Cache getCache(URL url, Invocation invocation);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import org.apache.dubbo.common.URL;
|
|||
|
||||
public class ExpiringCacheFactory extends AbstractCacheFactory {
|
||||
|
||||
public static final String NAME = "expiring";
|
||||
|
||||
/**
|
||||
* Takes url as an method argument and return new instance of cache store implemented by JCache.
|
||||
* @param url url of the method
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ import javax.cache.spi.CachingProvider;
|
|||
*/
|
||||
public class JCacheFactory extends AbstractCacheFactory {
|
||||
|
||||
public static final String NAME = "jcache";
|
||||
|
||||
/**
|
||||
* Takes url as an method argument and return new instance of cache store implemented by JCache.
|
||||
* @param url url of the method
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ import org.apache.dubbo.common.URL;
|
|||
*/
|
||||
public class LfuCacheFactory extends AbstractCacheFactory {
|
||||
|
||||
public static final String NAME = "lfu";
|
||||
|
||||
/**
|
||||
* Takes url as an method argument and return new instance of cache store implemented by LfuCache.
|
||||
* @param url url of the method
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ import org.apache.dubbo.common.URL;
|
|||
*/
|
||||
public class LruCacheFactory extends AbstractCacheFactory {
|
||||
|
||||
public static final String NAME = "lru";
|
||||
|
||||
/**
|
||||
* Takes url as an method argument and return new instance of cache store implemented by LruCache.
|
||||
* @param url url of the method
|
||||
|
|
|
|||
Loading…
Reference in New Issue