-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
operations
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
/.project | ||
/bin | ||
/target | ||
.metadata | ||
.git | ||
.settings | ||
.project | ||
.classpath |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Copyright 2012 Udo Klimaschewski | ||
|
||
http://about.me/udo.klimaschewski | ||
http://UdoJava.com/ | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,133 @@ | ||
A public Maven repository for my projects | ||
================================ | ||
|
||
To use an artifact from this repository in your Maven project, add the following repository location to your pom.xml: | ||
|
||
<repositories> | ||
<repository> | ||
<id>uklimaschewski-maven-repo</id> | ||
<name>Maven repository from uklimaschewski on GitHub</name> | ||
<url>https://raw.github.com/uklimaschewski/maven-repo/master</url> | ||
<layout>default</layout> | ||
</repository> | ||
</repositories> | ||
|
||
Then you can add dependencies to the individual artifacts from this repository in your pom.xml: | ||
(Check the actual artifact versions, here I only give an example entry using versions 1.2) | ||
|
||
* **[JmxWrapper] (https://github.com/uklimaschewski/JMXWrapper)** | ||
JMXWrapper is a wrapper that allows creation of dynamic JMX MBeans through annotations | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.udojava</groupId> | ||
<artifactId>jmxwrapper</artifactId> | ||
<version>1.2</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
JMXWrapper | ||
=== | ||
|
||
### Introduction | ||
|
||
JMXWrapper is a wrapper class that allows the creation of dynamic JMX MBeans by simply annotating a normal Java class. | ||
Names and descriptions of JMX beans, attributes, operations and operation parameters can also be localized using standard Java ResourceBundles. | ||
|
||
### Example | ||
|
||
````java | ||
@JMXBean(description = "My first JMX bean test") | ||
public class MyBean { | ||
int level = 0; | ||
|
||
@JMXBeanAttribute(name = "Floor Level", description = "The current floor level") | ||
public int getLevel() { | ||
return level; | ||
} | ||
|
||
@JMXBeanAttribute | ||
public void setLevel(int newLevel) { | ||
level = newLevel; | ||
} | ||
|
||
@JMXBeanOperation(name = "Echo Test", description = "Echoes the parameter back to you") | ||
public String myMethod( | ||
@JMXBeanParameter(name = "Input", description = "String of what to echo") String param) { | ||
return "You said " + param; | ||
} | ||
} | ||
```` | ||
Now you can use the **JMXWrapper** to publish a bean including the annotated informations to the JMX Server: | ||
|
||
````java | ||
MyBean bean = new MyBean(); | ||
JMXBeanWrapper wrappedBean = new JMXBeanWrapper(bean); | ||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); | ||
mbs.registerMBean(wrappedBean, new ObjectName("com.example.my.package:type=TestBean,name=My Bean")); | ||
```` | ||
**That's all!** | ||
|
||
### Sorting the attributes and operations | ||
|
||
To sort attributes and operations in a certain way, you have to mark the bean as sorted. | ||
By default, attributes and operations will be sorted by their name. You can specify a | ||
`sortValue` for the operations and attributes to override the default value. | ||
|
||
````java | ||
@JMXBean(sorted=true) | ||
public class MyBean { | ||
int level = 0; | ||
|
||
@JMXBeanAttribute(nameKey="level", descriptionKey="levelDescription", sortKey="1") | ||
public int getLevel() { | ||
return level; | ||
} | ||
|
||
@JMXBeanOperation(sortValue="2") | ||
public String methodX(String p1) { | ||
return p1; | ||
} | ||
} | ||
```` | ||
### Using ResourceBundles for names and descriptions | ||
|
||
Instead of specifying names and descriptions directly into the annotations, you can use standard Java ResourceBundles. | ||
You just have to specify the bundle name in the **JMXBean** annotation and then annotate the bundle keys for beans, attributes, operations and parameters: | ||
|
||
````java | ||
@JMXBean(resourceBundleName="com.example.my.package.BundleName") | ||
public class MyBean { | ||
int level = 0; | ||
@JMXBeanAttribute(nameKey="level", descriptionKey="levelDescription") | ||
public int getLevel() { | ||
return level; | ||
} | ||
```` | ||
### Annotation types | ||
|
||
Four annotation types can be used: | ||
|
||
JMXBean : Marks and describes a class to be used as a dynamic JMX bean. | ||
JMXBeanAttribute : Marks and describes methods (setter/getter) in a JMXBean to be | ||
used as a JMX attribute. | ||
JMXBeanOperation : Marks and describes a method to be used as a JMX operation. | ||
JMXBeanParameter : Describes a method parameter for JMX operation parameters | ||
|
||
### Project layout | ||
|
||
The software was created and tested using Java 1.6.0. | ||
You can check it out directly to an Eclipse project, the necessary files are in the repository. | ||
|
||
src/ The Java sources | ||
tests/ JUnit tests | ||
|
||
### Maven | ||
|
||
A pom.xml is provided, that allows to build the project with Maven. | ||
|
||
I also put the JMXWrapper to a public Maven repository. The repository location is [uklimaschewski/maven-repo.git](https://github.com/uklimaschewski/maven-repo.git), you will find the JMXWrapper there as an artifact. | ||
|
||
To use JMXWrapper in your Maven project, add the following repository location to your pom.xml: | ||
|
||
<repositories> | ||
<repository> | ||
<id>uklimaschewski-maven-repo</id> | ||
<name>Maven repository from uklimaschewski on GitHub</name> | ||
<url>https://raw.github.com/uklimaschewski/maven-repo/master</url> | ||
<layout>default</layout> | ||
</repository> | ||
</repositories> | ||
|
||
Then you can add a dependency from this repository to your pom.xml: | ||
Check the actual JMXWrapper version, here I only give an example entry using versions 1.0. | ||
You can check the versions at [maven-metadata.xml](https://raw.github.com/uklimaschewski/maven-repo/master/com/udojava/jmxwrapper/maven-metadata.xml). | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.udojava</groupId> | ||
<artifactId>jmxwrapper</artifactId> | ||
<version>1.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
### Author and License | ||
|
||
Copyright 2012 by Udo Klimaschewski | ||
- [about.me](http://about.me/udo.klimaschewski) | ||
- [UdoJava.com](http://UdoJava.com) | ||
|
||
The software is licensed under the MIT Open Source license (see [LICENSE](https://github.com/uklimaschewski/JMXWrapper/blob/master/LICENSE) file). | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.