当前位置: 首页>>代码示例>>Java>>正文


Java ByteArrayAsset类代码示例

本文整理汇总了Java中org.jboss.shrinkwrap.api.asset.ByteArrayAsset的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayAsset类的具体用法?Java ByteArrayAsset怎么用?Java ByteArrayAsset使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ByteArrayAsset类属于org.jboss.shrinkwrap.api.asset包,在下文中一共展示了ByteArrayAsset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addJarManifest

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
private void addJarManifest() {
    Manifest manifest = new Manifest();
    Attributes attrs = manifest.getMainAttributes();
    attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
    attrs.put(Attributes.Name.MAIN_CLASS, Main.class.getName());

    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        manifest.write(out);
        out.close();
        byte[] bytes = out.toByteArray();
        this.archive.addAsManifestResource(new ByteArrayAsset(bytes), "MANIFEST.MF");
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:17,代码来源:BuildTool.java

示例2: addFaviconExceptionHandler

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
/**
 * Add the default WildFly Swarm {@code favicon.ico} handler.
 *
 * @return This archive.
 */
@SuppressWarnings("unchecked")
default T addFaviconExceptionHandler() throws IOException {
    // Add FaviconServletExtension
    String path = "WEB-INF/classes/" + FaviconServletExtension.EXTENSION_NAME.replace('.', '/') + ".class";
    byte[] generatedExtension;
    generatedExtension = FaviconFactory.createFaviconServletExtension(FaviconServletExtension.EXTENSION_NAME);
    add(new ByteArrayAsset(generatedExtension), path);

    // Add FaviconErrorHandler
    path = "WEB-INF/classes/" + FaviconServletExtension.HANDLER_NAME.replace('.', '/') + ".class";
    byte[] generatedHandler;
    generatedHandler = FaviconFactory.createFaviconErrorHandler(FaviconServletExtension.HANDLER_NAME);
    add(new ByteArrayAsset(generatedHandler), path);

    // Add services entry for FaviconServletExtension
    this.addAsServiceProvider(ServletExtension.class.getName(), FaviconServletExtension.EXTENSION_NAME);

    return (T) this;
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:25,代码来源:WebXmlContainer.java

示例3: createAsset

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
private Asset createAsset(InputStream in) {

        StringBuilder str = new StringBuilder();
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {

            String line = null;

            while ((line = reader.readLine()) != null) {
                str.append(line).append("\n");
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
        return new ByteArrayAsset(str.toString().getBytes());
    }
 
开发者ID:wildfly-swarm-archive,项目名称:wildfly-swarm-keycloak,代码行数:17,代码来源:SecuredImpl.java

示例4: addWildFlySwarmProperties

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
private void addWildFlySwarmProperties() throws IOException {
    Properties props = new Properties();

    Enumeration<?> propNames = this.properties.propertyNames();

    while (propNames.hasMoreElements()) {
        String eachName = (String) propNames.nextElement();
        String eachValue = this.properties.get(eachName).toString();
        props.put(eachName, eachValue);
    }
    props.setProperty(BootstrapProperties.APP_ARTIFACT, this.projectAsset.getSimpleName());

    if (this.bundleDependencies) {
        props.setProperty(BootstrapProperties.BUNDLED_DEPENDENCIES, "true");
    }

    ByteArrayOutputStream propsBytes = new ByteArrayOutputStream();
    props.store(propsBytes, "Generated by WildFly Swarm");

    this.archive.addAsManifestResource(new ByteArrayAsset(propsBytes.toByteArray()), "wildfly-swarm.properties");
}
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:22,代码来源:BuildTool.java

示例5: base

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
static WebArchive base(String warName) {
    PomEquippedResolveStage resolver = Maven.resolver().loadPomFromFile("pom.xml");
    return ShrinkWrap
            .create(WebArchive.class, warName + ".war")
            .addClasses(FRAMEWORK_CLASSES)
            .addAsLibraries(resolver.resolve("com.vaadin:vaadin-server:7.1.6").withoutTransitivity().asSingleFile())
            .addAsLibraries(resolver.resolve("com.vaadin:vaadin-shared:7.1.6").withoutTransitivity().asSingleFile())
            .addAsWebInfResource(new ByteArrayAsset(VaadinExtension.class.getName().getBytes()),
                    ArchivePaths.create("services/javax.enterprise.inject.spi.Extension"))
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));

    /*-
    MavenDependencyResolver resolver = DependencyResolvers.use(MavenDependencyResolver.class).loadMetadataFromPom(
            "pom.xml");
           
    return ShrinkWrap
            .create(WebArchive.class, warName + ".war")
            .addClasses(FRAMEWORK_CLASSES)
            .addAsLibraries(resolver.artifact("com.vaadin:vaadin-server:7.1.6").resolveAsFiles())
           .addAsLibraries(resolver.artifact("com.vaadin:vaadin-shared:7.1.6").resolveAsFiles())
            .addAsWebInfResource(new ByteArrayAsset(VaadinExtension.class.getName().getBytes()),
                    ArchivePaths.create("services/javax.enterprise.inject.spi.Extension"))
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
     */

}
 
开发者ID:antoniomaria,项目名称:gazpachoquest,代码行数:27,代码来源:ArchiveProvider.java

示例6: onePaAsLib

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
/**
 * Deployment layout
 * 
 * test-application.ear    
 *    |-- lib /
 *        |-- processes.jar
 *          |-- META-INF/processes.xml
 *          |-- org/camunda/bpm/integrationtest/testDeployProcessArchive.bpmn20.xml
 *          
 *    |-- fox-platform-client.jar  <<===============================||      
 *                                                                  ||  Class-Path reference
 *    |-- test.war (contains the test-class but also processes)     ||
 *        |-- META-INF/MANIFEST.MF =================================||
 *        |-- WEB-INF/beans.xml
 *        |-- + test classes
 *        
 */   
@Deployment
public static EnterpriseArchive onePaAsLib() {    
  
  JavaArchive processArchiveJar = ShrinkWrap.create(JavaArchive.class, "processes.jar")
    .addAsResource("org/camunda/bpm/integrationtest/testDeployProcessArchive.bpmn20.xml")
    .addAsResource("META-INF/processes.xml", "META-INF/processes.xml");
  
  JavaArchive foxPlatformClientJar = DeploymentHelper.getEjbClient();
  
  WebArchive testJar = ShrinkWrap.create(WebArchive.class, "test.war")
    .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
    .setManifest(new ByteArrayAsset(("Class-Path: " + foxPlatformClientJar.getName()+"\n").getBytes()))
    .addClass(AbstractFoxPlatformIntegrationTest.class)
    .addClass(TestFoxPlatformClientAsEjbModule_onePaAsLib.class);

  return ShrinkWrap.create(EnterpriseArchive.class, "onePaAsLib.ear")            
    .addAsLibrary(processArchiveJar)
    .addAsModule(foxPlatformClientJar)
    .addAsModule(testJar)
    .addAsLibrary(DeploymentHelper.getEngineCdi());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:39,代码来源:TestFoxPlatformClientAsEjbModule_onePaAsLib.java

示例7: createDeployment

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
public static WebArchive createDeployment( final Class<?>... classesUnderTest )
{
    return ShrinkWrap
        .create(WebArchive.class)
        .addClasses(classesUnderTest)
        .addClass(RequestContextServletFilter.class)
        .addClass(TenantRequestContextListener.class)
        .addClass(DestinationsRequestContextListener.class)
        .addAsManifestResource("arquillian.xml")
        .addAsWebInfResource(new ByteArrayAsset("<beans/>".getBytes()), ArchivePaths.create("beans.xml"));
}
 
开发者ID:SAP,项目名称:cloud-s4-sdk-examples,代码行数:12,代码来源:TestUtil.java

示例8: addWildFlySwarmApplicationManifest

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
private void addWildFlySwarmApplicationManifest() {
    WildFlySwarmManifest manifest = this.dependencyManager.getWildFlySwarmManifest();

    this.properties.put("swarm.uberjar.build.user", System.getProperty("user.name"));
    if (!this.hollow) {
        this.properties.put(BootstrapProperties.APP_ARTIFACT, this.projectAsset.getSimpleName());
    }

    manifest.setProperties(this.properties);
    manifest.bundleDependencies(this.bundleDependencies);
    manifest.setMainClass(this.mainClass);
    manifest.setHollow(this.hollow);
    this.archive.add(new ByteArrayAsset(manifest.toString().getBytes(StandardCharsets.UTF_8)), WildFlySwarmManifest.CLASSPATH_LOCATION);

}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:16,代码来源:BuildTool.java

示例9: testWithSwaggerConfInRoot

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
@Test
public void testWithSwaggerConfInRoot() {
    JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class);

    archive.addResource(MyResource.class);
    archive.addResource(MyOtherResource.class);
    archive.add(new ByteArrayAsset("packages: com.myapp.mysubstuff".getBytes()), "META-INF/swarm.swagger.conf");

    SwaggerArchivePreparer preparer = new SwaggerArchivePreparer(archive);
    preparer.process();

    SwaggerArchive swaggerArchive = archive.as(SwaggerArchive.class);

    assertThat(swaggerArchive.getResourcePackages()).containsOnly("com.myapp.mysubstuff");
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:16,代码来源:SwaggerArchivePreparerTest.java

示例10: testWithSwaggerConfInWebInfClasses

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
@Test
public void testWithSwaggerConfInWebInfClasses() {
    JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class);

    archive.addResource(MyResource.class);
    archive.addResource(MyOtherResource.class);
    archive.add(new ByteArrayAsset("packages: com.myapp.mysubstuff".getBytes()), "WEB-INF/classes/META-INF/swarm.swagger.conf");

    SwaggerArchivePreparer preparer = new SwaggerArchivePreparer(archive);
    preparer.process();

    SwaggerArchive swaggerArchive = archive.as(SwaggerArchive.class);

    assertThat(swaggerArchive.getResourcePackages()).containsOnly("com.myapp.mysubstuff");
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:16,代码来源:SwaggerArchivePreparerTest.java

示例11: addGeneratedApplication

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
private void addGeneratedApplication(JAXRSArchive archive) {
    String name = "org.wildfly.swarm.generated.WildFlySwarmDefaultJAXRSApplication";
    String path = "WEB-INF/classes/" + name.replace('.', '/') + ".class";

    byte[] generatedApp;
    try {
        generatedApp = DefaultApplicationFactory.create(name, applicationPath.get());
        archive.add(new ByteArrayAsset(generatedApp), path);
        archive.addHandlers(new ApplicationHandler(archive, path));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:14,代码来源:DefaultApplicationDeploymentProcessor.java

示例12: process

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
@Override
public void process() {
    Collection<ClassInfo> serviceClients = index.getKnownDirectImplementors((DotName.createSimple(ServiceClient.class.getName())));

    serviceClients.forEach(info -> {
        String name = info.name().toString() + "_generated";
        String path = "WEB-INF/classes/" + name.replace('.', '/') + ".class";
        archive.as(JAXRSArchive.class).add(new ByteArrayAsset(ClientServiceFactory.createImpl(name, info)), path);
    });
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:11,代码来源:ServiceClientProcessor.java

示例13: createAsset

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
private Asset createAsset(InputStream in) throws IOException {
    StringBuilder str = new StringBuilder();
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {

        String line = null;

        while ((line = reader.readLine()) != null) {
            str.append(line).append("\n");
        }
    }
    return new ByteArrayAsset(str.toString().getBytes());
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:13,代码来源:SecuredArchivePreparer.java

示例14: removeWAR

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
protected static void removeWAR(EnterpriseArchive archive, String warName)
    throws Exception {
// Delete war file
archive.delete("/" + warName);
// now we remove the module entry in application.xml
Node node = archive.get(APPLICATION_XML_PATH);
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance()
	.newDocumentBuilder();
try (InputStream stream = node.getAsset().openStream()) {
    Document document = documentBuilder.parse(stream);
    NodeList elements = document.getElementsByTagName("web-uri");
    for (int index = 0; index < elements.getLength(); index++) {
	org.w3c.dom.Node item = elements.item(index);
	if (item.getTextContent().equals(warName)) {
	    org.w3c.dom.Node webNode = item.getParentNode();
	    org.w3c.dom.Node moduleNode = webNode.getParentNode();
	    moduleNode.getParentNode().removeChild(moduleNode);
	}
    }
    document.normalize();
    archive.delete(APPLICATION_XML_PATH);

    Transformer transformer = TransformerFactory.newInstance()
	    .newTransformer();
    try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
	transformer.transform(new DOMSource(document),
		new StreamResult(byteArrayOutputStream));
	archive.add(
		new ByteArrayAsset(byteArrayOutputStream.toByteArray()),
		APPLICATION_XML_PATH);
    }
}
   }
 
开发者ID:PureSolTechnologies,项目名称:Purifinity,代码行数:34,代码来源:AbstractArquillianTest.java

示例15: addGeneratedApplication

import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; //导入依赖的package包/类
protected void addGeneratedApplication() {

        Map<ArchivePath, Node> content = getArchive().getContent();

        boolean applicationFound = false;

        for (Map.Entry<ArchivePath, Node> entry : content.entrySet()) {
            Node node = entry.getValue();
            Asset asset = node.getAsset();
            if (hasApplicationPathAnnotation(node.getPath(), asset)) {
                applicationFound = true;
                break;
            }
        }

        if (!applicationFound) {
            String name = "org.wildfly.swarm.generated.WildFlySwarmDefaultJAXRSApplication";
            String path = "WEB-INF/classes/" + name.replace('.', '/') + ".class";

            byte[] generatedApp = new byte[0];
            try {
                generatedApp = ApplicationFactory2.create(name, "/");
                add(new ByteArrayAsset(generatedApp), path);
                addHandlers(new ApplicationHandler(this, path));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:30,代码来源:JAXRSArchiveImpl.java


注:本文中的org.jboss.shrinkwrap.api.asset.ByteArrayAsset类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。