use of com.sun.jersey.api.core.PackagesResourceConfig in project ribbon by Netflix.
the class GetPostTest method init.
@BeforeClass
public static void init() throws Exception {
PackagesResourceConfig resourceConfig = new PackagesResourceConfig("com.netflix.niws.http", "com.netflix.niws.client");
int port = (new Random()).nextInt(1000) + 4000;
SERVICE_URI = "http://localhost:" + port + "/";
try {
server = HttpServerFactory.create(SERVICE_URI, resourceConfig);
server.start();
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
client = (RestClient) ClientFactory.getNamedClient("GetPostTest");
}
use of com.sun.jersey.api.core.PackagesResourceConfig in project ribbon by Netflix.
the class ExampleAppWithLocalResource method runApp.
@edu.umd.cs.findbugs.annotations.SuppressWarnings
public final void runApp() throws Exception {
PackagesResourceConfig resourceConfig = new PackagesResourceConfig("com.netflix.ribbon.examples.server");
ExecutorService service = Executors.newFixedThreadPool(50);
try {
server = HttpServerFactory.create(SERVICE_URI, resourceConfig);
server.setExecutor(service);
server.start();
run();
} finally {
System.err.println("Shut down server ...");
if (server != null) {
server.stop(1);
}
service.shutdownNow();
}
System.exit(0);
}
use of com.sun.jersey.api.core.PackagesResourceConfig in project ribbon by Netflix.
the class PrimeConnectionsTest method setup.
@BeforeClass
public static void setup() {
PackagesResourceConfig resourceConfig = new PackagesResourceConfig("com.netflix.niws.client.http");
SERVICE_URI = "http://localhost:" + port + "/";
try {
server = HttpServerFactory.create(SERVICE_URI, resourceConfig);
server.start();
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of com.sun.jersey.api.core.PackagesResourceConfig in project hive by apache.
the class Main method makeJerseyConfig.
public PackagesResourceConfig makeJerseyConfig() {
PackagesResourceConfig rc = new PackagesResourceConfig("org.apache.hive.hcatalog.templeton");
HashMap<String, Object> props = new HashMap<String, Object>();
props.put("com.sun.jersey.api.json.POJOMappingFeature", "true");
props.put("com.sun.jersey.config.property.WadlGeneratorConfig", "org.apache.hive.hcatalog.templeton.WadlConfig");
rc.setPropertiesAndFeatures(props);
return rc;
}
use of com.sun.jersey.api.core.PackagesResourceConfig in project ANNIS by korpling.
the class AnnisServiceRunner method createWebServer.
private void createWebServer() {
// create beans
ctx = new GenericXmlApplicationContext();
ctx.setValidating(false);
AnnisXmlContextHelper.prepareContext(ctx);
ctx.load("file:" + Utils.getAnnisFile("conf/spring/Service.xml").getAbsolutePath());
ctx.refresh();
ResourceConfig rc = new PackagesResourceConfig("annis.service.internal", "annis.provider", "annis.rest.provider");
final IoCComponentProviderFactory factory = new SpringComponentProviderFactory(rc, ctx);
int port = overridePort == null ? ctx.getBean(QueryServiceImpl.class).getPort() : overridePort;
try {
// only allow connections from localhost
// if the administrator wants to allow external acccess he *has* to
// use a HTTP proxy which also should use SSL encryption
InetSocketAddress addr = new InetSocketAddress("localhost", port);
server = new Server(addr);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
context.setContextPath("/");
server.setHandler(context);
server.setThreadPool(new ExecutorThreadPool());
ServletContainer jerseyContainer = new ServletContainer(rc) {
@Override
protected void initiate(ResourceConfig rc, WebApplication wa) {
wa.initiate(rc, factory);
}
};
ServletHolder holder = new ServletHolder(jerseyContainer);
context.addServlet(holder, "/*");
context.setInitParameter(EnvironmentLoader.ENVIRONMENT_CLASS_PARAM, MultipleIniWebEnvironment.class.getName());
if (useAuthentification) {
log.info("Using authentification");
context.setInitParameter(EnvironmentLoader.CONFIG_LOCATIONS_PARAM, "file:" + System.getProperty("annis.home") + "/conf/shiro.ini," + "file:" + System.getProperty("annis.home") + "/conf/develop_shiro.ini");
} else {
log.warn("*NOT* using authentification, your ANNIS service *IS NOT SECURED*");
context.setInitParameter(EnvironmentLoader.CONFIG_LOCATIONS_PARAM, "file:" + System.getProperty("annis.home") + "/conf/shiro_no_security.ini");
}
EnumSet<DispatcherType> gzipDispatcher = EnumSet.of(DispatcherType.REQUEST);
context.addFilter(GzipFilter.class, "/*", gzipDispatcher);
// configure Apache Shiro with the web application
context.addEventListener(new EnvironmentLoaderListener());
EnumSet<DispatcherType> shiroDispatchers = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.ERROR);
context.addFilter(ShiroFilter.class, "/*", shiroDispatchers);
} catch (IllegalArgumentException ex) {
log.error("IllegalArgumentException at ANNIS service startup", ex);
isShutdownRequested = true;
errorCode = 101;
} catch (NullPointerException ex) {
log.error("NullPointerException at ANNIS service startup", ex);
isShutdownRequested = true;
errorCode = 101;
} catch (AnnisRunnerException ex) {
errorCode = ex.getExitCode();
}
}
Aggregations