private void startExternalPopularImagesService(String resourcesPath) { Path filePath = Paths.get(resourcesPath, POPULAR_IMAGES_FILE); if (!filePath.toFile().exists()) { logInfo("Skip loading popular images from user resource path."); return; } else { logInfo("Loading popular images from user resource path..."); } File file = filePath.toFile(); try { Utils.fromJson(FileUtil.getResourceAsString(file.getAbsolutePath(), false), Collection.class); } catch (Exception e) { logWarning("Error validating popular images file content: %s", e.getMessage()); return; } Operation post = Operation.createPost(UriUtils.buildUri(getHost(), EXTERNAL_LINK)); FileContentService fcs = new FileContentService(file); getHost().startService(post, fcs); }
super.handleGet(op);
@Override public void handleStart(Operation startPost) { try { Path baseResourcePath = Utils.getServiceUiResourcePath(this); Path baseUriPath = Paths.get(getSelfLink()); String prefix = baseResourcePath.toString().replace('\\', '/'); Map<Path, String> pathToURIPath = new HashMap<>(); if (getHost().getState().resourceSandboxFileReference != null) { getHost().discoverFileResources(this, pathToURIPath, baseUriPath, prefix); } if (pathToURIPath.isEmpty()) { getHost().discoverJarResources(baseResourcePath, this, pathToURIPath, baseUriPath, prefix); } if (pathToURIPath.isEmpty()) { log(Level.WARNING, "No custom UI resources found for %s", this.getClass().getName()); } for (Entry<Path, String> e : pathToURIPath.entrySet()) { String value = e.getValue(); Operation post = Operation.createPost(UriUtils.buildUri(getHost(), value)); FileContentService fcs = new FileContentService(e.getKey().toFile()); getHost().startService(post, fcs); } } catch (Exception e) { log(Level.WARNING, "Error enumerating UI resources for %s: %s", this.getSelfLink(), Utils.toString(e)); } super.handleStart(startPost); }
@Before public void startServices() throws Throwable { long initTime = System.nanoTime(); URL testImageResource = DockerAdapterServiceTest.class.getResource(TEST_IMAGE_FILE); assertNotNull("Missing test resource: " + TEST_IMAGE_FILE, testImageResource); File file = new File(testImageResource.toURI()); imageReference = UriUtils.buildPublicUri(host, TEST_IMAGE_URL_PATH); host.startService(Operation.createPost(imageReference), new FileContentService(file)); host.log(Level.INFO, ">>>>>>> DockerVolumeAdapterServiceTest.startServices took %d millis", TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - initTime)); }
@Before public void startServices() throws Throwable { URL testImageResource = DockerAdapterServiceTest.class.getResource(TEST_IMAGE_FILE); assertNotNull("Missing test resource: " + TEST_IMAGE_FILE, testImageResource); File file = new File(testImageResource.toURI()); imageReference = UriUtils.buildPublicUri(host, TEST_IMAGE_URL_PATH); host.startService(Operation.createPost(imageReference), new FileContentService(file)); }
@Before public void startServices() throws Throwable { // set up a service that serves a docker image tar file from the filesystem. // note that to work with an external docker server the IP must be the external // one (not localhost) URL testImageResource = DockerAdapterServiceTest.class.getResource(TEST_IMAGE_FILE); assertNotNull("Missing test resource: " + TEST_IMAGE_FILE, testImageResource); File file = new File(testImageResource.toURI()); URI imageReference = UriUtils.buildPublicUri(host, TEST_IMAGE_URL_PATH); host.startService(Operation.createPost(imageReference), new FileContentService(file)); }
this.host.startServiceAndWait(new FileContentService(defaultFile), route, null);
this.host.startServiceAndWait(new FileContentService(defaultFile), route, null);