Example usage for org.springframework.core.io ByteArrayResource ByteArrayResource

List of usage examples for org.springframework.core.io ByteArrayResource ByteArrayResource

Introduction

In this page you can find the example usage for org.springframework.core.io ByteArrayResource ByteArrayResource.

Prototype

public ByteArrayResource(byte[] byteArray) 

Source Link

Document

Create a new ByteArrayResource .

Usage

From source file:de.perdian.commons.lang.conversion.impl.converters.TestResourceToCharSequenceConverter.java

@Test
public void testConvert() {
    ResourceToCharSequenceConverter converter = new ResourceToCharSequenceConverter();
    Assert.assertEquals("foo", converter.convert(new ByteArrayResource("foo".getBytes())));
}

From source file:org.trpr.platform.batch.common.utils.ConfigFileUtils.java

/**
 * Gets the job names from Config file//w ww  .  j  av  a2  s.c o m
 * @param configFile job config file or its contents as a <code> Resource </code>
 * @return List of job names, null if unable to find a job name.
 */
public static List<String> getJobName(Resource configFile) {
    return ConfigFileUtils
            .getJobName(new ByteArrayResource(ConfigFileUtils.getContents(configFile).getBytes()));
}

From source file:com.flipkart.phantom.runtime.impl.spring.utils.ConfigFileUtils.java

/**
 * Gets the handler names from Config file
 * @param configFile Task Handler config file or its contents as a <code> Resource </code>
 * @return List of taskHandler names, null if unable to find a TaskHandler name.
 *//*from  ww w  .  j a  v  a2 s.c om*/
public static List<String> getHandlerNames(Resource configFile) {
    return ConfigFileUtils
            .getHandlerNames(new ByteArrayResource(ConfigFileUtils.getContents(configFile).getBytes()));
}

From source file:com.amazonaws.services.simpleworkflow.flow.examples.deployment.DeploymentWorkflowImpl.java

@Override
public Promise<String> deploy(String springTemplate) {
    Resource templateResource = new ByteArrayResource(springTemplate.getBytes());
    GenericXmlApplicationContext appContext = new GenericXmlApplicationContext();
    appContext.setParent(applicationContext);
    appContext.load(templateResource);//ww w .  j  a va  2  s  .  com
    appContext.refresh();
    ApplicationStack applicationStack = appContext.getBean("applicationStack", ApplicationStack.class);
    applicationStack.deploy();
    return applicationStack.getUrl();
}

From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java

@Test
public void testLoadResource() throws Exception {
    YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
    factory.setResources(new Resource[] { new ByteArrayResource("foo: bar\nspam:\n  foo: baz".getBytes()) });
    Properties properties = factory.getObject();
    assertEquals("bar", properties.get("foo"));
    assertEquals("baz", properties.get("spam.foo"));
}

From source file:com.quigley.moose.spring.MooseXsdSchema.java

@Override
public void afterPropertiesSet() throws ParserConfigurationException, IOException, SAXException {
    if (mappingProvider != null) {
        mapping = mappingProvider.getMapping();
    }//from  ww  w.j  a  va2s  . c  o  m

    xsdResource = new ByteArrayResource(SchemaGenerator.generate(mapping).getBytes());
    setXsd(xsdResource);

    super.afterPropertiesSet();
}

From source file:org.wildfly.extension.camel.SpringCamelContextFactory.java

/**
 * Create a {@link SpringCamelContext} from the given bytes
 *//* ww  w . j a  v  a2 s  . c  om*/
public static CamelContext createSpringCamelContext(byte[] bytes, ClassLoader classsLoader) throws Exception {
    return createSpringCamelContext(new ByteArrayResource(bytes), classsLoader);
}

From source file:org.eclipse.gemini.blueprint.test.internal.util.jar.storage.MemoryStorage.java

public Resource getResource() {
    return new ByteArrayResource(buffer.toByteArray());
}

From source file:com.yoncabt.ebr.executor.YoncaMailSender.java

public void send(String to, String text, Map<String, byte[]> attachments) throws MessagingException {

    MimeMessage mm = mailSender.createMimeMessage();
    MimeMessageHelper mmh = new MimeMessageHelper(mm, true);
    mmh.setTo(to);/*w w  w  .j  a v  a2s.com*/
    mmh.setText(text);
    for (Map.Entry<String, byte[]> entrySet : attachments.entrySet()) {
        String key = entrySet.getKey();
        byte[] value = entrySet.getValue();
        ByteArrayResource isr = new ByteArrayResource(value);
        mmh.addAttachment(key, isr);

    }
    mailSender.send(mm);
}

From source file:org.paxml.core.InMemoryResource.java

@Override
public Resource getSpringResource() {
    return new ByteArrayResource(array);
}