Giter Site home page Giter Site logo

sse-jmx's Introduction

sse-jmx

Build Status

The aim of this library is to make working with JMX in Scala simpler.

Usage

Exporting your Scala objects to JMX

You can export any Scala object as ModelMBean by using the MBeanExporter class. The MBeanExporter uses a configured MBeanInfoAssembler (by default AnnotationMBeanInfoAssembler to create an MBean model using reflection from the object's class. The library ships with two implementations of the MBeanInfoAssembler trait, AnnotationMBeanInfoAssembler and SimpleMBeanInfoAssembler.

SimpleMBeanInfoAssembler will generate a model with an operation for every method that takes no arguments and returns Unit, an attribute for every var and a read-only attribute for every method that takes no arguments and returns non-Unit value (usually a val).

AnnotationMBeanInfoAssembler maps Scala elements annotated with the @Managed annotation to MBean operations and attributes. Annotated defs become operations, annotated vars become attributes and annotated vals become read-only attributes.

The ObjectName of an exported object is determined by a configured ObjectNamingStratety or it is specified explicitly. The name can be explicitly specified when the object is registered or using the @ManagedResource annotation.

In the below example code we have a Cache class that is annotated with the @Managed annotation and exported using an MBeanExporter with the default configuration.

class Cache {

  @Managed(readOnly=true)
  var size: Int

  @Mavaged
  def evict(key: String) { /* ... */ }

  // the cache implementation...
}

class MyApplication {
  val myCache = new Cache
  val exporter = new MBeanExporter
  exporter.export(myCache)
}

Maven

<dependency>
  <groupId>com.tzavellas</groupId>
  <artifactId>sse-jmx</artifactId>
  <version>0.4.2</version>
</dependency>

License

Licensed under the Apache License, Version 2.0. See the LICENSE and NOTICE files for more information.

sse-jmx's People

Contributors

sptz45 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.