de.mcs.jmeasurement.jmx.JmxConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of JMeasurement Show documentation
Show all versions of JMeasurement Show documentation
JMeasurement profiling programs in production enviroment
/*
* MCS Media Computer Software Copyright (c) 2007 by MCS
* -------------------------------------- Created on 09.01.2007 by W.Klaas
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package de.mcs.jmeasurement.jmx;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import org.xml.sax.SAXException;
import de.mcs.jmeasurement.JMConfig;
import de.mcs.jmeasurement.MeasureFactory;
import de.mcs.jmeasurement.RendererMustNotBeNullException;
import de.mcs.jmeasurement.renderer.DefaultHTMLRenderer;
/**
* The MBean implementation for the configuration. To register this JMX
* Extension, you can use the
* {@link de.mcs.jmeasurement.MeasureFactory#registerMBeans()} method, so the
* MBeans will be registered in the standard MBean server deployed with the JRE.
*
* @author W.Klaas
*
*/
public class JmxConfig implements JmxConfigMBean {
/**
* @return the backgroundTime
*/
public final int getBackgroundTime() {
return MeasureFactory.getConfig().getInteger(JMConfig.OPTION_BACKGROUND_TIME);
}
/**
* @param backgroundTime
* the backgroundTime to set
*/
public final void setBackgroundTime(final int backgroundTime) {
MeasureFactory.getConfig().setInteger(JMConfig.OPTION_BACKGROUND_TIME, backgroundTime);
}
/**
* @return the configAutofile
*/
public final boolean isConfigAutofile() {
return MeasureFactory.getConfig().getBoolean(JMConfig.OPTION_CONFIG_AUTOFILE);
}
/**
* @param configAutofile
* the configAutofile to set
*/
public final void setConfigAutofile(final boolean configAutofile) {
MeasureFactory.getConfig().setBoolean(JMConfig.OPTION_CONFIG_AUTOFILE, configAutofile);
}
/**
* @return the disableDeviation
*/
public final boolean isDisableDeviation() {
return MeasureFactory.getConfig().getBoolean(JMConfig.OPTION_DISABLE_DEVIATION);
}
/**
* @param disableDeviation
* the disableDeviation to set
*/
public final void setDisableDeviation(final boolean disableDeviation) {
MeasureFactory.getConfig().setBoolean(JMConfig.OPTION_DISABLE_DEVIATION, disableDeviation);
}
/**
* @return the enableAutosnapshot
*/
public final boolean isEnableAutosnapshot() {
return MeasureFactory.getConfig().getBoolean(JMConfig.OPTION_ENABLE_AUTOSNAPSHOT);
}
/**
* @param enableAutosnapshot
* the enableAutosnapshot to set
*/
public final void setEnableAutosnapshot(final boolean enableAutosnapshot) {
MeasureFactory.getConfig().setBoolean(JMConfig.OPTION_ENABLE_AUTOSNAPSHOT, enableAutosnapshot);
}
/**
* @return the enableMeasurement
*/
public final boolean isEnableMeasurement() {
return MeasureFactory.getConfig().getBoolean(JMConfig.OPTION_ENABLE_MEASUREMENT);
}
/**
* @param enableMeasurement
* the enableMeasurement to set
*/
public final void setEnableMeasurement(final boolean enableMeasurement) {
MeasureFactory.getConfig().setBoolean(JMConfig.OPTION_ENABLE_MEASUREMENT, enableMeasurement);
}
/**
* @return the enableMemorySavings
*/
public final boolean isEnableMemorySavings() {
return MeasureFactory.getConfig().getBoolean(JMConfig.OPTION_ENABLE_MEMORY_SAVINGS);
}
/**
* @param enableMemorySavings
* the enableMemorySavings to set
*/
public final void setEnableMemorySavings(final boolean enableMemorySavings) {
MeasureFactory.getConfig().setBoolean(JMConfig.OPTION_ENABLE_MEMORY_SAVINGS, enableMemorySavings);
}
/**
* @return the exceptionHandling
*/
public final int getExceptionHandling() {
return MeasureFactory.getConfig().getInteger(JMConfig.OPTION_EXCEPTION_HANDLING);
}
/**
* @param exceptionHandling
* the exceptionHandling to set
*/
public final void setExceptionHandling(final int exceptionHandling) {
MeasureFactory.getConfig().setInteger(JMConfig.OPTION_EXCEPTION_HANDLING, exceptionHandling);
}
/**
* @return the pointIdletime
*/
public final int getPointIdletime() {
return MeasureFactory.getConfig().getInteger(JMConfig.OPTION_POINT_IDLETIME);
}
/**
* @param pointIdletime
* the pointIdletime to set
*/
public final void setPointIdletime(final int pointIdletime) {
MeasureFactory.getConfig().setInteger(JMConfig.OPTION_POINT_IDLETIME, pointIdletime);
}
/**
* @return the workingpath
*/
public final String getWorkingpath() {
return MeasureFactory.getConfig().getProperty(JMConfig.OPTION_WORKINGPATH);
}
/**
* @param workingpath
* the workingpath to set
*/
public final void setWorkingpath(final String workingpath) {
MeasureFactory.getConfig().setProperty(JMConfig.OPTION_WORKINGPATH, workingpath);
}
/**
* @return String array with all snapshotnames.
*/
public final String[] getSnapShotNames() {
return MeasureFactory.getSnapShotNames();
}
/**
* taking a new shapshot with the given name.
*
* @param name
* name of the snapshot.
*/
public final void takeSnapShot(final String name) {
MeasureFactory.takeSnapshot(name);
}
/**
* @param name
* name of the snapshot
* @param filename
* save the snapshot to the desired filename.
* @throws IOException
* if someting goes wrong.
* @throws SAXException
* if someting goes wrong.
*/
public final void saveSnapShot(final String name, final String filename) throws SAXException, IOException {
MeasureFactory.saveSnapShot(MeasureFactory.getSnapShot(name), new File(filename));
}
/**
* @param filename
* save the html report to the desired filename.
* @throws IOException
* if someting goes wrong.
*/
public final void saveHTMLReport(final String filename) throws IOException {
try {
Writer writer = new FileWriter(filename);
MeasureFactory.getReport(null, new DefaultHTMLRenderer(), writer);
writer.close();
} catch (RendererMustNotBeNullException e) {
e.printStackTrace();
}
}
/**
* @return the actual application name.
*/
public final String getApplicationName() {
return MeasureFactory.getApplicationName();
}
}