1 28 package org.jruby; 29 30 import java.io.InputStream ; 31 import java.io.PrintStream ; 32 import java.security.AccessControlException ; 33 import java.util.Map ; 34 import org.jruby.util.JRubyFile; 35 import org.jruby.util.CommandlineParser; 36 37 public class RubyInstanceConfig { 38 private InputStream input = System.in; 39 private PrintStream output = System.out; 40 private PrintStream error = System.err; 41 private Profile profile = Profile.DEFAULT; 42 private boolean objectSpaceEnabled = true; 43 private String currentDirectory; 44 private Map environment; 45 46 { 47 try { 48 currentDirectory = JRubyFile.getFileProperty("user.dir"); 49 if (System.getProperty("jruby.objectspace.enabled") != null) { 50 objectSpaceEnabled = Boolean.getBoolean("jruby.objectspace.enabled"); 51 } 52 } catch (AccessControlException accessEx) { 53 currentDirectory = "/"; 55 } 56 } 57 58 public void updateWithCommandline(CommandlineParser cmdline) { 59 this.objectSpaceEnabled = cmdline.isObjectSpaceEnabled(); 60 } 61 62 public void setInput(InputStream newInput) { 63 input = newInput; 64 } 65 66 public InputStream getInput() { 67 return input; 68 } 69 70 public void setOutput(PrintStream newOutput) { 71 output = newOutput; 72 } 73 74 public PrintStream getOutput() { 75 return output; 76 } 77 78 public void setError(PrintStream newError) { 79 error = newError; 80 } 81 82 public PrintStream getError() { 83 return error; 84 } 85 86 public void setCurrentDirectory(String newCurrentDirectory) { 87 currentDirectory = newCurrentDirectory; 88 } 89 90 public String getCurrentDirectory() { 91 return currentDirectory; 92 } 93 94 public void setProfile(Profile newProfile) { 95 profile = newProfile; 96 } 97 98 public Profile getProfile() { 99 return profile; 100 } 101 102 public void setObjectSpaceEnabled(boolean newObjectSpaceEnabled) { 103 objectSpaceEnabled = newObjectSpaceEnabled; 104 } 105 106 public boolean isObjectSpaceEnabled() { 107 return objectSpaceEnabled; 108 } 109 110 public void setEnvironment(Map newEnvironment) { 111 environment = newEnvironment; 112 } 113 114 public Map getEnvironment() { 115 return environment; 116 } 117 } 118 | Popular Tags |