Created
December 15, 2012 10:39
-
-
Save chkal/4292625 to your computer and use it in GitHub Desktop.
Demonstrates how to integrate Togglz with JMX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implementation of the Management interface | |
*/ | |
public class TogglzManagement implements TogglzManagementMBean { | |
@Override | |
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)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Management interface | |
*/ | |
public interface TogglzManagementMBean { | |
/** | |
* Toggles the given feature | |
*/ | |
void toggle(String featureName, boolean enabled); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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