org.apache.http.impl.bootstrap.HttpServer Java Examples
The following examples show how to use
org.apache.http.impl.bootstrap.HttpServer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Photato.java From Photato with GNU Affero General Public License v3.0 | 5 votes |
private static HttpServer getDefaultServer(Path folderRoot) { return ServerBootstrap.bootstrap() .setListenerPort(PhotatoConfig.serverPort) .setServerInfo(serverName) .setSocketConfig(getSocketConfig()) .setExceptionLogger(new StdErrorExceptionLogger()) .registerHandler("*", new LoadingHandler(folderRoot)) .create(); }
Example #2
Source File: MockIpdServer.java From deprecated-security-advanced-modules with Apache License 2.0 | 4 votes |
public HttpServer getHttpServer() { return httpServer; }
Example #3
Source File: MockSamlIdpServer.java From deprecated-security-advanced-modules with Apache License 2.0 | 4 votes |
public HttpServer getHttpServer() { return httpServer; }
Example #4
Source File: Photato.java From Photato with GNU Affero General Public License v3.0 | 4 votes |
public static void main(String[] args) throws Exception { //Set up this way so we can change default formatter for everyone System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tF %1$tT %4$s %2$s %5$s%6$s%n"); LOGGER = Logger.getLogger( Photato.class.getName() ); if (args.length < 1) { LOGGER.log( Level.SEVERE, "Usage: <picturesRootFolder> [cacheFolder] [configFolder]"); System.exit(-1); } FileSystem fileSystem = FileSystems.getDefault(); Path rootFolder = getRootFolder(fileSystem, args[0]); String cacheRootFolder = (args.length >= 2 ? args[1] : "cache"); String thumbnailCacheFolder = cacheRootFolder + "/thumbnails"; String fullscreenCacheFolder = cacheRootFolder + "/fullscreen"; String metadataCacheLocation = cacheRootFolder + "/metadata.cache"; String extractedPicturesCacheFolder = cacheRootFolder + "/extracted"; String configFile = (args.length >= 3 ? args[2] : ".") + "/photato.ini"; PhotatoConfig.init(configFile); LOGGER.log(Level.INFO, "Starting photato"); LOGGER.log(Level.INFO, "-- Config file: {0}", configFile); LOGGER.log(Level.INFO, "-- Cache file: {0}", cacheRootFolder); LOGGER.log(Level.INFO, "-- Pictures file: {0}", rootFolder); HttpServer server = getDefaultServer(fileSystem.getPath("www")); server.start(); if (!Files.exists(fileSystem.getPath(cacheRootFolder))) { LOGGER.log(Level.INFO, "Creating cache folder"); Files.createDirectory(fileSystem.getPath(cacheRootFolder)); } HttpClient httpClient = HttpClientBuilder.create().setUserAgent(serverName).build(); ExifToolDownloader.run(httpClient, fileSystem, PhotatoConfig.forceFfmpegToolsDownload); FfmpegDownloader.run(httpClient, fileSystem, PhotatoConfig.forceExifToolsDownload); ThumbnailGenerator thumbnailGenerator = new ThumbnailGenerator(fileSystem, rootFolder, thumbnailCacheFolder, extractedPicturesCacheFolder, PhotatoConfig.thumbnailHeight, PhotatoConfig.thumbnailQuality); IGpsCoordinatesDescriptionGetter gpsCoordinatesDescriptionGetter = new OSMGpsCoordinatesDescriptionGetter(httpClient, PhotatoConfig.addressElementsCount); MetadataAggregator metadataGetter = new MetadataAggregator(fileSystem, metadataCacheLocation, gpsCoordinatesDescriptionGetter); FullScreenImageGetter fullScreenImageGetter = new FullScreenImageGetter(fileSystem, rootFolder, fullscreenCacheFolder, extractedPicturesCacheFolder, PhotatoConfig.fullScreenPictureQuality, PhotatoConfig.maxFullScreenPictureWitdh, PhotatoConfig.maxFullScreenPictureHeight); PhotatoFilesManager photatoFilesManager = new PhotatoFilesManager(rootFolder, fileSystem, metadataGetter, thumbnailGenerator, fullScreenImageGetter, PhotatoConfig.prefixModeOnly, PhotatoConfig.indexFolderName, PhotatoConfig.useParallelPicturesGeneration); // Closing tmp server server.shutdown(5, TimeUnit.SECONDS); while (true) { try { server = ServerBootstrap.bootstrap() .setListenerPort(PhotatoConfig.serverPort) .setServerInfo(serverName) .setSocketConfig(getSocketConfig()) .setExceptionLogger(new StdErrorExceptionLogger()) .registerHandler(Routes.rawVideosRootUrl + "/*", new VideoHandler(rootFolder, Routes.rawVideosRootUrl)) .registerHandler(Routes.rawPicturesRootUrl + "/*", new ImageHandler(rootFolder, Routes.rawPicturesRootUrl)) .registerHandler(Routes.fullScreenPicturesRootUrl + "/*", new ImageHandler(fileSystem.getPath(fullscreenCacheFolder), Routes.fullScreenPicturesRootUrl)) .registerHandler(Routes.thumbnailRootUrl + "/*", new ImageHandler(fileSystem.getPath(thumbnailCacheFolder), Routes.thumbnailRootUrl)) .registerHandler(Routes.listItemsApiUrl, new FolderListHandler(Routes.listItemsApiUrl, photatoFilesManager)) .registerHandler("/img/*", new ImageHandler(fileSystem.getPath("www/img"), "/img")) .registerHandler("/js/*", new JsHandler(fileSystem.getPath("www/js"), "/js")) .registerHandler("/css/*", new CssHandler(fileSystem.getPath("www/css"), "/css")) .registerHandler("*", new DefaultHandler(fileSystem.getPath("www"))) .create(); server.start(); LOGGER.log(Level.INFO, "Server started http://{0}:{1}", new Object[] {getLocalIp(), server.getLocalPort()}); server.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); } catch (IOException | InterruptedException ex) { // In case of port already binded LOGGER.log( Level.SEVERE, "Could not start the server ..."); Thread.sleep(1000); } } }
Example #5
Source File: AuthConfigFactoryTest.java From docker-maven-plugin with Apache License 2.0 | 4 votes |
private void setupEcsMetadataConfiguration(HttpServer httpServer, String containerCredentialsUri) { environmentVariables.set("ECS_METADATA_ENDPOINT", "http://" + httpServer.getInetAddress().getHostAddress()+":" + httpServer.getLocalPort()); environmentVariables.set("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI", containerCredentialsUri); }
Example #6
Source File: LocalTestServer.java From htmlunit with Apache License 2.0 | 2 votes |
/** * Returns the underlying server. * @return the server */ public HttpServer getServer() { return server; }