③ getCandidateConfigurations(annotationMetadata, attributes)方法:
/**
* Return the auto-configuration class names that should be considered. By default
* this method will load candidates using {@link SpringFactoriesLoader} with
* {@link #getSpringFactoriesLoaderFactoryClass()}.
* @param metadata the source metadata
* @param attributes the {@link #getAttributes(AnnotationMetadata) annotation
* attributes}
* @return a list of candidate configurations
*/protected List getCandidateConfigurations(AnnotationMetadata metadata, AnnotationAttributes attributes) {
//去spring.factories中去查询EnableAutoConfiguration类
List configurations = SpringFactoriesLoader.loadFactoryNames(getSpringFactoriesLoaderFactoryClass(),
getBeanClassLoader());
Assert.notEmpty(configurations, "No auto configuration classes found in META-INF/spring.factories. If you "
+ "are using a custom packaging, make sure that file is correct.");
return configurations;
}
④ SpringFactoriesLoader.loadFactoryNames方法:
/**
* Load the fully qualified class names of factory implementations of the
* given type from {@value #FACTORIES_RESOURCE_LOCATION}, using the given
* class loader.
* @param factoryClass the interface or abstract class representing the factory
* @param classLoader the ClassLoader to use for loading resources; can be
* {@code null} to use the default
* @throws IllegalArgumentException if an error occurs while loading factory names
* @see #loadFactories
*/publicstatic List loadFactoryNames(Class factoryClass, @Nullable ClassLoader classLoader) {
String factoryClassName = factoryClass.getName();
//去spring.factories 中去查询EnableAutoConfiguration类return loadSpringFactories(classLoader).getOrDefault(factoryClassName, Collections.emptyList());
}
⑤ loadSpringFactories(classLoader)方法:
privatestatic Map> loadSpringFactories(@Nullable ClassLoader classLoader) {
MultiValueMap result = cache.get(classLoader);
if (result != null) {
return result;
}
try {
/**
* The location to look for factories. Can be present in multiple JAR files.
* FACTORIES_RESOURCE_LOCATION = "META-INF/spring.factories";
*/
Enumeration urls = (classLoader != null ?
classLoader.getResources(FACTORIES_RESOURCE_LOCATION) :
ClassLoader.getSystemResources(FACTORIES_RESOURCE_LOCATION));
result = new LinkedMultiValueMap<>();
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
UrlResource resource = new UrlResource(url);
Properties properties = PropertiesLoaderUtils.loadProperties(resource);
for (Map.Entry entry : properties.entrySet()) {
String factoryClassName = ((String) entry.getKey()).trim();
for (String factoryName : StringUtils.commaDelimitedListToStringArray((String) entry.getValue())) {
result.add(factoryClassName, factoryName.trim());
}
}
}
cache.put(classLoader, result);
return result;
}
catch (IOException ex) {
thrownew IllegalArgumentException("Unable to load factories from location [" +
FACTORIES_RESOURCE_LOCATION + "]", ex);
}
}
@ConfigurationProperties(prefix = "spring.redis")
publicclass RedisProperties {
/**
* Database index used by the connection factory.
*/privateint database = 0;
/**
* Connection URL. Overrides host, port, and password. User is ignored. Example:
* redis://user:[email protected]:6379
*/private String url;
/**
* Redis server host.
*/private String host = "localhost";
/**
* Login password of the redis server.
*/private String password;
/**
* Redis server port.
*/privateint port = 6379;
/**
* Whether to enable SSL support.
*/privateboolean ssl;
/**
* Connection timeout.
*/private Duration timeout;
private Sentinel sentinel;
private Cluster cluster;
privatefinal Jedis jedis = new Jedis();
privatefinal Lettuce lettuce = new Lettuce();
publicint getDatabase() {
returnthis.database;
}
publicvoid setDatabase(int database) {
this.database = database;
}
public String getUrl() {
returnthis.url;
}
publicvoid setUrl(String url) {
this.url = url;
}
public String getHost() {
returnthis.host;
}
publicvoid setHost(String host) {
this.host = host;
}
public String getPassword() {
returnthis.password;
}
publicvoid setPassword(String password) {
this.password = password;
}
publicint getPort() {
returnthis.port;
}
publicvoid setPort(int port) {
this.port = port;
}
publicboolean isSsl() {
returnthis.ssl;
}
publicvoid setSsl(boolean ssl) {
this.ssl = ssl;
}
publicvoid setTimeout(Duration timeout) {
this.timeout = timeout;
}
public Duration getTimeout() {
returnthis.timeout;
}
public Sentinel getSentinel() {
returnthis.sentinel;
}
publicvoid setSentinel(Sentinel sentinel) {
this.sentinel = sentinel;
}
public Cluster getCluster() {
returnthis.cluster;
}
publicvoid setCluster(Cluster cluster) {
this.cluster = cluster;
}
public Jedis getJedis() {
returnthis.jedis;
}
public Lettuce getLettuce() {
returnthis.lettuce;
}
/**
* Pool properties.
*/publicstaticclass Pool {
/**
* Maximum number of "idle" connections in the pool. Use a negative value to
* indicate an unlimited number of idle connections.
*/privateint maxIdle = 8;
/**
* Target for the minimum number of idle connections to maintain in the pool. This
* setting only has an effect if both it and time between eviction runs are
* positive.
*/privateint minIdle = 0;
/**
* Maximum number of connections that can be allocated by the pool at a given
* time. Use a negative value for no limit.
*/privateint maxActive = 8;
/**
* Maximum amount of time a connection allocation should block before throwing an
* exception when the pool is exhausted. Use a negative value to block
* indefinitely.
*/private Duration maxWait = Duration.ofMillis(-1);
/**
* Time between runs of the idle object evictor thread. When positive, the idle
* object evictor thread starts, otherwise no idle object eviction is performed.
*/private Duration timeBetweenEvictionRuns;
publicint getMaxIdle() {
returnthis.maxIdle;
}
publicvoid setMaxIdle(int maxIdle) {
this.maxIdle = maxIdle;
}
publicint getMinIdle() {
returnthis.minIdle;
}
publicvoid setMinIdle(int minIdle) {
this.minIdle = minIdle;
}
publicint getMaxActive() {
returnthis.maxActive;
}
publicvoid setMaxActive(int maxActive) {
this.maxActive = maxActive;
}
public Duration getMaxWait() {
returnthis.maxWait;
}
publicvoid setMaxWait(Duration maxWait) {
this.maxWait = maxWait;
}
public Duration getTimeBetweenEvictionRuns() {
returnthis.timeBetweenEvictionRuns;
}
publicvoid setTimeBetweenEvictionRuns(Duration timeBetweenEvictionRuns) {
this.timeBetweenEvictionRuns = timeBetweenEvictionRuns;
}
}
/**
* Cluster properties.
*/publicstaticclass Cluster {
/**
* Comma-separated list of "host:port" pairs to bootstrap from. This represents an
* "initial" list of cluster nodes and is required to have at least one entry.
*/private List nodes;
/**
* Maximum number of redirects to follow when executing commands across the
* cluster.
*/private Integer maxRedirects;
public List getNodes() {
returnthis.nodes;
}
publicvoid setNodes(List nodes) {
this.nodes = nodes;
}
public Integer getMaxRedirects() {
returnthis.maxRedirects;
}
publicvoid setMaxRedirects(Integer maxRedirects) {
this.maxRedirects = maxRedirects;
}
}
/**
* Redis sentinel properties.
*/publicstaticclass Sentinel {
/**
* Name of the Redis server.
*/private String master;
/**
* Comma-separated list of "host:port" pairs.
*/private List nodes;
public String getMaster() {
returnthis.master;
}
publicvoid setMaster(String master) {
this.master = master;
}
public List getNodes() {
returnthis.nodes;
}
publicvoid setNodes(List nodes) {
this.nodes = nodes;
}
}
/**
* Jedis client properties.
*/publicstaticclass Jedis {
/**
* Jedis pool configuration.
*/private Pool pool;
public Pool getPool() {
returnthis.pool;
}
publicvoid setPool(Pool pool) {
this.pool = pool;
}
}
/**
* Lettuce client properties.
*/publicstaticclass Lettuce {
/**
* Shutdown timeout.
*/private Duration shutdownTimeout = Duration.ofMillis(100);
/**
* Lettuce pool configuration.
*/private Pool pool;
public Duration getShutdownTimeout() {
returnthis.shutdownTimeout;
}
publicvoid setShutdownTimeout(Duration shutdownTimeout) {
this.shutdownTimeout = shutdownTimeout;
}
public Pool getPool() {
returnthis.pool;
}
publicvoid setPool(Pool pool) {
this.pool = pool;
}
}
}
Android中的Toast是一种简易的消息提示框,toast提示框不能被用户点击,toast会根据用户设置的显示时间后自动消失。
创建Toast
两个方法创建Toast
makeText(Context context, int resId, int duration)
参数:context是toast显示在
angular.identiy 描述: 返回它第一参数的函数. 此函数多用于函数是编程. 使用方法: angular.identity(value); 参数详解: Param Type Details value
*
to be returned. 返回值: 传入的value 实例代码:
<!DOCTYPE HTML>
Hierarchical Queries
If a table contains hierarchical data, then you can select rows in a hierarchical order using the hierarchical query clause:
hierarchical_query_clause::=
start with condi
初次接触到socket网络编程,也参考了网络上众前辈的文章。尝试自己也写了一下,记录下过程吧:
服务端:(接收客户端消息并把它们打印出来)
public class SocketServer {
private List<Socket> socketList = new ArrayList<Socket>();
public s