View Javadoc

    1   package org.acegisecurity.util;
    2
    3   import org.springframework.core.io.AbstractResource;
    4
    5   import java.io.ByteArrayInputStream;
    6   import java.io.InputStream;
    7   import java.io.IOException;
    8
    9   /***
    10   * An in memory implementation of Spring's {@link org.springframework.core.io.Resource} interface.
    11   * <p>
    12   * Used by the "Acegifier" web application to create a
    13   * bean factory from an XML string, rather than a file.
    14   * </p>
    15   *
    16   * @author Luke Taylor
    17   * @version $Id: InMemoryResource.java,v 1.3 2005/11/17 00:56:09 benalex Exp $
    18   */
    19  public class InMemoryResource extends AbstractResource {
    20
    21      ByteArrayInputStream in;
    22      String description;
    23
    24      public InMemoryResource(byte[] source) {
    25          this(source, null);
    26      }
    27
    28      public InMemoryResource(byte[] source, String description) {
    29          in = new ByteArrayInputStream(source);
    30          this.description = description;
    31      }
    32
    33      public String getDescription() {
    34          return description == null ? in.toString() : description;
    35      }
    36
    37      public InputStream getInputStream() throws IOException {
    38          return in;
    39      }
    40  }