I already had a look into FeatureContext. Here you are maintaining different FeatureManager for different ContextClassLoaders. My expectation for an JMX bean would be to be able to operate on ALL FeatureManagers known for the different ClassLoaders.
BTW: Why did you coma up with this approach, i.e. having different FeatureManager per ClassLoader? Is it because you want to be able to drop the toggle jar just once into an app server?
What is the target JDK for togglz? Java got some very nice new features in JMX area in JDK 1.6 +, but if togglz is targeting 1.5 + , these options are not available.
In my view the JMX beans act 'just' as facades to the different FeatureManager instances in a jvm. So in a first implementation I'ld suggest to expose this methods and their results (probably converted into a string representation)
FeatureManager#getFeaturesFeatureManager#setFeatureState
The interesting part is to find the correct FeatureManager for an update operation … so that we do the update on the correct instance of a feature.
Hey Mark,
I'll answer to your question inline...
I already had a look into FeatureContext. Here you are maintaining different FeatureManager for different ContextClassLoaders. My expectation for an JMX bean would be to be able to operate on ALL FeatureManagers known for the different ClassLoaders.I think it would make sense to have separate JMX beans for each FeatureManager. They could have different names, depending on the feature enum or something like this to simplify identifying them. And it would simplify the API, because you don't have to reference the FeatureManager you want to use in each call to the JMX API. I thought of JMX object names like:org.togglz.jmx.FeatureManagement:name=com.example.myapp.MyFeatureEnum
Usually there is only one FeatureManager per VM. But if users deploy multiple applications to one app server, there could be multiple ones. And I think that it makes sense to have separate JMX beans in this case.BTW: Why did you coma up with this approach, i.e. having different FeatureManager per ClassLoader? Is it because you want to be able to drop the toggle jar just once into an app server?
Actually the map that stores a FeatureManager per class loader is just a cache. The basic concept is that the FeatureContext uses the FeatureManagerProvider SPI to lookup the correct FeatureManager for the current execution context. There a different implementations for different deployment scenarios. But as the lookup MAY take some time, the result is cached on a per context class loader basis. Actually I already thought about removing this caching, but I think I'll leave it there for now.But fortunately we shouldn't have to deal with FeatureContext at all for the JMX support, if we create the JMX beans using the FeatureManagerListener SPI like described above. We just would have to publish the mbean when FeatureManagerListener#start() is called and remove it in FeatureManagerListener#stop().What is the target JDK for togglz? Java got some very nice new features in JMX area in JDK 1.6 +, but if togglz is targeting 1.5 + , these options are not available.Good news. Togglz requires only JDK 1.6 :)In my view the JMX beans act 'just' as facades to the different FeatureManager instances in a jvm. So in a first implementation I'ld suggest to expose this methods and their results (probably converted into a string representation)I agree. This should be fine for a first version.FeatureManager#getFeaturesFeatureManager#setFeatureStateThe most important methods are getFeatureState() and setFeatureState(). The method getFeatures() is also nice to have and the new getMetaData() may also be interesting.The interesting part is to find the correct FeatureManager for an update operation … so that we do the update on the correct instance of a feature.This won't be a problem if there is exactly one JMX bean for each feature manager as I suggested above.
What do you think?Christian
I try to summarize my understandings:- we will have a JMX bean instance for each FeatureManagerthis implicates we need to have a unique id on each FeatureManager (or FeatureProvider), so we can build unique MBean object names. The EnumBasedFeatureProvider ie. might be used by several FeatureManager instances.What do you think?
- JMX support is de/activated via Listener on start/stop of FeatureManager- Target is JDK 1.6+- JMX is done in a separate module- first implementation will coverFeatureManager#getFeaturesFeatureManager#setFeatureStateFeatureManager#setFeatureStateother methods will be exposed via JMX as needed...That's fine by me.
I'll have to read on using git/github. Haven't had the pleasure up to know…I saw you recommend to create a special 'repository' for the implementation and issue a pull request when I'm done!?
I think I'll start working on this on monday and will finish within the next week.
I'm on my phone right now. So just a quick reply. You can use setFeatureState and getFeatureState of FeatureManager for now. The manager delegates these to the repository. But I think it also makes sense that the manager exposes the repository.
I'll reply in detail tomorrow.
Christian