use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class JettyContainerTest method testParentServiceLocator.
/**
* Test that defined ServiceLocator becomes a parent of the newly created service locator.
*/
@Test
public void testParentServiceLocator() {
final ServiceLocator locator = new ServiceLocatorImpl("MyServiceLocator", null);
final Server server = JettyHttpContainerFactory.createServer(URI.create("http://localhost:9876"), new ResourceConfig(Resource.class), false, locator);
JettyHttpContainer container = (JettyHttpContainer) server.getHandler();
InjectionManager injectionManager = container.getApplicationHandler().getInjectionManager();
HK2InjectionManager hk2InjectionManager = (HK2InjectionManager) injectionManager;
ServiceLocator serviceLocator = hk2InjectionManager.getServiceLocator();
assertTrue("Application injection manager was expected to have defined parent locator", serviceLocator.getParent() == locator);
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class Server method start.
/**
* Start SSL-secured HTTP test server.
*
* @throws IOException in case there is an error while reading server key store or trust store.
* @return an instance of the started SSL-secured HTTP test server.
*/
public static Server start(String keystore) throws IOException {
final InputStream trustStore = Server.class.getResourceAsStream(SERVER_TRUST_STORE);
final InputStream keyStore = Server.class.getResourceAsStream(keystore);
// Grizzly ssl configuration
SSLContextConfigurator sslContext = new SSLContextConfigurator();
// set up security context
// contains server key pair
sslContext.setKeyStoreBytes(ByteStreams.toByteArray(keyStore));
sslContext.setKeyStorePass("asdfgh");
// contains client certificate
sslContext.setTrustStoreBytes(ByteStreams.toByteArray(trustStore));
sslContext.setTrustStorePass("asdfgh");
ResourceConfig rc = new ResourceConfig();
rc.register(new LoggingFeature(LOGGER, LoggingFeature.Verbosity.PAYLOAD_ANY));
rc.registerClasses(RootResource.class, SecurityFilter.class, AuthenticationExceptionMapper.class);
final HttpServer grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc, true, new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(true));
// start Grizzly embedded server //
LOGGER.info("Jersey app started. Try out " + BASE_URI + "\nHit CTRL + C to stop it...");
grizzlyServer.start();
return new Server(grizzlyServer);
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class ResponseReadAndBufferEntityTest method configure.
@Override
protected Application configure() {
enable(TestProperties.DUMP_ENTITY);
enable(TestProperties.LOG_TRAFFIC);
return new ResourceConfig(Resource.class).registerInstances(new LoggingFeature(LOGGER, LoggingFeature.Verbosity.PAYLOAD_ANY));
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class ProvidersLegacyOrderingTest method configure.
@Override
protected Application configure() {
final ResourceConfig resourceConfig = new ResourceConfig(MyResource.class, MyMBW5.class, MyMBW6.class);
resourceConfig.property(MessageProperties.LEGACY_WORKERS_ORDERING, true);
return resourceConfig;
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class ResponseLinksTest method configure.
@Override
protected Application configure() {
ResourceConfig resourceConfig = new ResourceConfig(MyResource.class);
resourceConfig.register(LoggingFeature.class);
return resourceConfig;
}
Aggregations