Skip to content

Instantly share code, notes, and snippets.

Created December 15, 2012 10:39
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chkal/4292625 to your computer and use it in GitHub Desktop.
Demonstrates how to integrate Togglz with JMX
* Implementation of the Management interface
public class TogglzManagement implements TogglzManagementMBean {
public void toggle(String featureName, boolean enabled) {
// as we only know the name, wrap it into an UntypedFature
UntypedFeature feature = new UntypedFeature(featureName);
// toggle the feature
FeatureManager featureManager = FeatureContext.getFeatureManager();
featureManager.setFeatureState(new FeatureState(feature, enabled));
* Management interface
public interface TogglzManagementMBean {
* Toggles the given feature
void toggle(String featureName, boolean enabled);
// create the MBean
TogglzManagement mbean = new TogglzManagement();
ObjectName name = new ObjectName("org.togglz", "name", "Togglz");
// Register it with the MBeanServer
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
mBeanServer.registerMBean(mbean, name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment