openejb - new feature to create mbeans?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

openejb - new feature to create mbeans?

Romain Manni-Bucau
Hi,

what do you think about https://issues.apache.org/jira/browse/OPENEJB-1430 ?

it is a first patch version i didn't really test it in something else than
junit test but i think it can be nice to integrate it into our preferred
container ;).

To summarize the idea: i took an abandonned jsr which wanted to create a
standard inspired from spring annotations to create MBean.

For the user it is simply annotation to add to a simple java class (not a
pojo :p).

Here an example:

@MBean
@Description("descr ;)")
public class MyNiceMBean {
    private int i = -1;

    @ManagedAttribute @Description("just a value") public int getValue() {
        if (i < 0) {
            return 2;
        }
        return i;
    }

    @ManagedOperation public String returnValue() {
        return "yes - no";
    }

    @ManagedAttribute public void setValue(int v) {
        i = v;
    }
}

In this patch i used a system property to detect mbean to register (i
preferred to avoid to scan for it)... but it can easily be improved :).

- Romain
Reply | Threaded
Open this post in threaded view
|

Re: openejb - new feature to create mbeans?

Jean-Louis MONTEIRO
That looks pretty good.
Definitely something interesting.

Should be able to commit your patch and change it afterward.
Would be great to also provide a documentation page on our website.

Jean-Louis

2011/4/5 Romain Manni-Bucau <[hidden email]>

> Hi,
>
> what do you think about https://issues.apache.org/jira/browse/OPENEJB-1430?
>
> it is a first patch version i didn't really test it in something else than
> junit test but i think it can be nice to integrate it into our preferred
> container ;).
>
> To summarize the idea: i took an abandonned jsr which wanted to create a
> standard inspired from spring annotations to create MBean.
>
> For the user it is simply annotation to add to a simple java class (not a
> pojo :p).
>
> Here an example:
>
> @MBean
> @Description("descr ;)")
> public class MyNiceMBean {
>    private int i = -1;
>
>    @ManagedAttribute @Description("just a value") public int getValue() {
>        if (i < 0) {
>            return 2;
>        }
>        return i;
>    }
>
>    @ManagedOperation public String returnValue() {
>        return "yes - no";
>    }
>
>    @ManagedAttribute public void setValue(int v) {
>        i = v;
>    }
> }
>
> In this patch i used a system property to detect mbean to register (i
> preferred to avoid to scan for it)... but it can easily be improved :).
>
> - Romain
>
   --
    Jean-Louis Monteiro
    http://twitter.com/jlouismonteiro
    http://www.tomitribe.com