Skip to content

Instantly share code, notes, and snippets.

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Properties;
import javax.annotation.PostConstruct;
import org.apache.ibatis.cache.CacheKey;
import org.apache.ibatis.executor.Executor;
public static Object resolveAutowiringValue(Object autowiringValue, Class<?> requiredType) {
if (autowiringValue instanceof ObjectFactory && !requiredType.isInstance(autowiringValue)) {
ObjectFactory<?> factory = (ObjectFactory<?>) autowiringValue;
if (autowiringValue instanceof Serializable && requiredType.isInterface()) {
autowiringValue = Proxy.newProxyInstance(requiredType.getClassLoader(),
new Class<?>[] {requiredType}, new ObjectFactoryDelegatingInvocationHandler(factory));
}
else {
return factory.getObject();
}
protected Map<String, Object> findAutowireCandidates(
@Nullable String beanName, Class<?> requiredType, DependencyDescriptor descriptor) {
String[] candidateNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
this, requiredType, true, descriptor.isEager());
Map<String, Object> result = new LinkedHashMap<>(candidateNames.length);
for (Class<?> autowiringType : this.resolvableDependencies.keySet()) {
if (autowiringType.isAssignableFrom(requiredType)) {
Object autowiringValue = this.resolvableDependencies.get(autowiringType);
autowiringValue = AutowireUtils.resolveAutowiringValue(autowiringValue, requiredType);
/**
* Factory that exposes the current request object on demand.
*/
@SuppressWarnings("serial")
private static class RequestObjectFactory implements ObjectFactory<ServletRequest>, Serializable {
@Override
public ServletRequest getObject() {
return currentRequestAttributes().getRequest();
}
public static void registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory,
@Nullable ServletContext sc) {
...
beanFactory.registerResolvableDependency(ServletRequest.class, new RequestObjectFactory());
beanFactory.registerResolvableDependency(ServletResponse.class, new ResponseObjectFactory());
beanFactory.registerResolvableDependency(HttpSession.class, new SessionObjectFactory());
beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
@Controller
public FooController {
@Autowired
private HttpServletRequest request;
...
}
public class MfaCredentailProvider implements AWSCredentialsProvider {
private DefaultAWSCredentialsProviderChain defaultChain = DefaultAWSCredentialsProviderChain.getInstance();
private final String region;
private AWSCredentials token;
public MfaCredentailProvider(String region) {
if(region == null) {
@circlee
circlee / IgnoreXssEscape.java
Created February 28, 2020 04:48
luxy xssEscapeStringDeserializer
@Target({ElementType.FIELD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface IgnoreXssEscape {
}
/**
* Initializes or doubles table size. If null, allocates in
* accord with initial capacity target held in field threshold.
* Otherwise, because we are using power-of-two expansion, the
* elements from each bin must either stay at same index, or move
* with a power of two offset in the new table.
*
* @return the table
*/
final Node<K,V>[] resize() {
putVal(int XORHash, K key, V value, boolean onlyIfAbsent, boolean evict) {
1. Node<K,V> 테이블이 없다면 초기화
2. 테이블의 [ 테이블 길이 -1 & XORHash ] 인덱스 Value가 null 이라면
- 테이블의 [ 테이블 길이 -1 & XORHash ] 인덱스에 newNode(새로운 노드 생성) 넣음
3. 2번이 아니라면
테이블의 [ 테이블 길이 -1 & XORHash ] 인덱스의 Node 값 참조
3-1. (Node의 hash 가 파라미터 XORHash 같고 Node의 key 가 파라미터 키와 같음) or (노드의 key 가 파라미터 key 와 equals true)