New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizer Service #177

Closed
rhuss opened this Issue Jan 8, 2015 · 3 comments

Comments

Projects
None yet
1 participant
@rhuss
Owner

rhuss commented Jan 8, 2015

Add the possibility to hook in so called Lifecycle Services which are triggered during startup and shutdown of the agent. That way, extra MBeans can be registered.

The interface could look like

public interface Customizer {
     public void start(MBeanServer server);
     public void stop(MBeanServer server);
}

Implementation should be looked up in the classpath in META-INF/customizers for the JVM or WAR agents and as an OSGi Service for the OSGi client.

@rhuss

This comment has been minimized.

Owner

rhuss commented Jan 8, 2015

This is related for implementing HealthChecks defined in #162 .

rhuss added a commit that referenced this issue Jan 10, 2015

rhuss added a commit that referenced this issue Jan 13, 2015

rhuss added a commit that referenced this issue Jan 13, 2015

rhuss added a commit that referenced this issue Jan 13, 2015

@rhuss

This comment has been minimized.

Owner

rhuss commented Jan 13, 2015

@jstrachan, @nevenr, I implemented a first version of a now called MBeanPlugin and pushed as 1.2.4-SNAPSHOT.
You can find the code in branch 177-customizer-service.

Especially, have a look at the plugin interface MBeanPlugin, which needs to be implemented for hooking into the agent's startup process. In it's init() method it gets a MBeanPluginContext from which MBean can be registered and queried (later on).

A sample implementation can be found in TestMBeanPlugin which registers an MBean during startup and when this MBean is called later on access JMX directly from there.

Setting up a plugin is easy for the WAR and JAR plugin, but requites repackaging.

  • For the WAR file simple create a new jar with an META-INF/plugins text-file containing the plugin classes line by line. Put this jar simply into the war (without modifying any other jar)
  • For the JVM Agent you have to put the Plugin class and the plugins descriptor directly into the agent.

I will set up a sample project in the repo jolokia-extra, copying over your initial code, james.

Ah yes, you can also configure the plugin from the configuration:

  • Add a config value with key mbeanPluginOptions to the configuration (web.xml or external properties). This value should be a JSON string, holding an JSON-Object, where the keys are plugin identfiers (as returned by the Plugin interface) and the values are again JSON-Objects with the configuration for this particular plugin.
  • The plugin configuration is feed into the plugin in its init() method.

I think, that (beside maybe the naming, which might still change slightly) is a good, minimal approach for providing the basis for the required functionality without cluttering the core to much.

For Jolokia 2.0 there is already a different mechanism for plugging in, so that one then probably would have to change the plugins. But that will be more or less an automatic conversion.

In the next step, I preparing a sample for an healtcheck plugin including a packaging for a custom agent over there in jolokia-extra

@rhuss

This comment has been minimized.

Owner

rhuss commented Jul 13, 2015

Already implemented as "Plugins"

@rhuss rhuss closed this Jul 13, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment