You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Romain Manni-Bucau <rm...@gmail.com> on 2011/04/05 21:14:27 UTC

openejb - new feature to create mbeans?

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

Re: openejb - new feature to create mbeans?

Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
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 <rm...@gmail.com>

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