Hi Shenglin

I've removed some XML fragments to make it simpler to read...

> Here is what I have right now:
>
> <MBeans>
>    <MBean href="http://localhost:8080/services/jmx/mbean/0";>
>    </MBean>
> </MBeans>
>

OK

>
> And
> Request:
> http://localhost:8080/services/jmx/mbean/0
> Response:
> <MBean href="http://localhost:8080/services/jmx/mbean/0";>
> </MBean>
>
> And so on with others.

Very good.

>
> However, I have to make http://localhost:8080/services/jmx/ at every time I
> am trying to do anything further, because I need to use this following
> function to load up all mbeans along with their /mbean/** unique
> identifiers, and I think this may not be what you want. Please correct me on
> this.
>
Are you saying that you have to use UriInfo and UriBuilder for
creating hrefs whenever you need to
build an MBean representation ?

Perhaps, you may want to keep "http://localhost:8080/services/jmx/";
parts of hrefs in the map as well, as you suggested on #cxf. This will
let you avoid recalculating the base values for those MBeans which
have already been retrieved before. These values may not 'survive' the
restarts for ex, say a port may've been changed, etc,  but I agree it
may be worth optimizing. I'm not sure if injecting  UriInfo via
constructor can provide a way to get to the base address at the
JMXServer initialization time - may be worth trying later on...

Please don't spend much time on it right now, because it's more
important at the moment to try to build a more or less complete
solution around exposing JMX mbeans over HTTP.

Have a look at it a bit further, and then start focusing on making sure

"http://localhost:8080/services/jmx/mbean/0";, etc, are handled by
MBeanResource subresource, we can keep adding methods for dealing with
individual MBeans to JMXServer itself, but  having a subresource
dealing with such requests may be a bit cleaner...


>     @GET
>     public CxfMBeanCollection traversMBeans(@Context UriInfo uriInfo) throws
> MalformedObjectNameException, NullPointerException{
>     ....
>    }
>
>

Please have UriInfo injected in one of the JMXServer's fields, remove
NPE declaration

Cheers, Sergey
>
> Thank you.
>
> Regards:
> Shenglin Qiu
>
>
>> Date: Thu, 19 May 2011 17:02:36 +0100
>> Subject: Re: Expose MBeans in CXF
>> From: sberyoz...@gmail.com
>> To: dev@cxf.apache.org
>>
>> Every MBean should have a unique id so that we can work with it later
>> on individually.
>> 0, 1, 2, 3, n, represents the unique part in the otherwise same URI.
>> When working with MBeans (when populating MBeans collections, etc) you
>> need to associate some unique number with every MBean. Have some local
>> AtomicInteger var, have some map there which will keep pairs like
>> id: Mbean ref
>>
>> and generate 'id' dynamically if none already exists in the map for a
>> given MBean
>>
>> may be it should be
>>
>> Map<String, Integer>
>> where String is a canonical name.
>>
>> So when later on you process something like
>> /mbean/234
>>
>> you can get 234, use it to find the canonical name (or actual JMX
>> MBean reference), and use the latter to init an instance of
>> MBeanResource which will deal with the request
>>
>> Ping me on IRC please if you have any questions
>> Cheers, Sergey
>>
>> On Thu, May 19, 2011 at 4:43 PM, Shenglin Qiu <dabaip...@hotmail.com>
>> wrote:
>> >
>> > Yes, Sergey,
>> >
>> > Should I manually give/define every mbean an indexer which is
>> > accumulated as you mentioned?
>> >> > http://localhost:8080/services/jmx/mbean/0
>> >> > http://localhost:8080/services/jmx/mbean/1
>> >> > http://localhost:8080/services/jmx/mbean/2
>> > ...
>> >> > http://localhost:8080/services/jmx/mbean/***
>> > Thank you.
>> >
>> > Regards:
>> > Shenglin Qiu
>> >
>> >> Date: Thu, 19 May 2011 15:03:03 +0100
>> >> Subject: Re: Expose MBeans in CXF
>> >> From: sberyoz...@gmail.com
>> >> To: dev@cxf.apache.org
>> >>
>> >> HI Shenglin
>> >>
>> >> On Thu, May 19, 2011 at 2:54 PM, Shenglin Qiu <dabaip...@hotmail.com>
>> >> wrote:
>> >> >
>> >> > Yes Sergey, will have these following pattern:
>> >> >
>> >> > http://localhost:8080/services/jmx/mbean/0  -> CXF Bus
>> >> >
>> >> > http://localhost:8080/services/jmx/mbean/01   -> UserService
>> >> >
>> >> > http://localhost:8080/services/jmx/mbean/0123   -> CustomerService
>> >> >
>> >> > http://localhost:8080/services/jmx/mbean/01234  -> GreeterService
>> >> > (Soap)
>> >> >
>> >> > http://localhost:8080/services/jmx/mbean/012   -> JMXServer will be
>> >> > hidden to user.
>> >> >
>> >>
>> >> That looks better, but do you think it would make sense to avoid the
>> >> concatenation ?
>> >> We can get hundreds of CXF MBeans in the production environment, so
>> >> IMHO it would be simpler
>> >> to have /mbean/199 identifying a particular MBean,
>> >>
>> >> Cheers, Sergey
>> >>
>> >> >
>> >> > Regards:
>> >> >
>> >> > Shenglin Qiu
>> >> >
>> >> >
>> >> >
>> >
>>
>>
>>
>> --
>> Sergey Beryozkin
>>
>> Application Integration Division of Talend
>> http://sberyozkin.blogspot.com
>



-- 
Sergey Beryozkin

Application Integration Division of Talend
http://sberyozkin.blogspot.com

Reply via email to