RESTEasy的容器分析

RESTEasy的核心容器是ResteasyDeployment

ResteasyDeployment包含ResteasyProviderFactory,而反之则不包含。

只需要考虑在ResteasyDeployment.start()之后的地方往ResteasyProviderFactory里面注入相关参数,就可以了。

ResteasyProviderFactory是实现了ConfigurableConfiguration接口的。

注意javax.ws.rs.core.Configuration接口定义的getProperties()是immutable的:

/**
 * Get the immutable bag of configuration properties.
 *
 * @return the immutable view of configuration properties.
 */
public Map<String, Object> getProperties();

所以ResteasyProviderFactory自己实现了mutable版本:

public Map<String, Object> getMutableProperties()
{
   return properties;
}

然后mutable版本的实现如下:

@Override
public Map<String, Object> getProperties()
{
   return Collections.unmodifiableMap(properties);
}

注意ResteasyProviderFactorycontextualData是thread local的:

protected static ThreadLocalStack<Map<Class<?>, Object>> contextualData = new ThreadLocalStack<Map<Class<?>, Object>>();

以上是针对上周工作的一些总结。

My Github Page: https://github.com/liweinan

Powered by Jekyll and Theme by solid

If you have any question want to ask or find bugs regarding with my blog posts, please report it here:
https://github.com/liweinan/liweinan.github.io/issues