001    package org.shiftone.jrat.core.config;
002    
003    import org.shiftone.jrat.util.io.Dir;
004    import org.shiftone.jrat.util.log.Logger;
005    
006    /**
007     * @author jeff@shiftone.org (Jeff Drost)
008     */
009    public class Settings {
010        private static final Logger LOG = Logger.getLogger(Settings.class);
011    
012        private String applicationName;
013    
014        private boolean systemPropertyTweakingEnabled = true;
015        private String baseDirectory = "jrat.output";
016        private String logLevel = "info";
017        private boolean nanoSecondTimingEnabled;
018        private int outputBufferSize = 1024 * 8;
019        private boolean outputCompressionEnabled;
020    
021        //
022        private boolean httpServerEnabled;
023        private int httpPort = 8888;
024        //
025        private boolean jmxEnabled;
026        private boolean mBeanServerCreationEnabled;
027        private String mBeanServerServerUrl;
028        private String mBeanServerAgentId;
029        private boolean rmiRegistryCreationEnabled = true;
030        private int rmiRegistryPort = 2121;
031        //
032    
033        private boolean injectorDefaultExcludesEnabled;
034    
035    
036        /**
037         * It is occasionally necessary for JRat to set a system property that
038         * it knows will change the behavior of an environment in a way that
039         * is necessary for profiling.
040         * This is only done when using the jvmti agent.
041         */
042        public boolean isSystemPropertyTweakingEnabled() {
043            return systemPropertyTweakingEnabled;
044        }
045    
046        public void setSystemPropertyTweakingEnabled(boolean systemPropertyTweakingEnabled) {
047            this.systemPropertyTweakingEnabled = systemPropertyTweakingEnabled;
048        }
049    
050        public String getApplicationName() {
051            return applicationName;
052        }
053    
054        public void setApplicationName(String applicationName) {
055            this.applicationName = applicationName;
056        }
057    
058        public Dir getBaseDirectory() {
059            return new Dir(baseDirectory);
060        }
061    
062        public void setBaseDirectory(String baseDirectory) {
063            this.baseDirectory = baseDirectory;
064        }
065    
066        public String getLogLevel() {
067            return logLevel;
068        }
069    
070        public void setLogLevel(String logLevel) {
071            this.logLevel = logLevel;
072        }
073    
074        public boolean isNanoSecondTimingEnabled() {
075            return nanoSecondTimingEnabled;
076        }
077    
078        public void setNanoSecondTimingEnabled(boolean nanoSecondTimingEnabled) {
079            this.nanoSecondTimingEnabled = nanoSecondTimingEnabled;
080        }
081    
082        public int getOutputBufferSize() {
083            return outputBufferSize;
084        }
085    
086        public void setOutputBufferSize(int outputBufferSize) {
087            this.outputBufferSize = outputBufferSize;
088        }
089    
090        public boolean isOutputCompressionEnabled() {
091            return outputCompressionEnabled;
092        }
093    
094        public void setOutputCompressionEnabled(boolean outputCompressionEnabled) {
095            this.outputCompressionEnabled = outputCompressionEnabled;
096        }
097    
098        public boolean isHttpServerEnabled() {
099            return httpServerEnabled;
100        }
101    
102        public void setHttpServerEnabled(boolean httpServerEnabled) {
103            this.httpServerEnabled = httpServerEnabled;
104        }
105    
106        public int getHttpPort() {
107            return httpPort;
108        }
109    
110        public void setHttpPort(int httpPort) {
111            this.httpPort = httpPort;
112        }
113    
114        public boolean isJmxEnabled() {
115            return jmxEnabled;
116        }
117    
118        public void setJmxEnabled(boolean jmxEnabled) {
119            this.jmxEnabled = jmxEnabled;
120        }
121    
122        public boolean isMBeanServerCreationEnabled() {
123            return mBeanServerCreationEnabled;
124        }
125    
126        public void setMBeanServerCreationEnabled(boolean mBeanServerCreationEnabled) {
127            this.mBeanServerCreationEnabled = mBeanServerCreationEnabled;
128        }
129    
130        public String getMBeanServerServerUrl() {
131            return this.mBeanServerServerUrl == null
132                    ? "service:jmx:rmi:///jndi/rmi://localhost:" + getRmiRegistryPort() + "/jrat"
133                    : this.mBeanServerServerUrl;
134        }
135    
136        public void setMBeanServerServerUrl(String mBeanServerServerUrl) {
137            this.mBeanServerServerUrl = mBeanServerServerUrl;
138        }
139    
140        public String getMBeanServerAgentId() {
141            return mBeanServerAgentId;
142        }
143    
144        public void setMBeanServerAgentId(String mBeanServerAgentId) {
145            this.mBeanServerAgentId = mBeanServerAgentId;
146        }
147    
148        public boolean isRmiRegistryCreationEnabled() {
149            return rmiRegistryCreationEnabled;
150        }
151    
152        public void setRmiRegistryCreationEnabled(boolean rmiRegistryCreationEnabled) {
153            this.rmiRegistryCreationEnabled = rmiRegistryCreationEnabled;
154        }
155    
156        public int getRmiRegistryPort() {
157            return rmiRegistryPort;
158        }
159    
160        public void setRmiRegistryPort(int rmiRegistryPort) {
161            this.rmiRegistryPort = rmiRegistryPort;
162        }
163    
164        public boolean isInjectorDefaultExcludesEnabled() {
165            return injectorDefaultExcludesEnabled;
166        }
167    
168        public void setInjectorDefaultExcludesEnabled(boolean injectorDefaultExcludesEnabled) {
169            this.injectorDefaultExcludesEnabled = injectorDefaultExcludesEnabled;
170        }
171    }