GithubHelp home page GithubHelp logo

dotrado / simplejmx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from j256/simplejmx

0.0 2.0 0.0 1.46 MB

Simple JMX Java Library

Home Page: http://256.com/sources/simplejmx/

License: Other

Shell 1.02% Makefile 0.20% Java 98.78%

simplejmx's Introduction

This package provides some Java classes to help with the publishing of objects using JMX.

For more information, visit the home page:
	http://256stuff.com/sources/simplejmx/

Online documentation can be found off the home page.  Here are the Javadocs:
	http://256stuff.com/sources/simplejmx/javadoc/simplejmx/

The git repository is:
	https://github.com/j256/simplejmx

Maven packages are published via the central repo:
	http://repo1.maven.org/maven2/com/j256/simplejmx/simplejmx/

Here's a little working example program:
	http://256stuff.com/sources/simplejmx/docs/example-simple

Enjoy,
Gray Watson

-----------------------------------------------------------------------------
Little Sample Program
http://256stuff.com/sources/simplejmx/docs/example-simple
-----------------------------------------------------------------------------

// create a new JMX server listening on a specific port
JmxServer jmxServer = new JmxServer(JMX_PORT);
// NOTE: you could also do: new JmxServer(ManagementFactory.getPlatformMBeanServer());
// start our server
jmxServer.start();

// create the object we will be exposing with JMX
RuntimeCounter counter = new RuntimeCounter();
// register our object
jmxServer.register(counter);
...
// shutdown our server
jmxServer.stop();
...

@JmxResource(domainName = "j256")
public class RuntimeCounter {
	private long startMillis = System.currentTimeMillis();

	// we can annotate fields directly to be published, isReadible defaults to true
	@JmxAttributeField(description = "Show runtime in seconds", isWritable = true)
	private boolean showSeconds;

	// we can annotate getter methods
	@JmxAttributeMethod(description = "Run time in seconds or milliseconds")
	public long getRunTime() {
		long diffMillis = System.currentTimeMillis() - startMillis;
		return diffMillis / (showSeconds ? 1 : 1000);
	}

	// this is an operation that shows up in the operations tab in jconsole.
	@JmxOperation(description = "Reset our start time to the current millis")
	public String resetStartTime() {
		startMillis = System.currentTimeMillis();
		return "Timer has been reset to current millis";
	}
}

simplejmx's People

Contributors

j256 avatar mottati avatar kuenishi avatar waldyrious avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.