本文整理汇总了Java中org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters类的典型用法代码示例。如果您正苦于以下问题:Java ResteasyContextParameters类的具体用法?Java ResteasyContextParameters怎么用?Java ResteasyContextParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResteasyContextParameters类属于org.jboss.resteasy.plugins.server.servlet包,在下文中一共展示了ResteasyContextParameters类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getExceptionProviderMap
import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters; //导入依赖的package包/类
/**
* Finds the RESTEasy providers parameter and return its value as map of classes with its generic types.
*
* @param contextParams the map of all context parameters
* @return a Map of RESTEasy exception-provider classes
*/
public static Map<Class<?>, Class<?>> getExceptionProviderMap(Map<String, String> contextParams) {
Map<Class<?>, Class<?>> providerMap = new HashMap<Class<?>, Class<?>>();
List<String> providers = getParamValues(contextParams, ResteasyContextParameters.RESTEASY_PROVIDERS);
if (providers != null) {
for (String provider : providers) {
Class<?> providerClass = Classes.forName(provider.trim());
if (providerClass != null) {
Type exceptionType = Types.getActualTypeArgumentsOfAnInterface(providerClass, ExceptionMapper.class)[0];
Class<?> exceptionClass = Types.getRawType(exceptionType);
providerMap.put(exceptionClass, providerClass);
}
}
}
return providerMap;
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:22,代码来源:RESTEasyUtil.java
示例2: keycloakJaxRsApplication
import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters; //导入依赖的package包/类
@Bean
ServletRegistrationBean keycloakJaxRsApplication(KeycloakServerProperties keycloakServerProperties, DataSource dataSource) throws Exception {
mockJndiEnvironment(dataSource);
//FIXME: hack to propagate Spring Boot Properties to Keycloak Application
EmbeddedKeycloakApplication.keycloakServerProperties = keycloakServerProperties;
ServletRegistrationBean servlet = new ServletRegistrationBean(new HttpServlet30Dispatcher());
servlet.addInitParameter("javax.ws.rs.Application", EmbeddedKeycloakApplication.class.getName());
servlet.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, keycloakServerProperties.getContextPath());
servlet.addInitParameter(ResteasyContextParameters.RESTEASY_USE_CONTAINER_FORM_PARAMS, "true");
servlet.addUrlMappings(keycloakServerProperties.getContextPath() + "/*");
servlet.setLoadOnStartup(1);
servlet.setAsyncSupported(true);
return servlet;
}
开发者ID:thomasdarimont,项目名称:spring-boot-keycloak-server-example,代码行数:19,代码来源:EmbeddedKeycloakConfig.java
示例3: getProviderClasses
import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters; //导入依赖的package包/类
/**
* Finds the RESTEasy providers parameter and return its value as list of classes.
*
* @param contextParams the map of all context parameters
* @return a List of RESTEasy provider classes or null if not present
*/
public static List<Class<?>> getProviderClasses(Map<String, String> contextParams) {
List<String> providers = getParamValues(contextParams, ResteasyContextParameters.RESTEASY_PROVIDERS);
if (providers != null) {
List<Class<?>> providerClasses = new ArrayList<Class<?>>(providers.size());
for (String provider : providers) {
Class<?> pc = Classes.forName(provider.trim());
if (pc != null) {
providerClasses.add(pc);
}
}
return providerClasses.isEmpty() ? null : providerClasses;
}
return null;
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:21,代码来源:RESTEasyUtil.java
示例4: RESTEasyUtilTest
import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters; //导入依赖的package包/类
public RESTEasyUtilTest() {
contextParams = new HashMap<String, String>(1);
contextParams.put(ResteasyContextParameters.RESTEASY_USE_BUILTIN_PROVIDERS, "false");
contextParamsWithProviders = new HashMap<String, String>(1);
contextParamsWithProviders.put(ResteasyContextParameters.RESTEASY_PROVIDERS, STRING_CLASS_NAME + "," + BAD_CLASS_NAME);
contextParamsWithOnlyBadProviders = new HashMap<String, String>(1);
contextParamsWithOnlyBadProviders.put(ResteasyContextParameters.RESTEASY_PROVIDERS, BAD_CLASS_NAME);
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:11,代码来源:RESTEasyUtilTest.java
示例5: testGetProviders
import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters; //导入依赖的package包/类
@Test
public void testGetProviders() throws Exception {
Assert.assertNull(RESTEasyUtil.getParamValues(null, ResteasyContextParameters.RESTEASY_PROVIDERS));
Assert.assertNull(RESTEasyUtil.getParamValues(contextParams, ResteasyContextParameters.RESTEASY_PROVIDERS));
List<String> providers = RESTEasyUtil.getParamValues(contextParamsWithProviders, ResteasyContextParameters.RESTEASY_PROVIDERS);
Assert.assertEquals(2, providers.size());
Assert.assertEquals(STRING_CLASS_NAME, providers.get(0));
Assert.assertEquals(BAD_CLASS_NAME, providers.get(1));
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:11,代码来源:RESTEasyUtilTest.java
示例6: publish
import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Endpoint publish(final ServiceDomain domain, final String context, final List<Object> instances, final Map<String, String> contextParams) throws Exception {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Publishing StandaloneResource: resouces=" + instances + ", contextParams=" + contextParams);
}
_nettyServer.stop();
// CAUTION: Note that this publisher ignores context. Use it only for test purpose.
for (Object instance : instances) {
_nettyServer.getDeployment().getResources().add(instance);
}
final List<String> providers = RESTEasyUtil.getParamValues(contextParams, ResteasyContextParameters.RESTEASY_PROVIDERS);
_nettyServer.getDeployment().getScannedProviderClasses().addAll(providers != null ? providers : Collections.<String>emptyList());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Published StandaloneResource - Restarting Netty JAXRS Server: resources=" + instances + ", providers=" + providers);
}
_nettyServer.start();
return new StandaloneResource(new StandaloneResource.Callback() {
@Override
public void onStart() {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Starting StandaloneResource: resources=" + instances + ", providers=" + providers);
}
}
@Override
public void onStop() {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Stopping StandaloneResource: resouces=" + instances + ", providers=" + providers);
}
_nettyServer.stop();
List<Object> resources = new ArrayList<Object>(_nettyServer.getDeployment().getResources());
for (int i=0; instances != null && i<instances.size(); i++) {
if (instances.get(i) != null) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Removing RESTEasy Resource: " + instances.get(i));
}
resources.remove(instances.get(i));
}
}
_nettyServer.getDeployment().setResources(resources);
List<String> scannedProviders = new ArrayList<String>(_nettyServer.getDeployment().getScannedProviderClasses());
for (int i=0; providers != null && i<providers.size(); i++) {
if (providers.get(i) != null) {
scannedProviders.remove(providers.get(i));
}
}
_nettyServer.getDeployment().setScannedProviderClasses(scannedProviders);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Stopped StandaloneResource - Restarting Netty JAXRS Server: resources=" + resources + ", providers=" + scannedProviders);
}
_nettyServer.start();
}
});
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:65,代码来源:NettyResourcePublisher.java
示例7: publish
import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters; //导入依赖的package包/类
@Override
public Endpoint publish(ServiceDomain domain, String context, List<Object> instances, Map<String, String> contextParams) throws Exception {
OsgiRESTEasyServletRegistry servletRegistry = (OsgiRESTEasyServletRegistry) domain.getProperty(KEY_SERVLET_REGISTRY);
if (servletRegistry == null) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Creating OsgiRESTEasyServletRegistry");
}
servletRegistry = new OsgiRESTEasyServletRegistry().setOsgiHttpService(_httpService);
domain.setProperty(KEY_SERVLET_REGISTRY, servletRegistry);
}
String alias = context.startsWith("/") ? context : "/" + context;
OsgiRESTEasyServletWrapper servlet = servletRegistry.getRegisteredRESTEasyServlet(alias);
if (servlet == null) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Registering RESTEasy servlet with an alias '" + alias + "'");
}
servlet = new OsgiRESTEasyServletWrapper().setClassLoader(Classes.getTCCL());
Dictionary<String,String> initparams = new Hashtable<String,String>();
initparams.put(KEY_SERVLET_MAPPING_PREFIX, alias);
if (contextParams != null) {
for (Map.Entry<String, String> cp : contextParams.entrySet()) {
// @Provider must be registered manually by bundle class loader
if (!cp.getKey().equals(ResteasyContextParameters.RESTEASY_PROVIDERS)) {
initparams.put(cp.getKey(), cp.getValue());
}
}
}
servletRegistry.registerRESTEasyServlet(alias, servlet, initparams, null);
// A workaround for https://issues.jboss.org/browse/RESTEASY-640
ResteasyProviderFactory repFactory = servlet.getDispatcher().getProviderFactory();
for (Class<?> provider : RESTEasyProviders.PROVIDERS) {
repFactory.registerProvider(provider);
}
// Register @Provider classes
List<Class<?>> providerClasses = RESTEasyUtil.getProviderClasses(contextParams);
if (providerClasses != null) {
for (Class<?> pc : providerClasses) {
repFactory.registerProvider(pc);
}
}
}
List<Class<?>> resourceClasses = servletRegistry.registerRESTEasyResources(alias, instances);
return new OsgiRESTEasyResource()
.setServletRegistry(servletRegistry)
.setAlias(alias)
.setResourceClasses(resourceClasses);
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:52,代码来源:OsgiRESTEasyResourcePublisher.java
示例8: init
import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters; //导入依赖的package包/类
public void init(ServletContext servletContext, ConfigurationBootstrap bootstrap, HttpRequestFactory requestFactory,
HttpResponseFactory responseFactory) throws ServletException {
this.requestFactory = requestFactory;
this.responseFactory = responseFactory;
ResteasyProviderFactory globalFactory = (ResteasyProviderFactory) servletContext
.getAttribute(ResteasyProviderFactory.class.getName());
Dispatcher globalDispatcher = (Dispatcher) servletContext.getAttribute(Dispatcher.class.getName());
String application = bootstrap.getInitParameter("javax.ws.rs.Application");
String useGlobalStr = bootstrap.getInitParameter("resteasy.servlet.context.deployment");
boolean useGlobal = globalFactory != null;
if (useGlobalStr != null) {
useGlobal = Boolean.parseBoolean(useGlobalStr);
}
// use global is backward compatible with 2.3.x and earlier and will store and/or use the
// dispatcher and provider factory
// in the servlet context
if (useGlobal) {
this.providerFactory = globalFactory;
this.dispatcher = globalDispatcher;
if (((this.providerFactory != null) && (this.dispatcher == null))
|| ((this.providerFactory == null) && (this.dispatcher != null))) { throw new ServletException(
"Unknown state. You have a Listener messing up what resteasy expects"); }
// We haven't been initialized by an external entity so bootstrap ourselves
if (this.providerFactory == null) {
this.deployment = bootstrap.createDeployment();
this.deployment.start();
servletContext.setAttribute(ResteasyProviderFactory.class.getName(), this.deployment.getProviderFactory());
servletContext.setAttribute(Dispatcher.class.getName(), this.deployment.getDispatcher());
servletContext.setAttribute(Registry.class.getName(), this.deployment.getRegistry());
this.dispatcher = this.deployment.getDispatcher();
this.providerFactory = this.deployment.getProviderFactory();
} else {
// ResteasyBootstrap inited us. Check to see if the servlet defines an Application
// class
if (application != null) {
try {
Map contextDataMap = ResteasyProviderFactory.getContextDataMap();
contextDataMap.putAll(this.dispatcher.getDefaultContextObjects());
Application app = ResteasyDeployment.createApplication(application.trim(), this.dispatcher,
this.providerFactory);
// push context data so we can inject it
processApplication(app);
} finally {
ResteasyProviderFactory.removeContextDataLevel();
}
}
}
this.servletMappingPrefix = bootstrap.getParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX);
if (this.servletMappingPrefix == null) {
this.servletMappingPrefix = "";
}
this.servletMappingPrefix = this.servletMappingPrefix.trim();
} else {
this.deployment = bootstrap.createDeployment();
this.deployment.start();
this.dispatcher = this.deployment.getDispatcher();
this.providerFactory = this.deployment.getProviderFactory();
this.servletMappingPrefix = bootstrap.getParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX);
if (this.servletMappingPrefix == null) {
this.servletMappingPrefix = "";
}
this.servletMappingPrefix = this.servletMappingPrefix.trim();
}
}
开发者ID:trein,项目名称:gtfs-java,代码行数:71,代码来源:MultipleServletContainerDispatcher.java
注:本文中的org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论