use of com.sun.jersey.api.core.ApplicationAdapter in project camunda-bpm-platform by camunda.
the class JerseyServerBootstrap method setupServer.
private void setupServer(Application application) {
ResourceConfig rc = new ApplicationAdapter(application);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(ResourceConfig.FEATURE_TRACE, "true");
rc.setPropertiesAndFeatures(properties);
Properties serverProperties = readProperties();
int port = Integer.parseInt(serverProperties.getProperty(PORT_PROPERTY));
URI serverUri = UriBuilder.fromPath(ROOT_RESOURCE_PATH).scheme("http").host("localhost").port(port).build();
try {
server = GrizzlyServerFactory.createHttpServer(serverUri, rc);
} catch (IllegalArgumentException e) {
throw new ServerBootstrapException(e);
} catch (NullPointerException e) {
throw new ServerBootstrapException(e);
} catch (IOException e) {
throw new ServerBootstrapException(e);
}
}
use of com.sun.jersey.api.core.ApplicationAdapter in project nuxeo-filesystem-connectors by nuxeo.
the class WebDavServerFeature method setUpTomcat.
protected void setUpTomcat() throws Exception {
tomcat = new Tomcat();
// for tmp dir
tomcat.setBaseDir(".");
tomcat.setHostname(HOST);
tomcat.setPort(PORT);
ProtocolHandler p = tomcat.getConnector().getProtocolHandler();
AbstractEndpoint<?> endpoint = (AbstractEndpoint<?>) getFieldValue(p, "endpoint");
// vital for clean shutdown
endpoint.setMaxKeepAliveRequests(1);
File docBase = new File(".");
Context context = tomcat.addContext(CONTEXT, docBase.getAbsolutePath());
Application app = new org.nuxeo.ecm.webdav.Application();
ApplicationAdapter conf = new ApplicationAdapter(app);
conf.getFeatures().put(ResourceConfig.FEATURE_MATCH_MATRIX_PARAMS, Boolean.TRUE);
String servletName = "testServlet";
Servlet servlet = new ServletContainer(conf);
tomcat.addServlet(CONTEXT, servletName, servlet);
context.addServletMappingDecoded("/*", servletName);
addFilter(context, servletName, "RequestContextFilter", new RequestContextFilter());
addFilter(context, servletName, "SessionCleanupFilter", new SessionCleanupFilter());
addFilter(context, servletName, "NuxeoAuthenticationFilter", new NuxeoAuthenticationFilter());
addFilter(context, servletName, "WebEngineFilter", new WebEngineFilter());
tomcat.start();
}
use of com.sun.jersey.api.core.ApplicationAdapter in project SSM by Intel-bigdata.
the class SmartZeppelinServer method setupRestApiContextHandler.
private void setupRestApiContextHandler(WebAppContext webApp) throws Exception {
webApp.setSessionHandler(new SessionHandler());
// There are two sets of rest api: Zeppelin's and SSM's. They have different path.
ResourceConfig smartConfig = new ApplicationAdapter(new SmartRestApp());
ServletHolder smartServletHolder = new ServletHolder(new ServletContainer(smartConfig));
webApp.addServlet(smartServletHolder, SMART_PATH_SPEC);
ResourceConfig zeppelinConfig = new ApplicationAdapter(new ZeppelinRestApp());
ServletHolder zeppelinServletHolder = new ServletHolder(new ServletContainer(zeppelinConfig));
webApp.addServlet(zeppelinServletHolder, ZEPPELIN_PATH_SPEC);
String shiroIniPath = zconf.getShiroPath();
if (!StringUtils.isBlank(shiroIniPath)) {
webApp.setInitParameter("shiroConfigLocations", new File(shiroIniPath).toURI().toString());
SecurityUtils.initSecurityManager(shiroIniPath);
webApp.addFilter(ShiroFilter.class, ZEPPELIN_PATH_SPEC, EnumSet.allOf(DispatcherType.class));
// To make shiro configuration (authentication, etc.) take effect for smart rest api as well.
webApp.addFilter(ShiroFilter.class, SMART_PATH_SPEC, EnumSet.allOf(DispatcherType.class));
webApp.addEventListener(new EnvironmentLoaderListener());
}
}
Aggregations