use of javax.servlet.http.HttpServlet in project opennms by OpenNMS.
the class Activator method createAndRegisterVaadinResourceServlet.
private void createAndRegisterVaadinResourceServlet() {
Bundle vaadin = null;
for (Bundle bundle : bundleContext.getBundles()) {
if ("com.vaadin.client-compiled".equals(bundle.getSymbolicName())) {
vaadin = bundle;
break;
}
}
Dictionary<String, String> props;
props = new Hashtable<String, String>();
props.put("alias", VaadinResourceServlet.VAADIN);
HttpServlet vaadinResourceServlet = new VaadinResourceServlet(vaadin);
resourceService = bundleContext.registerService(Servlet.class.getName(), vaadinResourceServlet, props);
bundleContext.registerService(VaadinResourceService.class.getName(), vaadinResourceServlet, null);
}
use of javax.servlet.http.HttpServlet in project jena by apache.
the class SPARQLServer method buildServer.
// Later : private and in constructor.
private ServletContextHandler buildServer(String jettyConfig, boolean enableCompression) {
if (jettyConfig != null) {
// --jetty-config=jetty-fuseki.xml
// for detailed configuration of the server using Jetty features.
server = configServer(jettyConfig);
} else
server = defaultServerConfig(serverConfig.port, serverConfig.loopback);
// Keep the server to a maximum number of threads.
// server.setThreadPool(new QueuedThreadPool(ThreadPoolSize)) ;
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setErrorHandler(new FusekiErrorHandler());
context.addEventListener(new FusekiServletContextListener(this));
// Increase form size.
context.getServletContext().getContextHandler().setMaxFormContentSize(10 * 1000 * 1000);
// Wire up authentication if appropriate
if (jettyConfig == null && serverConfig.authConfigFile != null) {
Constraint constraint = new Constraint();
constraint.setName(Constraint.__BASIC_AUTH);
constraint.setRoles(new String[] { "fuseki" });
constraint.setAuthenticate(true);
ConstraintMapping mapping = new ConstraintMapping();
mapping.setConstraint(constraint);
mapping.setPathSpec("/*");
IdentityService identService = new DefaultIdentityService();
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
securityHandler.addConstraintMapping(mapping);
securityHandler.setIdentityService(identService);
HashLoginService loginService = new HashLoginService("Fuseki Authentication", serverConfig.authConfigFile);
loginService.setIdentityService(identService);
securityHandler.setLoginService(loginService);
securityHandler.setAuthenticator(new BasicAuthenticator());
context.setSecurityHandler(securityHandler);
serverLog.debug("Basic Auth Configuration = " + serverConfig.authConfigFile);
}
// Wire up context handler to server
server.setHandler(context);
// Constants. Add RDF types.
MimeTypes mt = new MimeTypes();
mt.addMimeMapping("rdf", WebContent.contentTypeRDFXML + ";charset=utf-8");
mt.addMimeMapping("ttl", WebContent.contentTypeTurtle + ";charset=utf-8");
mt.addMimeMapping("nt", WebContent.contentTypeNTriples + ";charset=ascii");
mt.addMimeMapping("nq", WebContent.contentTypeNQuads + ";charset=ascii");
mt.addMimeMapping("trig", WebContent.contentTypeTriG + ";charset=utf-8");
// mt.addMimeMapping("tpl", "text/html;charset=utf-8") ;
context.setMimeTypes(mt);
server.setHandler(context);
serverLog.debug("Pages = " + serverConfig.pages);
boolean installManager = true;
boolean installServices = true;
String validationRoot = "/validate";
if (installManager || installServices) {
// TODO Respect port.
if (serverConfig.pagesPort != serverConfig.port)
serverLog.warn("Not supported yet - pages on a different port to services");
if (serverConfig.pages != null) {
if (!FileOps.exists(serverConfig.pages))
serverLog.warn("No pages directory - " + serverConfig.pages);
String base = serverConfig.pages;
Map<String, Object> data = new HashMap<>();
data.put("mgt", new MgtFunctions());
SimpleVelocityServlet templateEngine = new SimpleVelocityServlet(base, data);
addServlet(context, templateEngine, "*.tpl", false);
}
}
if (installManager) {
// Action when control panel selects a dataset.
HttpServlet datasetChooser = new ActionDataset();
addServlet(context, datasetChooser, PageNames.actionDatasetNames, false);
}
if (installServices) {
// Validators
HttpServlet validateQuery = new QueryValidator();
HttpServlet validateUpdate = new UpdateValidator();
HttpServlet validateData = new DataValidator();
HttpServlet validateIRI = new IRIValidator();
HttpServlet dumpService = new DumpServlet();
HttpServlet generalQueryService = new SPARQL_QueryGeneral();
addServlet(context, validateQuery, validationRoot + "/query", false);
addServlet(context, validateUpdate, validationRoot + "/update", false);
addServlet(context, validateData, validationRoot + "/data", false);
addServlet(context, validateIRI, validationRoot + "/iri", false);
// general query processor.
addServlet(context, generalQueryService, HttpNames.ServiceGeneralQuery, enableCompression);
}
if (installManager || installServices) {
String[] files = { "fuseki.html", "index.html" };
context.setWelcomeFiles(files);
addContent(context, "/", serverConfig.pages);
}
return context;
}
use of javax.servlet.http.HttpServlet in project jena by apache.
the class SPARQLServer method configureOneDataset.
private void configureOneDataset(ServletContextHandler context, DatasetRef dsDesc, boolean enableCompression) {
String datasetPath = dsDesc.name;
if (datasetPath.equals("/"))
datasetPath = "";
else if (!datasetPath.startsWith("/"))
datasetPath = "/" + datasetPath;
if (datasetPath.endsWith("/"))
datasetPath = datasetPath.substring(0, datasetPath.length() - 1);
dsDesc.init();
if (DatasetRegistry.get().isRegistered(datasetPath))
throw new FusekiException("Already registered: " + datasetPath);
DatasetRegistry.get().put(datasetPath, dsDesc);
serverLog.info(format("Dataset path = %s", datasetPath));
HttpServlet sparqlQuery = new SPARQL_QueryDataset();
HttpServlet sparqlUpdate = new SPARQL_Update();
HttpServlet sparqlUpload = new SPARQL_Upload();
HttpServlet sparqlHttpR = new SPARQL_REST_R();
HttpServlet sparqlHttpRW = new SPARQL_REST_RW();
HttpServlet sparqlDataset = new SPARQL_UberServlet.AccessByConfig();
if (!überServlet) {
// If uberserver, these are unnecessary but can be used.
// If just means the überservlet isn't handling these operations.
addServlet(context, datasetPath, sparqlQuery, dsDesc.query, enableCompression);
addServlet(context, datasetPath, sparqlUpdate, dsDesc.update, false);
// No point - no results of any size.
addServlet(context, datasetPath, sparqlUpload, dsDesc.upload, false);
addServlet(context, datasetPath, sparqlHttpR, dsDesc.readGraphStore, enableCompression);
addServlet(context, datasetPath, sparqlHttpRW, dsDesc.readWriteGraphStore, enableCompression);
// This adds direct operations on the dataset itself.
// addServlet(context, datasetPath, sparqlDataset,
// ListOfEmptyString, enableCompression) ;
} else {
// This is the servlet that analyses requests and dispatches them to
// the appropriate servlet.
// SPARQL Query, SPARQL Update -- handles dataset?query=
// dataset?update=
// Graph Store Protocol (direct and indirect naming) if enabled.
// GET/PUT/POST on the dataset itself.
// It also checks for a request that looks like a service request
// and passes it
// on to the service (this takes precedence over direct naming).
addServlet(context, datasetPath, sparqlDataset, epDataset, enableCompression);
}
// Add JMX beans to record daatset and it's services.
addJMX(dsDesc);
}
use of javax.servlet.http.HttpServlet in project spring-framework by spring-projects.
the class ForwardedHeaderFilterTests method setUp.
@Before
@SuppressWarnings("serial")
public void setUp() throws Exception {
this.request = new MockHttpServletRequest();
this.request.setScheme("http");
this.request.setServerName("localhost");
this.request.setServerPort(80);
this.filterChain = new MockFilterChain(new HttpServlet() {
});
}
use of javax.servlet.http.HttpServlet in project spring-framework by spring-projects.
the class ForwardedHeaderFilterTests method doWithFiltersAndGetResponse.
@SuppressWarnings("serial")
private MockHttpServletResponse doWithFiltersAndGetResponse(Filter... filters) throws ServletException, IOException {
MockHttpServletResponse response = new MockHttpServletResponse();
FilterChain filterChain = new MockFilterChain(new HttpServlet() {
}, filters);
filterChain.doFilter(request, response);
return response;
}
Aggregations