/** * Return the first found {@link AsyncContextDelegateProvider} * (via {@link Providers#getAllProviders(InjectionManager, Class)}) or {@code #DEFAULT_ASYNC_DELEGATE} if * other delegate cannot be found. * * @return a non-null AsyncContextDelegateProvider. */ private AsyncContextDelegateProvider getAsyncExtensionDelegate() { final Iterator<AsyncContextDelegateProvider> providers = Providers.getAllProviders(appHandler.getInjectionManager(), AsyncContextDelegateProvider.class).iterator(); if (providers.hasNext()) { return providers.next(); } return (request, response) -> DEFAULT_ASYNC_DELEGATE; }
/** * Return the first found {@link AsyncContextDelegateProvider} * (via {@link Providers#getAllProviders(InjectionManager, Class)}) or {@code #DEFAULT_ASYNC_DELEGATE} if * other delegate cannot be found. * * @return a non-null AsyncContextDelegateProvider. */ private AsyncContextDelegateProvider getAsyncExtensionDelegate() { final Iterator<AsyncContextDelegateProvider> providers = Providers.getAllProviders(appHandler.getInjectionManager(), AsyncContextDelegateProvider.class).iterator(); if (providers.hasNext()) { return providers.next(); } return (request, response) -> DEFAULT_ASYNC_DELEGATE; }
/** * Resolve the {@link FilterUrlMappingsProvider} service via hk2. * * Will only work in Servlet 3 container, as the older API version * does not provide access to the filter mapping structure. * * @return {@code FilterContextPath} instance, if available, {@code null} otherwise. */ private FilterUrlMappingsProvider getFilterUrlMappingsProvider() { FilterUrlMappingsProvider filterUrlMappingsProvider = null; final Iterator<FilterUrlMappingsProvider> providers = Providers.getAllProviders( getApplicationHandler().getInjectionManager(), FilterUrlMappingsProvider.class).iterator(); if (providers.hasNext()) { filterUrlMappingsProvider = providers.next(); } return filterUrlMappingsProvider; }
/** * Resolve the {@link FilterUrlMappingsProvider} service via hk2. * * Will only work in Servlet 3 container, as the older API version * does not provide access to the filter mapping structure. * * @return {@code FilterContextPath} instance, if available, {@code null} otherwise. */ private FilterUrlMappingsProvider getFilterUrlMappingsProvider() { FilterUrlMappingsProvider filterUrlMappingsProvider = null; final Iterator<FilterUrlMappingsProvider> providers = Providers.getAllProviders( getApplicationHandler().getInjectionManager(), FilterUrlMappingsProvider.class).iterator(); if (providers.hasNext()) { filterUrlMappingsProvider = providers.next(); } return filterUrlMappingsProvider; }
/** * Get {@link java.util.concurrent.ExecutorService}. * * @return Executor service associated with this container. */ ExecutorService getExecutorService() { return appHandler.getInjectionManager().getInstance(ExecutorServiceProvider.class).getExecutorService(); }
/** * Get {@link ScheduledExecutorService}. * * @return Scheduled executor service associated with this container. */ ScheduledExecutorService getScheduledExecutorService() { return appHandler.getInjectionManager().getInstance(ScheduledExecutorServiceProvider.class).getExecutorService(); } }
/** * Set the request entity and entity input stream. Entity {@code null} values are ignored. * <p/> * {@link org.glassfish.jersey.server.ApplicationHandler} is required to obtain * {@link org.glassfish.jersey.message.MessageBodyWorkers} to transform the object into entity input stream used for * processing the request. * <p/> * NOTE: Entity transformation into entity input stream doesn't have any impact on benchmarks. * * @param entity request entity instance. * @param handler application handler to obtain message body workers from. * @return the updated builder. */ public ContainerRequestBuilder entity(final Object entity, final ApplicationHandler handler) { return entity(entity, handler.getInjectionManager().getInstance(MessageBodyWorkers.class)); }
this.configSetStatusOverSendError = ServerProperties.getValue(resourceConfig.getProperties(), ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, false, Boolean.class); this.backgroundTaskScheduler = appHandler.getInjectionManager() .getInstance(ScheduledExecutorService.class, BackgroundSchedulerLiteral.INSTANCE);
this.configSetStatusOverSendError = ServerProperties.getValue(resourceConfig.getProperties(), ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, false, Boolean.class); this.backgroundTaskScheduler = appHandler.getInjectionManager() .getInstance(ScheduledExecutorService.class, BackgroundSchedulerLiteral.INSTANCE);
/** * Return the first found {@link AsyncContextDelegateProvider} * (via {@link Providers#getAllProviders(InjectionManager, Class)}) or {@code #DEFAULT_ASYNC_DELEGATE} if * other delegate cannot be found. * * @return a non-null AsyncContextDelegateProvider. */ private AsyncContextDelegateProvider getAsyncExtensionDelegate() { final Iterator<AsyncContextDelegateProvider> providers = Providers.getAllProviders(appHandler.getInjectionManager(), AsyncContextDelegateProvider.class).iterator(); if (providers.hasNext()) { return providers.next(); } return (request, response) -> DEFAULT_ASYNC_DELEGATE; }
/** * Resolve the {@link FilterUrlMappingsProvider} service via hk2. * * Will only work in Servlet 3 container, as the older API version * does not provide access to the filter mapping structure. * * @return {@code FilterContextPath} instance, if available, {@code null} otherwise. */ private FilterUrlMappingsProvider getFilterUrlMappingsProvider() { FilterUrlMappingsProvider filterUrlMappingsProvider = null; final Iterator<FilterUrlMappingsProvider> providers = Providers.getAllProviders( getApplicationHandler().getInjectionManager(), FilterUrlMappingsProvider.class).iterator(); if (providers.hasNext()) { filterUrlMappingsProvider = providers.next(); } return filterUrlMappingsProvider; }
/** * Set the request entity and entity input stream. Entity {@code null} values are ignored. * <p/> * {@link org.glassfish.jersey.server.ApplicationHandler} is required to obtain * {@link org.glassfish.jersey.message.MessageBodyWorkers} to transform the object into entity input stream used for * processing the request. * <p/> * NOTE: Entity transformation into entity input stream doesn't have any impact on benchmarks. * * @param entity request entity instance. * @param handler application handler to obtain message body workers from. * @return the updated builder. */ public ContainerRequestBuilder entity(final Object entity, final ApplicationHandler handler) { return entity(entity, handler.getInjectionManager().getInstance(MessageBodyWorkers.class)); }
Providers.getAllProviders(applicationHandler.getInjectionManager(), ContainerLifecycleListener.class), new LinkedList<ContainerLifecycleListener>() {{ add(new ServiceLocatorShutdownListener());
@Override public void onShutdown(final Container container) { final ApplicationHandler handler = container.getApplicationHandler(); final InjectionManager injectionManager = handler.getInjectionManager(); // Call @PreDestroy method on Application. injectionManager.preDestroy(getWrappedApplication(handler.getConfiguration())); // Shutdown ServiceLocator. injectionManager.shutdown(); } }
this.configSetStatusOverSendError = ServerProperties.getValue(resourceConfig.getProperties(), ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, false, Boolean.class); this.backgroundTaskScheduler = appHandler.getInjectionManager() .getInstance(ScheduledExecutorService.class, BackgroundSchedulerLiteral.INSTANCE);