本文整理了Java中org.jboss.resteasy.core.Dispatcher
类的一些代码示例,展示了Dispatcher
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dispatcher
类的具体详情如下:
包路径:org.jboss.resteasy.core.Dispatcher
类名称:Dispatcher
暂无
代码示例来源:origin: alipay/sofa-rpc
providerFactory = new ResteasyProviderFactory();
providerFactory.setRegisterBuiltins(registerBuiltin);
if (ResteasyProviderFactory.peekInstance() == null ||
!(ResteasyProviderFactory.peekInstance() instanceof ThreadLocalResteasyProviderFactory))
dispatcher = dis;
registry = dispatcher.getRegistry();
if (widerRequestMatching)
dispatcher.getDefaultContextObjects().putAll(defaultContextObjects);
dispatcher.getDefaultContextObjects().put(Configurable.class, providerFactory);
dispatcher.getDefaultContextObjects().put(Providers.class, providerFactory);
dispatcher.getDefaultContextObjects().put(Registry.class, registry);
dispatcher.getDefaultContextObjects().put(Dispatcher.class, dispatcher);
dispatcher.getDefaultContextObjects().put(InternalDispatcher.class, InternalDispatcher.getInstance());
Map contextDataMap = ResteasyProviderFactory.getContextDataMap();
contextDataMap.putAll(dispatcher.getDefaultContextObjects());
dispatcher.getDefaultContextObjects().put(key, obj);
contextDataMap.put(key, obj);
代码示例来源:origin: atomix/atomix
deployment.start();
deployment.getDispatcher().getDefaultContextObjects()
.put(ClusterMembershipService.class, atomix.getMembershipService());
deployment.getDispatcher().getDefaultContextObjects()
.put(ClusterCommunicationService.class, atomix.getCommunicationService());
deployment.getDispatcher().getDefaultContextObjects()
.put(ClusterEventService.class, atomix.getEventService());
deployment.getDispatcher().getDefaultContextObjects()
.put(PrimitiveFactory.class, atomix.getPrimitivesService());
deployment.getDispatcher().getDefaultContextObjects()
.put(PrimitivesService.class, atomix.getPrimitivesService());
deployment.getDispatcher().getDefaultContextObjects()
.put(EventManager.class, new EventManager());
deployment.getDispatcher().getDefaultContextObjects()
.put(AtomixRegistry.class, atomix.getRegistry());
deployment.getDispatcher().getProviderFactory().register(new JacksonProvider(createObjectMapper()));
代码示例来源:origin: stackoverflow.com
Dispatcher dispatcher = MockDispatcherFactory.createDispatcher();
dispatcher.getRegistry().addSingletonResource(new Service());
ResteasyProviderFactory
.getContextDataMap()
.put(HttpServletRequest.class, new MockHttpServletRequest());
MockHttpResponse response = new MockHttpResponse();
dispatcher.invoke(
MockHttpRequest.get("/"),
response
);
代码示例来源:origin: com.peterphi.std.guice/stdlib-guice-webapp
dispatcher.getDispatcher().getDefaultContextObjects().put(FilterConfig.class, filterConfig);
if (servletConfig != null)
dispatcher.getDispatcher().getDefaultContextObjects().put(ServletConfig.class, servletConfig);
resteasyRegistry = dispatcher.getDispatcher().getRegistry();
providerFactory = dispatcher.getDispatcher().getProviderFactory();
providerFactory.registerProvider(providerClass);
providerFactory.registerProviderInstance(provider);
providerFactory.registerProviderInstance(new LogReportMessageBodyReader());
providerFactory.registerProviderInstance(jaxbContextResolver);
代码示例来源:origin: io.takari.siesta/siesta-server
private void doInit(final ServletConfig servletConfig) throws ServletException {
deployment.start();
servletConfig.getServletContext().setAttribute(ResteasyDeployment.class.getName(), deployment);
super.init(servletConfig);
if (log.isDebugEnabled()) {
ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();
log.debug("Provider factory: {}", providerFactory);
log.debug("Configuration: {}", providerFactory.getConfiguration());
log.debug("Runtime type: {}", providerFactory.getRuntimeType());
log.debug("Built-ins registered: {}", providerFactory.isBuiltinsRegistered());
log.debug("Properties: {}", providerFactory.getProperties());
log.debug("Dynamic features: {}", providerFactory.getServerDynamicFeatures());
log.debug("Enabled features: {}", providerFactory.getEnabledFeatures());
log.debug("Class contracts: {}", providerFactory.getClassContracts());
log.debug("Reader interceptor registry: {}", providerFactory.getServerReaderInterceptorRegistry());
log.debug("Writer interceptor registry: {}", providerFactory.getServerWriterInterceptorRegistry());
log.debug("Injector factory: {}", providerFactory.getInjectorFactory());
log.debug("Instances: {}", providerFactory.getInstances());
log.debug("Exception mappers: {}", providerFactory.getExceptionMappers());
}
}
代码示例来源:origin: org.jboss.resteasy/resteasy-test-tjws
ResteasyProviderFactory defaultInstance = ResteasyProviderFactory.getInstance();
if (defaultInstance instanceof ThreadLocalResteasyProviderFactory)
ResteasyProviderFactory.pushContext(HttpServletRequest.class, request);
ResteasyProviderFactory.pushContext(HttpServletResponse.class, response);
ResteasyProviderFactory.pushContext(SecurityContext.class, new ServletSecurityContext(request));
if (handleNotFound)
dispatcher.invoke(in, theResponse);
代码示例来源:origin: HotswapProjects/HotswapAgent
Registry registry = (Registry) context.getAttribute(Registry.class.getName());
if (registry == null) {
registry = servletContainerDispatcher.getDispatcher().getRegistry();
代码示例来源:origin: io.takari.siesta/siesta-server
@Override
public void addComponent(final BeanEntry<?, ?> entry) throws Exception {
Class<?> type = entry.getImplementationClass();
if (isResource(type)) {
getDispatcher().getRegistry().addResourceFactory(new SisuResourceFactory(entry));
String path = resourcePath(type);
if (path == null) {
log.warn("Found resource implementation missing @Path: {}", type.getName());
}
else {
log.debug("Added resource: {} with path: {}", type.getName(), path);
}
}
else {
// TODO: Doesn't seem to be a late-biding/factory here so we create the object early
getDispatcher().getProviderFactory().register(entry.getValue());
log.debug("Added component: {}", type.getName());
}
}
代码示例来源:origin: org.jboss.resteasy/resteasy-test-tjws
for (Class clazz : actualProviderClasses) providerFactory.registerProvider(clazz);
for (Object obj : providers) providerFactory.registerProviderInstance(obj);
for (Class clazz : actualResourceClasses) dispatcher.getRegistry().addPerRequestResource(clazz);
for (Object obj : resources) dispatcher.getRegistry().addSingletonResource(obj);
代码示例来源:origin: io.takari.siesta/siesta-server
@Override
public void removeComponent(final BeanEntry<?, ?> entry) throws Exception {
Class<?> type = entry.getImplementationClass();
if (isResource(type)) {
getDispatcher().getRegistry().removeRegistrations(type);
String path = resourcePath(type);
log.debug("Removed resource: {} with path: {}", type.getName(), path);
}
else {
ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();
if (providerFactory instanceof SisuResteasyProviderFactory) {
((SisuResteasyProviderFactory) providerFactory).removeRegistrations(type);
log.debug("Removed component: {}", type.getName());
}
else {
log.warn("Component removal not supported; Unable to remove component: {}", type.getName());
}
}
}
}
代码示例来源:origin: org.jboss.resteasy/resteasy-jaxrs-20
public static Application createApplication(String applicationClass, Dispatcher dispatcher, ResteasyProviderFactory providerFactory)
{
Class<?> clazz = null;
try
{
clazz = Thread.currentThread().getContextClassLoader().loadClass(applicationClass);
}
catch (ClassNotFoundException e)
{
throw new RuntimeException(e);
}
Application app = (Application)providerFactory.createProviderInstance(clazz);
dispatcher.getDefaultContextObjects().put(Application.class, app);
ResteasyProviderFactory.pushContext(Application.class, app);
PropertyInjector propertyInjector = providerFactory.getInjectorFactory().createPropertyInjector(clazz, providerFactory);
propertyInjector.inject(app);
return app;
}
代码示例来源:origin: com.arcbees/guicy-resteasy
@Override
public void init(FilterConfig servletConfig) throws ServletException {
super.init(servletConfig);
Registry registry = getDispatcher().getRegistry();
ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();
for (final Binding<?> binding : injector.getBindings().values()) {
Type type = binding.getKey().getTypeLiteral().getType();
if (type instanceof Class) {
Class<?> beanClass = (Class) type;
if (GetRestful.isRootResource(beanClass)) {
ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
registry.addResourceFactory(resourceFactory);
}
if (beanClass.isAnnotationPresent(Provider.class)) {
providerFactory.registerProviderInstance(binding.getProvider().get());
}
}
}
}
}
代码示例来源:origin: stackoverflow.com
public void test() throws Exception {
Dispatcher dispatcher = MockDispatcherFactory.createDispatcher();
dispatcher.getProviderFactory().getServerPreProcessInterceptorRegistry().register(new MyInterceptor());
dispatcher.getRegistry().addSingletonResource(new InterceptedResource());
dispatcher.invoke(request, response);
代码示例来源:origin: org.jboss.resteasy/resteasy-jaxrs-20
public static Dispatcher createDispatcher()
{
Dispatcher dispatcher = new SynchronousDispatcher(new ResteasyProviderFactory());
ResteasyProviderFactory.setInstance(dispatcher.getProviderFactory());
RegisterBuiltin.register(dispatcher.getProviderFactory());
return dispatcher;
}
}
代码示例来源:origin: org.jboss.resteasy/resteasy-jaxrs-20
if (application != null)
dispatcher.getDefaultContextObjects().put(Application.class, application);
ResteasyProviderFactory.getContextDataMap().put(Application.class, application);
if (processApplication(application))
providerFactory.registerProviderInstance(provider);
providerFactory.registerProvider(actualProviderClass);
代码示例来源:origin: org.jboss.resteasy/resteasy-jaxrs-20
@Override
public HttpResponse createResteasyHttpResponse(HttpServletResponse response)
{
return new HttpServletResponseWrapper(response, getDispatcher().getProviderFactory()) {
@Override
public void addNewCookie(NewCookie cookie)
{
outputHeaders.add(javax.ws.rs.core.HttpHeaders.SET_COOKIE, cookie);
}
};
}
代码示例来源:origin: info.magnolia.rest/magnolia-rest-integration
@Override
public void init(ServletConfig servletConfig) throws ServletException {
this.servletConfig = servletConfig;
// Initialise the ServletContainerDispatcher
servletContainerDispatcher = new ServletContainerDispatcher();
ConfigurationBootstrap bootstrap = createBootstrap(servletConfig);
servletContainerDispatcher.init(servletConfig.getServletContext(), bootstrap, this, this);
servletContainerDispatcher.getDispatcher().getDefaultContextObjects().put(ServletConfig.class, servletConfig);
// Register additional providers that have been configured
for (AdditionalProviderDefinition provider : restIntegrationModule.getAdditionalProviders()) {
log.debug("Registering additional provider [{}]", provider.getProviderClass());
super.getDispatcher().getProviderFactory().registerProvider(provider.getProviderClass());
}
// Register all currently registered endpoints
for (DefinitionProvider<EndpointDefinition> provider : endpointRegistry.getAllProviders()) {
try {
registerEndpoint(provider);
} catch (Exception e) {
log.error("Failed to register endpoint [{}]", provider.getMetadata().getReferenceId(), e);
// Others should continue to be registered.
}
}
// Listen for changes to the registry to observe endpoints being added or removed
registerHandler = systemEventBus.addHandler(EndpointDefinitionRegistryEvent.class, this);
}
代码示例来源:origin: jboss-switchyard/components
ResteasyProviderFactory repFactory = servlet.getDispatcher().getProviderFactory();
for (Class<?> provider : RESTEasyProviders.PROVIDERS) {
repFactory.registerProvider(provider);
if (providerClasses != null) {
for (Class<?> pc : providerClasses) {
repFactory.registerProvider(pc);
代码示例来源:origin: org.overlord.sramp/s-ramp-client
/**
* @throws Exception
*/
public static void registerServices() throws Exception {
// use the in-memory config for unit tests
System.setProperty("sramp.modeshape.config.url", "classpath://" + AbstractNoAuditingJCRPersistenceTest.class.getName() //$NON-NLS-1$ //$NON-NLS-2$
+ "/META-INF/modeshape-configs/junit-sramp-config.json"); //$NON-NLS-1$
deployment.getProviderFactory().registerProvider(SrampAtomExceptionProvider.class);
deployment.getProviderFactory().registerProvider(HttpResponseProvider.class);
dispatcher.getRegistry().addPerRequestResource(ArtifactResource.class);
dispatcher.getRegistry().addPerRequestResource(FeedResource.class);
dispatcher.getRegistry().addPerRequestResource(BatchResource.class);
dispatcher.getRegistry().addPerRequestResource(QueryResource.class);
dispatcher.getRegistry().addPerRequestResource(OntologyResource.class);
dispatcher.getRegistry().addPerRequestResource(AuditResource.class);
dispatcher.getRegistry().addPerRequestResource(ServiceDocumentResource.class);
}
代码示例来源:origin: org.jboss.seam/jboss-seam-resteasy
protected void registerSeamComponentProvider(Component seamComponent)
{
log.debug("registering provider as Seam component: {0}", seamComponent.getName());
getDispatcher().getProviderFactory().registerProviderInstance(
Component.getInstance(seamComponent.getName())
);
}
内容来源于网络,如有侵权,请联系作者删除!