/**
 * Copyright (C) 2009 - 2010 by OpenGamma Inc.
 *
 * Please see distribution for license.
 */
package com.opengamma.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.springframework.beans.factory.FactoryBean;

import com.opengamma.OpenGammaRuntimeException;

/**
 * FactoryBean for creating File objects within Spring configuration files. 
 */
public class FileFactoryBean implements FactoryBean {

  private File _file;

  public FileFactoryBean() {
  }

  public File getFile() {
    return _file;
  }

  public void setFile(final File file) {
    _file = file;
  }

  public void setResource(final String path) {
    try {
      // Because File objects can't point to things in JAR files, we extract any resources to
      // the local file system so we can return a proper "File".
      final InputStream in = getClass().getResourceAsStream(path);
      if (in == null) {
        throw new OpenGammaRuntimeException("Resource " + path + " not found");
      }
      _file = File.createTempFile("FileFactoryBean", null);
      final OutputStream out = new FileOutputStream(_file);
      final byte[] buffer = new byte[4096];
      int i;
      while ((i = in.read(buffer)) > 0) {
        out.write(buffer, 0, i);
      }
      in.close();
      out.close();
    } catch (IOException e) {
      throw new OpenGammaRuntimeException("error loading resource", e);
    }
  }

  @Override
  public Object getObject() throws Exception {
    return getFile();
  }

  @Override
  public Class<?> getObjectType() {
    return File.class;
  }

  @Override
  public boolean isSingleton() {
    return false;
  }
  
}

@@ -664,32 +664,123 @@
 file = file;%0A  %7D
+%0A  %0A  public void setFilename(final String filename) %7B%0A    setFile(new File(filename));%0A  %7D
 %0A%0A  public void 

Adding filename string