/** * Legitimacy check of stub, note that: the local will deprecated, and replace with <code>stub</code> * * @param interfaceClass for provider side, it is the {@link Class} of the service that will be exported; for consumer * side, it is the {@link Class} of the remote service interface */ void checkStubAndLocal(Class<?> interfaceClass) { if (ConfigUtils.isNotEmpty(local)) { Class<?> localClass = ConfigUtils.isDefault(local) ? ReflectUtils.forName(interfaceClass.getName() + "Local") : ReflectUtils.forName(local); verify(interfaceClass, localClass); } if (ConfigUtils.isNotEmpty(stub)) { Class<?> localClass = ConfigUtils.isDefault(stub) ? ReflectUtils.forName(interfaceClass.getName() + "Stub") : ReflectUtils.forName(stub); verify(interfaceClass, localClass); } }
@Override public Object getInternalProperty(String key) { return ConfigUtils.getProperty(key); } }
if (ConfigUtils.isEmpty(mock)) { return; if (ConfigUtils.isNotEmpty(normalizedMock)) { try {
@SuppressWarnings({"unchecked", "rawtypes"}) public static String getProperty(String key, String defaultValue) { String value = System.getProperty(key); if (value != null && value.length() > 0) { return value; } Properties properties = getProperties(); return replaceProperty(properties.getProperty(key, defaultValue), (Map) properties); }
private boolean isActive(String[] keys, URL url) { if (keys.length == 0) { return true; } for (String key : keys) { for (Map.Entry<String, String> entry : url.getParameters().entrySet()) { String k = entry.getKey(); String v = entry.getValue(); if ((k.equals(key) || k.endsWith("." + key)) && ConfigUtils.isNotEmpty(v)) { return true; } } } return false; }
checkInvokers(invokers, invocation); String merger = getUrl().getMethodParameter(invocation.getMethodName(), Constants.MERGER_KEY); if (ConfigUtils.isEmpty(merger)) { // If a method doesn't have a merger, only invoke one Group for (final Invoker<T> invoker : invokers) { if (invoker.isAvailable()) { if (ConfigUtils.isDefault(merger)) { resultMerger = MergerFactory.getMerger(returnType); } else {
appendRuntimeParameters(map); String hostToRegistry = ConfigUtils.getSystemProperty(Constants.DUBBO_IP_TO_REGISTRY); if (StringUtils.isEmpty(hostToRegistry)) { hostToRegistry = NetUtils.getLocalHost(); address = sysaddress; if (ConfigUtils.isNotEmpty(address)) { if (!map.containsKey(Constants.PROTOCOL_KEY)) { if (getExtensionLoader(MonitorFactory.class).hasExtension("logstat")) {
@SuppressWarnings("unchecked") public static Object getMockObject(String mockService, Class serviceType) { if (ConfigUtils.isDefault(mockService)) { mockService = serviceType.getName() + "Mock"; } Class<?> mockClass = ReflectUtils.forName(mockService); if (!serviceType.isAssignableFrom(mockClass)) { throw new IllegalStateException("The mock class " + mockClass.getName() + " not implement interface " + serviceType.getName()); } try { return mockClass.newInstance(); } catch (InstantiationException e) { throw new IllegalStateException("No default constructor from mock class " + mockClass.getName(), e); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } }
public static boolean isNotEmpty(String value) { return !isEmpty(value); }
static void appendRuntimeParameters(Map<String, String> map) { map.put(Constants.DUBBO_VERSION_KEY, Version.getProtocolVersion()); map.put(Constants.RELEASE_KEY, Version.getVersion()); map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis())); if (ConfigUtils.getPid() > 0) { map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid())); } }
public static void addProperties(Properties properties) { if (properties != null) { getProperties().putAll(properties); } }
Properties properties = new Properties(); if (checkFileNameExist(fileName)) { try { FileInputStream input = new FileInputStream(fileName);
private boolean isActive(String[] keys, URL url) { if (keys.length == 0) { return true; } for (String key : keys) { for (Map.Entry<String, String> entry : url.getParameters().entrySet()) { String k = entry.getKey(); String v = entry.getValue(); if ((k.equals(key) || k.endsWith("." + key)) && ConfigUtils.isNotEmpty(v)) { return true; } } } return false; }
checkInvokers(invokers, invocation); String merger = getUrl().getMethodParameter(invocation.getMethodName(), Constants.MERGER_KEY); if (ConfigUtils.isEmpty(merger)) { // If a method doesn't have a merger, only invoke one Group for (final Invoker<T> invoker : invokers) { if (invoker.isAvailable()) { if (ConfigUtils.isDefault(merger)) { resultMerger = MergerFactory.getMerger(returnType); } else {
appendRuntimeParameters(map); String hostToRegistry = ConfigUtils.getSystemProperty(Constants.DUBBO_IP_TO_REGISTRY); if (StringUtils.isEmpty(hostToRegistry)) { hostToRegistry = NetUtils.getLocalHost(); address = sysaddress; if (ConfigUtils.isNotEmpty(address)) { if (!map.containsKey(Constants.PROTOCOL_KEY)) { if (getExtensionLoader(MonitorFactory.class).hasExtension("logstat")) {
@SuppressWarnings("unchecked") public static Object getMockObject(String mockService, Class serviceType) { if (ConfigUtils.isDefault(mockService)) { mockService = serviceType.getName() + "Mock"; } Class<?> mockClass = ReflectUtils.forName(mockService); if (!serviceType.isAssignableFrom(mockClass)) { throw new IllegalStateException("The mock class " + mockClass.getName() + " not implement interface " + serviceType.getName()); } try { return mockClass.newInstance(); } catch (InstantiationException e) { throw new IllegalStateException("No default constructor from mock class " + mockClass.getName(), e); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } }
@SuppressWarnings({"unchecked", "rawtypes"}) public static String getProperty(String key, String defaultValue) { String value = System.getProperty(key); if (value != null && value.length() > 0) { return value; } Properties properties = getProperties(); return replaceProperty(properties.getProperty(key, defaultValue), (Map) properties); }
public static boolean isNotEmpty(String value) { return !isEmpty(value); }
static void appendRuntimeParameters(Map<String, String> map) { map.put(Constants.DUBBO_VERSION_KEY, Version.getProtocolVersion()); map.put(Constants.RELEASE_KEY, Version.getVersion()); map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis())); if (ConfigUtils.getPid() > 0) { map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid())); } }
public static void addProperties(Properties properties) { if (properties != null) { getProperties().putAll(properties); } }