Skip to content

Instantly share code, notes, and snippets.

@iocanel
Created March 5, 2012 18:54
Show Gist options
  • Select an option

  • Save iocanel/1980339 to your computer and use it in GitHub Desktop.

Select an option

Save iocanel/1980339 to your computer and use it in GitHub Desktop.
Http Endpoint Manager
package net.iocanel.blog.servicemix.management;
import org.apache.servicemix.http.HttpEndpoint;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
/**
* A simple spring bean that gets injected an HttpEndpoint and exposes it to jmx
* @author iocanel
*/
@ManagedResource
public class HttpEndpointManager implements InitializingBean {
private HttpEndpoint endpoint;
@ManagedOperation(description="Stops the endpoint")
public void stop() throws Exception {
endpoint.stop();
}
@ManagedOperation(description="Starts the endpoint")
public void start() throws Exception {
endpoint.start();
}
@ManagedOperation(description="Deactivates the endpoint")
public void deactivate() throws Exception {
endpoint.deactivate();
}
@ManagedOperation(description="Activates the endpoint")
public void activate() throws Exception {
endpoint.activate();
}
public HttpEndpoint getEndpoint() {
return endpoint;
}
public void setEndpoint(HttpEndpoint endpoint) {
this.endpoint = endpoint;
}
/**
* Make sure that the HttpEndpoint has been injected
* @throws Exception
*/
public void afterPropertiesSet() throws Exception {
if(endpoint == null){
throw new Exception("Http consumer endpoint is not set");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment