Skip to content

Commit

Permalink
Adds JMX Operations to Bus Endpoints (#52)
Browse files Browse the repository at this point in the history
Adds @ManagedResource and @ManagedOperation to
the EnvironmentBusEndpoint and RefreshBusEndpoint
to expose these operations over JMX.

Fixes gh-50
  • Loading branch information
steve-oakey authored and spencergibb committed Jan 9, 2017
1 parent eb100c4 commit 5aad681
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Expand Up @@ -4,6 +4,8 @@

import org.springframework.cloud.bus.event.EnvironmentChangeRemoteApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -12,6 +14,7 @@
/**
* @author Spencer Gibb
*/
@ManagedResource
public class EnvironmentBusEndpoint extends AbstractBusEndpoint {

public EnvironmentBusEndpoint(ApplicationEventPublisher context, String id,
Expand All @@ -21,6 +24,7 @@ public EnvironmentBusEndpoint(ApplicationEventPublisher context, String id,

@RequestMapping(value = "env", method = RequestMethod.POST)
@ResponseBody
@ManagedOperation
// TODO: make this an abstract method in AbstractBusEndpoint?
public void env(@RequestParam Map<String, String> params,
@RequestParam(value = "destination", required = false) String destination) {
Expand Down
Expand Up @@ -2,6 +2,9 @@

import org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedOperationParameter;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -10,6 +13,7 @@
/**
* @author Spencer Gibb
*/
@ManagedResource
public class RefreshBusEndpoint extends AbstractBusEndpoint {

public RefreshBusEndpoint(ApplicationEventPublisher context, String id,
Expand All @@ -19,6 +23,7 @@ public RefreshBusEndpoint(ApplicationEventPublisher context, String id,

@RequestMapping(value = "refresh", method = RequestMethod.POST)
@ResponseBody
@ManagedOperation
public void refresh(
@RequestParam(value = "destination", required = false) String destination) {
publish(new RefreshRemoteApplicationEvent(this, getInstanceId(), destination));
Expand Down

0 comments on commit 5aad681

Please sign in to comment.