當前位置: 首頁>>代碼示例>>Java>>正文


Java Streams類代碼示例

本文整理匯總了Java中org.apache.brooklyn.util.stream.Streams的典型用法代碼示例。如果您正苦於以下問題:Java Streams類的具體用法?Java Streams怎麽用?Java Streams使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Streams類屬於org.apache.brooklyn.util.stream包,在下文中一共展示了Streams類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

import org.apache.brooklyn.util.stream.Streams; //導入依賴的package包/類
public ParsingResult<Csar> parse(String plan) {
    ParsingResult<Csar> tp;
    PlanTypeChecker type = new PlanTypeChecker(plan);
    if (!type.isTosca) {
        if (type.csarLink == null) {
            throw new UnsupportedTypePlanException("Does not look like TOSCA");
        }
        tp = uploader.uploadArchive(new ResourceUtils(this).getResourceFromUrl(type.csarLink), "submitted-tosca-archive");

    } else {
        tp = uploader.uploadSingleYaml(Streams.newInputStreamWithContents(plan), "submitted-tosca-plan");
    }

    if (ArchiveUploadService.hasError(tp, ParsingErrorLevel.ERROR)) {
        throw new UserFacingException("Could not parse TOSCA plan: "
                + Strings.join(tp.getContext().getParsingErrors(), "\n  "));
    }

    return tp;
}
 
開發者ID:cloudsoft,項目名稱:brooklyn-tosca,代碼行數:21,代碼來源:ToscaParser.java

示例2: makeOutputPath

import org.apache.brooklyn.util.stream.Streams; //導入依賴的package包/類
private Path makeOutputPath(String yamlFile, String scriptsFolder, String... scripts) throws IOException {
    File tempDir = Files.createTempDir();
    tempDir.deleteOnExit();
    File subfolder = new File(tempDir.getAbsolutePath() + "/scripts");
    subfolder.mkdir();

    Streams.copy(new ResourceUtils(this).getResourceFromUrl("classpath://templates/" + yamlFile),
            new FileOutputStream(tempDir.toString() + "/" + yamlFile));
    for (String script : scripts) {
        Streams.copy(new ResourceUtils(this).getResourceFromUrl("classpath://scripts/" + scriptsFolder + "/" + script),
                new FileOutputStream(subfolder.toString() + "/" + script));
    }

    Path outputPath = java.nio.file.Files.createTempFile("temp", ".zip");
    FileUtil.zip(tempDir.toPath(), outputPath);
    return outputPath;
}
 
開發者ID:cloudsoft,項目名稱:brooklyn-tosca,代碼行數:18,代碼來源:ToscaTypePlanTransformerIntegrationTest.java

示例3: execute

import org.apache.brooklyn.util.stream.Streams; //導入依賴的package包/類
@Override
public Response execute(Request request) throws IOException {
    Map<String, String> headersMap = MutableMap.of();
    for (Header header: request.getHeaders()) {
        headersMap.put(header.getName(), header.getValue());
    }

    String mimeType = "text/plain"; // Default Content-Type used in Brooklyn Ambari
    byte[] content = null;
    TypedOutput body = request.getBody();
    if (body != null) {
        mimeType = request.getBody().mimeType();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            body.writeTo(baos);
            content = baos.toByteArray();
        } finally {
            Streams.closeQuietly(baos);
        }
    }

    final HttpResponse response = httpExecutor.execute(new HttpRequest.Builder()
            .headers(headersMap)
            .uri(URI.create(request.getUrl()))
            .method(request.getMethod())
            .body(content)
            .build());

    List<Header> responseHeaders = Lists.newArrayList();
    for (Map.Entry<String, String> entry: response.headers().entries()) {
        responseHeaders.add(new Header(entry.getKey(), entry.getValue()));
    }
    TypedInput responseBody = new TypedByteArray(mimeType, ByteStreams.toByteArray(response.getContent()));
    return new Response(request.getUrl(), 
            response.code(), 
            (response.reasonPhrase() != null) ? response.reasonPhrase() : "", 
            responseHeaders, 
            responseBody);
}
 
開發者ID:brooklyncentral,項目名稱:brooklyn-ambari,代碼行數:40,代碼來源:AmbariRestClient.java

示例4: uploadArchive

import org.apache.brooklyn.util.stream.Streams; //導入依賴的package包/類
public ParsingResult<Csar> uploadArchive(InputStream resourceFromUrl, String callerReferenceName) {
    try {
        File f = new File(tmpRoot, callerReferenceName + "_" + Identifiers.makeRandomId(8));
        Streams.copy(resourceFromUrl, new FileOutputStream(f));
        return uploadArchive(f, callerReferenceName);

    } catch (Exception e) {
        throw Exceptions.propagate(e);
    }
}
 
開發者ID:cloudsoft,項目名稱:brooklyn-tosca,代碼行數:11,代碼來源:Uploader.java

示例5: create

import org.apache.brooklyn.util.stream.Streams; //導入依賴的package包/類
@RequestMapping(value = "/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED)
public void create(InputStream uploadedInputStream){
	admin.postBlueprint(Streams.readFullyString(uploadedInputStream));
	// TODO create a response
}
 
開發者ID:cloudfoundry-incubator,項目名稱:apache-brooklyn-service-broker,代碼行數:6,代碼來源:BrooklynController.java


注:本文中的org.apache.brooklyn.util.stream.Streams類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。