use of owltools.gaf.eco.SimpleEcoMapper in project minerva by geneontology.
the class StartUpTool method startUp.
public static Server startUp(UndoAwareMolecularModelManager models, MinervaStartUpConfig conf, Map<IRI, Set<OWLAnnotation>> ont_annos) throws Exception {
LOGGER.info("Setup Jetty config.");
// Configuration: Use an already existing handler instance
// Configuration: Use custom JSON renderer (GSON)
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.register(GsonMessageBodyHandler.class);
resourceConfig.register(RequireJsonpFilter.class);
resourceConfig.register(SPARQLResultsMessageBodyWriter.class);
resourceConfig.register(SPARQLGraphMessageBodyWriter.class);
if (conf.useRequestLogging) {
resourceConfig.register(LoggingApplicationEventListener.class);
}
// resourceConfig.register(AuthorizationRequestFilter.class);
LOGGER.info("BatchHandler config inference provider: " + conf.reasonerOpt);
LOGGER.info("BatchHandler config importantRelations: " + conf.importantRelations);
LOGGER.info("BatchHandler config lookupService: " + conf.lookupService);
LOGGER.info("BatchHandler config checkLiteralIds: " + conf.checkLiteralIds);
LOGGER.info("BatchHandler config useRequestLogging: " + conf.useRequestLogging);
if (conf.golrSeedUrl == null) {
// default fall back to normal golr URL
conf.golrSeedUrl = conf.golrUrl;
}
LOGGER.info("SeedHandler config golrUrl: " + conf.golrSeedUrl);
InferenceProviderCreator ipc = createInferenceProviderCreator(conf.reasonerOpt, models, conf.shex);
JsonOrJsonpBatchHandler batchHandler = new JsonOrJsonpBatchHandler(models, conf.defaultModelState, ipc, conf.importantRelations, conf.lookupService);
// conf.checkLiteralIds;
batchHandler.CHECK_LITERAL_IDENTIFIERS = false;
SimpleEcoMapper ecoMapper = EcoMapperFactory.createSimple();
// JsonOrJsonpSeedHandler seedHandler = new JsonOrJsonpSeedHandler(models, conf.defaultModelState, conf.golrSeedUrl, ecoMapper );
// SPARQLHandler sparqlHandler = new SPARQLHandler(models, conf.sparqlEndpointTimeout);
ModelSearchHandler searchHandler = new ModelSearchHandler(models);
ModelARTHandler artHandler = new ModelARTHandler(models, ipc);
LocalDate d = LocalDate.now();
LocalTime t = LocalTime.now();
String startup = d.toString() + " " + t.toString();
StatusHandler statusHandler = new StatusHandler(conf, ont_annos, startup);
TaxonHandler taxonHandler = new TaxonHandler(models);
resourceConfig = resourceConfig.registerInstances(batchHandler, searchHandler, artHandler, statusHandler, taxonHandler);
// setup jetty server port, buffers and context path
Server server = new Server();
// create connector with port and custom buffer sizes
// old jetty
// SelectChannelConnector connector = new SelectChannelConnector();
// old jetty - they must be configured somewhere else in new jetty
// connector.setRequestHeaderSize(conf.requestHeaderSize);
// connector.setRequestBufferSize(conf.requestBufferSize);
// new jetty - does not have setRequestBufferSize at all
// seems to push defaults harder here.
// to change request header size need to create a new connector and manipulate httpconfiguration
HttpConfiguration http_config = new HttpConfiguration();
http_config.setRequestHeaderSize(conf.requestHeaderSize);
ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(http_config));
connector.setPort(conf.port);
server.addConnector(connector);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath(conf.contextString);
server.setHandler(context);
ServletHolder h = new ServletHolder(new ServletContainer(resourceConfig));
context.addServlet(h, "/*");
// start jetty server
LOGGER.info("Start server on port: " + conf.port + " context: " + conf.contextString);
server.start();
return server;
}
Aggregations