本文整理汇总了Java中org.glassfish.jersey.server.ApplicationHandler类的典型用法代码示例。如果您正苦于以下问题:Java ApplicationHandler类的具体用法?Java ApplicationHandler怎么用?Java ApplicationHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationHandler类属于org.glassfish.jersey.server包,在下文中一共展示了ApplicationHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SpringContextJerseyTest
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
/**
* An extending class must implement the {@link #configure()} method to
* provide an application descriptor.
*
* @throws TestContainerException if the default test container factory
* cannot be obtained, or the application descriptor is not
* supported by the test container factory.
*/
public SpringContextJerseyTest() throws TestContainerException {
ResourceConfig config = getResourceConfig(configure());
config.register(new ServiceFinderBinder<TestContainerFactory>(TestContainerFactory.class, null, RuntimeType.SERVER));
if (isLogRecordingEnabled()) {
registerLogHandler();
}
this.application = new ApplicationHandler(config);
this.tc = getContainer(application, getTestContainerFactory());
if (isLogRecordingEnabled()) {
loggedStartupRecords.addAll(loggedRuntimeRecords);
loggedRuntimeRecords.clear();
unregisterLogHandler();
}
}
示例2: testBinder
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
/**
* Test the application binder.
*/
@Test
public void testBinder() {
ResourceConfig config = new ResourceConfig();
config.register(TestFeature.class);
// Make sure it's registered
Assert.assertTrue(config.isRegistered(TestFeature.class));
// Create a fake application.
ApplicationHandler handler = new ApplicationHandler(config);
ServiceRegistry serviceRegistry = handler
.getServiceLocator().getService(ServiceRegistry.class);
Assert.assertNotNull(serviceRegistry);
// Make sure it's reading from the same place.
Dialect d = new MetadataSources(serviceRegistry)
.buildMetadata().getDatabase().getDialect();
Assert.assertTrue(d instanceof H2Dialect);
// Make sure it's a singleton...
ServiceRegistry serviceRegistry2 = handler
.getServiceLocator().getService(ServiceRegistry.class);
Assert.assertSame(serviceRegistry, serviceRegistry2);
}
示例3: HttpServer
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
public HttpServer(String serverIdentifier, HttpConfiguration http, Timer timer, ApplicationHandler applicationHandler) {
PooledByteBufAllocator allocator = new PooledByteBufAllocator(http.isDirectMemoryBacked());
this.serverIdentifier = serverIdentifier;
this.host = http.getHost();
this.port = http.getPort();
this.requestProcessingExecutor = Executors.newFixedThreadPool(http.getNumRequestProcessingThreads(), Threads.newNamedThreadFactory(serverIdentifier + "-requests-%d"));
this.bossEventLoopGroup = new NioEventLoopGroup(com.aerofs.baseline.http.Constants.DEFAULT_NUM_BOSS_THREADS, Threads.newNamedThreadFactory(serverIdentifier + "-nio-boss-%d"));
this.workEventLoopGroup = new NioEventLoopGroup(http.getNumNetworkThreads(), Threads.newNamedThreadFactory(serverIdentifier + "-nio-work-%d"));
this.bootstrap = new ServerBootstrap();
this.bootstrap
.group(bossEventLoopGroup, workEventLoopGroup)
.channel(NioServerSocketChannel.class)
.childHandler(new AcceptedChannelInitializer(http, applicationHandler, URI.create(String.format("http://%s:%s/", host, port)), requestProcessingExecutor, timer))
.option(ALLOCATOR, allocator)
.option(SO_BACKLOG, http.getMaxAcceptQueueSize())
.childOption(AUTO_READ, false)
.childOption(ALLOCATOR, allocator);
}
示例4: CdiAwareInMemoryTestContainer
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
/**
* Constructor
*
* @param baseUri
* @param context
*/
public CdiAwareInMemoryTestContainer(final URI baseUri, final DeploymentContext context) {
this.baseUri = UriBuilder.fromUri(baseUri).path(context.getContextPath()).build();
if (CdiAwareInMemoryTestContainer.LOGGER.isLoggable(Level.INFO)) {
CdiAwareInMemoryTestContainer.LOGGER
.info("Creating InMemoryTestContainer configured at the base URI " + this.baseUri);
}
// TODO: Hack is here...
// HandlerWrapper cdiHandlerWrapper = new CdiAwareHandlerWrapper();
// cdiHandlerWrapper.setHandler(this.server.getHandler());
// this.server.setHandler(cdiHandlerWrapper);
this.appHandler = new ApplicationHandler(context.getResourceConfig());
}
示例5: setup
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
@BeforeMethod
public void setup() {
applicationMapping = mock(ApplicationMapping.class);
request = mock(FullHttpRequest.class);
response = mock(FullHttpResponse.class);
when(request.getMethod()).thenReturn(HttpMethod.GET);
when(request.getUri()).thenReturn("/test");
when(request.headers()).thenReturn(new DefaultHttpHeaders());
when(request.content()).thenReturn(mock(ByteBuf.class));
when(request.getProtocolVersion()).thenReturn(HttpVersion.HTTP_1_1);
when(response.getStatus()).thenReturn(HttpResponseStatus.PROCESSING);
application = mock(Application.class);
context = mock(MessageContext.class);
router = spy(new Router(applicationMapping));
doReturn(new ApplicationHandler()).when(router).getApplicationHandler(application);
when(application.getPath()).thenReturn(URI.create("/app"));
when(context.getRequest()).thenReturn(request);
when(context.getResponse()).thenReturn(response);
when(context.getApplication()).thenReturn(application);
when(context.getBaseUri()).thenReturn(URI.create("http://localhost:8080"));
when(applicationMapping.resolve(request)).thenReturn(application);
}
示例6: getClient
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
/**
* Creates an instance of {@link Client}.
* <p/>
* Checks whether TestContainer provides ClientConfig instance and
* if not, empty new {@link org.glassfish.jersey.client.ClientConfig} instance
* will be used to create new client instance.
* <p/>
* This method is called exactly once when JerseyTest is created.
*
* @param tc instance of {@link TestContainer}
* @param applicationHandler instance of {@link ApplicationHandler}
* @return A Client instance.
*/
protected Client getClient(TestContainer tc, ApplicationHandler applicationHandler) {
ClientConfig cc = tc.getClientConfig();
if (cc == null) {
cc = new ClientConfig();
}
//check if logging is required
if (isEnabled(TestProperties.LOG_TRAFFIC)) {
cc.register(new LoggingFilter(LOGGER, isEnabled(TestProperties.DUMP_ENTITY)));
}
configureClient(cc);
return ClientBuilder.newClient(cc);
}
开发者ID:amacoder,项目名称:demo-restWS-spring-jersey-tomcat-mybatis,代码行数:30,代码来源:SpringContextJerseyTest.java
示例7: JerseyLambdaContainerHandler
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
/**
* Private constructor for a LambdaContainer. Sets the application object, sets the ApplicationHandler,
* and initializes the application using the <code>onStartup</code> method.
* @param requestReader A request reader instance
* @param responseWriter A response writer instance
* @param securityContextWriter A security context writer object
* @param exceptionHandler An exception handler
* @param jaxRsApplication The JaxRs application
*/
public JerseyLambdaContainerHandler(RequestReader<RequestType, ContainerRequest> requestReader,
ResponseWriter<JerseyResponseWriter, ResponseType> responseWriter,
SecurityContextWriter<RequestType> securityContextWriter,
ExceptionHandler<ResponseType> exceptionHandler,
Application jaxRsApplication) {
super(requestReader, responseWriter, securityContextWriter, exceptionHandler);
this.jaxRsApplication = jaxRsApplication;
this.applicationHandler = new ApplicationHandler(jaxRsApplication);
applicationHandler.onStartup(this);
}
示例8: reload
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
/**
* Shuts down and restarts the application handler in the current container. The <code>ApplicationHandler</code>
* object is re-initialized with the <code>Application</code> object initially set in the <code>LambdaContainer.getInstance()</code>
* call.
*/
public void reload() {
applicationHandler.onShutdown(this);
this.applicationHandler = new ApplicationHandler(jaxRsApplication);
applicationHandler.onReload(this);
applicationHandler.onStartup(this);
}
示例9: reload_ConfigGiven_ShouldReloadNewAppHandler
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
@Test
public void reload_ConfigGiven_ShouldReloadNewAppHandler() {
ResourceConfig config = new ApplicationHandler().getConfiguration();
ApplicationHandler newAppHandler = mock(ApplicationHandler.class);
doReturn(newAppHandler).when(container).createNewApplicationHandler(any());
container.reload(config);
verify(newAppHandler, times(1)).onReload(container);
}
示例10: reload_ConfigGiven_ShouldStartNewAppHandler
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
@Test
public void reload_ConfigGiven_ShouldStartNewAppHandler() {
ResourceConfig config = new ApplicationHandler().getConfiguration();
ApplicationHandler newAppHandler = mock(ApplicationHandler.class);
doReturn(newAppHandler).when(container).createNewApplicationHandler(any());
container.reload(config);
verify(newAppHandler, times(1)).onStartup(container);
}
示例11: reload_ConfigGiven_ShouldResetAppHandler
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
@Test
public void reload_ConfigGiven_ShouldResetAppHandler() {
ResourceConfig config = new ApplicationHandler().getConfiguration();
ApplicationHandler newAppHandler = mock(ApplicationHandler.class);
doReturn(newAppHandler).when(container).createNewApplicationHandler(any());
container.reload(config);
assertSame(newAppHandler, container.getApplicationHandler());
}
示例12: getService
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
protected <T> T getService(Class<T> clazz) {
return new ApplicationHandler(configure().register(new GenericBinder<T>() {
public Class<T> getType() {
return clazz;
}
})).getServiceLocator().getService(clazz);
}
示例13: getContainer
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
private TestContainer getContainer(ApplicationHandler application, TestContainerFactory tcf) {
if (application == null) {
throw new IllegalArgumentException("The application cannot be null");
}
return tcf.create(getBaseUri(), application);
}
示例14: onAfterShutdown
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
@Override
public void onAfterShutdown(Object obj) {
if (container instanceof NettyRestHandlerContainer) {
NettyRestHandlerContainer restHandlerContainer = ((NettyRestHandlerContainer) container);
ApplicationHandler applicationHandler = restHandlerContainer.getApplicationHandler();
ContainerLifecycleListener lifecycleListener = ConfigHelper.getContainerLifecycleListener(applicationHandler);
lifecycleListener.onShutdown(container);
}
}
示例15: onAfterStart
import org.glassfish.jersey.server.ApplicationHandler; //导入依赖的package包/类
@Override
public void onAfterStart(Object obj) {
if (container instanceof NettyRestHandlerContainer) {
NettyRestHandlerContainer restHandlerContainer = ((NettyRestHandlerContainer) container);
ApplicationHandler applicationHandler = restHandlerContainer.getApplicationHandler();
ContainerLifecycleListener lifecycleListener = ConfigHelper.getContainerLifecycleListener(applicationHandler);
lifecycleListener.onStartup(container);
}
}