You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Shenglin Qiu <da...@hotmail.com> on 2011/05/12 14:53:52 UTC

Expose MBeans in CXF

Hi Sergey:

I have tested my current code and these are working fine:
http://localhost:8080/demoserver/jaxserver/jmxserver/port/%22UserServiceImpl%22
http://localhost:8080/demoserver/jaxserver/jmxserver/type/Bus.Service.Endpoint

I will work on this " sign which is %22 in the URL and try to remove it.

This is not working
http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://web.management.gsoc.cxf.apache.org/}DJMXServer
which is :
http://localhost:8080/demoserver/jaxserver/jmxserver/service/%7Bhttp://web.management.gsoc.cxf.apache.org/%7DJMXServer

It simply return 404 error. I guess it's the restriction from CXF Rest inbound, then I tried:
http://localhost:8080/demoserver/jaxserver/jmxserver/service/service?{http://web.management.gsoc.cxf.apache.org/}DJMXServer
http://localhost:8080/demoserver/jaxserver/jmxserver/service/service={http://web.management.gsoc.cxf.apache.org/}DJMXServer
They didn't work neither. Because when = in request, it's still 404, and when ? in request, I only get 'service' as the @PathParam in the input, the rest of the part is lost.

So is there any way I can pass string like 'http://******' as a part of request in cxf?

BTW, I will have the NDA ready this week.

Thank you.

Regards
Shenglin Qiu

 		 	   		  

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi Sergey:
 
I was pulling name list out and when I type 'se', the first one now is secretary@apache.org, my mistake.
 
I pulled your comment out and made @Todo replies:
 
> 
> Well, /soapdemo is confusing.
> Have the context named as "/services" or "/application" and set the
> address of SOAP endpoint as "/soap/greeter" or simply "/greeter" as
> you do now.
> 
Yes, it's done. I will use project name services

> I think you meant to say: > http://localhost:8080/soapdemo/jmx 
> which is the address of your JMX server endpoint which should be changed to say"http://localhost:8080/services/jmx".
Yes, I changed the project name as well as context path as you mentioned:
Project name: services
Context path: services

> http://localhost:8080/soapdemo/jmx/service/{http://server.gsoc.apache.org/}*
@Todo: I will get this done real quick. to make it like http://localhost:8080/services/jmx/service/{http://server.gsoc.apache.org/}*

> OK. Please remove MBeanCollection wrapper, you have another wrapper, MBeans.
> No need to have quotes around endpointName's value.How about having MBean representation structured like this:
> <MBean>
> <domain>org.apache.cxf</domain>
> <canonicalName>
> org.apache.cxf:bus.id=cxf5663550,
> port="CustomerServiceImpl",
> service="{http://server.gsoc.apache.org/}CustomerServiceImpl",
> type=Bus.Service.Endpoint
> </canonicalName>
> <!-- this is another representation of canonical's name
> <attributes>
> <type>Bus.Service.Endpoint</type>
> <service>{http://server.gsoc.apache.org/}CustomerServiceImpl</service>
> <endpoint>CustomerServiceImpl</endpoint>
> <attributes>
> <!--This can be ignored for now<properties/>-->
> </MBean>

@Todo: I will remove <MBeanCollection>, and put <attributes> in.

> <MBean href="http://localhost:8080/soapdemo/jmx/mbean/1">
@Todo: I will add it real quick.
> So please update MBean class to have "href" attribute (with@XmlAttribute). 
> Have a '@Context UriInfo uriinfo' field in JMXServerclass. 
> When you create a response for /list or /service/*, etc, 
> useUriInfo to get to the *base* UriBuilder which will represent a URIlike 
> "http://localhost:8080/soapdemo/jmx". 
> Next add "mbean" and then a number like 1/2/etc which identifies a particular MBean, 
> may be ashort objectname instead of the compete canonical name, etc, 
> so and have UriBuilder to return you'http://localhost:8080/soapdemo/jmx/mbean/1', etc: 
> String href = builder.path("mbean").path(someUniqueKey).build().toString()
 
@Todo: I will have this unique key implemented in href="....", and:
            @Context
            UriInfo uriinfo
 
> Your JMXServer should have a subresource locator, with @Path("mbean") and without HttpMethod.
> This locator will return something like MBeanResource and that class,at this stage, 
> will have *only*a single @GET resource method with @Path("{key}") and 
> which will return the above MBean representaion only, without MBeans wrapper: GET http://localhost:8080/soapdemo/jmx/mbean/1

@Todo: subresource locator, with @Path("mbean") and without HttpMethod:
             I will have this done.
 
 
 

Thank you very much.

Regards:
Shenglin Qiu
 
 
 

 
> Date: Wed, 18 May 2011 11:38:24 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dev@cxf.apache.org
> 
> Hi Shenglin
> 
> Well done, you are progressing well.
> 
> Note that you don't have to start formatting the updates to the dev
> list, it's just
> the work as usual, keep it simple please :-). And don't CC to the secretary :-)
> 
> Some comments below.
> 
> > I am fully upgrade it to 2.4.0, I have some testing phase exceptions
> > ocurring even I don't have a test case in maven test src folder. I will
> > figure this out later after this doc.
> >
> If you are seeing some unrelated test failures when building the trunk
> then add '-Pfastinstall'
> 
> > The RAR src is attached, hope this 'soap' won't confuse you, it actually has
> > 1 soap inbound and 2 restful inbounds. I am always stuck at the naming,
> > previous demoserver has been down when I was upgrading, that's another
> > story, and I will fix it.
> >
> 
> Well, /soapdemo is confusing.
> Have the context named as "/services" or "/application" and set the
> address of SOAP endpoint as "/soap/greeter" or simply "/greeter" as
> you do now.
> 
> <snip/>
> >
> > Here are the 3 enabled inbound service, including 1 soap webservice and 2
> > Restful service:(They are up and running)
> >
> > http://localhost:8080/soapdemo/greeter?wsdl
> >
> > http://localhost:8080/soapdemo/customerservice/customers
> >
> > http://localhost:8080/soapdemo/customerservice/customer/firstname/Lois
> >
> > http://localhost:8080/soapdemo/customerservice/customer/id/1
> >
> > http://localhost:8080/soapdemo/userservice/users
> >
> > http://localhost:8080/soapdemo/userservice/user/1
> >
> 
> OK, lets have
> http://localhost:8080/services/greeter
> http://localhost:8080/services/customerservice
> http://localhost:8080/services/userservice
> 
> >
> >
> > And here is the demo inbound Restful service url which is holding the above
> > 3 services MBeans:
> >
> > http://localhost:8080/soapdemo/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
> >
> 
> I think you meant to say:
> 
> > http://localhost:8080/soapdemo/jmx
> 
> which is the address of your JMX server endpoint which should be changed to say
> "http://localhost:8080/services/jmx".
> 
> > which is:
> >
> > http://localhost:8080/soapdemo/jmx/service/{http://server.gsoc.apache.org/}CustomerServiceImpl
> >
> > http://localhost:8080/soapdemo/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
> >
> > http://localhost:8080/soapdemo/jmx/type/Bus.Service.Endpoint
> >
> > http://localhost:8080/soapdemo/jmx/list
> >
> >
> 
> Ok, so what are you saying is that you can have a list of all MBeans
> returned, using "/list" or a list of all MBeans which have a matching
> objectname or attribute (such as type, service, port, etc)
> 
> I like "http://localhost:8080/soapdemo/jmx/list and
> http://localhost:8080/soapdemo/jmx/objectname/" though I think we can
> simplify those, but right now make sure that you have something like
> @Path("{attribute}/{value}") for a method which serves /service/*, and
> /type/* requests. because 'service' and 'type' are attributes and we
> can have many attributes.
> 
> >
> > Request:
> >
> > http://localhost:8080/soapdemo/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
> >
> > Note: this is actually an url encoded string which is  from:
> >
> > http://localhost:8080/soapdemo/jmx/service/{http://server.gsoc.apache.org/}CustomerServiceImpl
> >
> OK, we should also be able to support
> 
> http://localhost:8080/soapdemo/jmx/service/{http://server.gsoc.apache.org/}*
> 
> which means get all MBeans which have a service attribute with
> namespace equal to 'http://server.gsoc.apache.org'
> 
> 
> > Response:
> >
> > <MBeanCollection>
> >
> >    <MBeans>
> >
> >       <MBean>
> >
> >
> > <canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> >
> >          <domain>org.apache.cxf</domain>
> >
> >
> > <endpointName>"{http://server.gsoc.apache.org/}CustomerServiceImpl"</endpointName>
> >
> >       </MBean>
> >
> >    </MBeans>
> >
> > </MBeanCollection>
> >
> OK. Please remove MBeanCollection wrapper, you have another wrapper, MBeans.
> No need to have quotes around endpointName's value.
> How about having MBean representation structured like this:
> 
> <MBean>
> <domain>org.apache.cxf</domain>
> <canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> <!-- this is another representation of canonical's name
> <attributes>
> <type>Bus.Service.Endpoint</type>
> <service>{http://server.gsoc.apache.org/}CustomerServiceImpl</service>
> <endpoint>CustomerServiceImpl</endpoint>
> <attributes>
> <!--
> This can be ignored for now
> <properties/>
> -->
> </MBean>
> 
> This will make it simpler for consumers to understand - we may support
> returning canonicalNames only or alternative, structured reps but for
> now just have MBean representation updated as suggested.
> 
> Now, there's one thing which is missing from the above representation
> and it is a link to a resource which will deal with a particular MBean
> (possible updates of properties, handling the notifications). We need
> to put it all into a more practical surface so it should be something
> like
> 
> <MBeans>
> <MBean href="http://localhost:8080/soapdemo/jmx/mbean/1">
> <domain>org.apache.cxf</domain>
> <canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> <MBean>
> <MBean href="http://localhost:8080/soapdemo/jmx/mbean/2">
> <domain>org.apache.cxf</domain>
> <canonicalName>org.apache.cxf:bus.id=cxf5663551,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> <MBean>
> </MBeans>
> 
> where http://localhost:8080/soapdemo/jmx/mbean/1,
> http://localhost:8080/soapdemo/jmx/mbean/2, etc, uniquely identify
> those individual MBeans only.
> 
> So please update MBean class to have "href" attribute (with
> @XmlAttribute). Have a '@Context UriInfo uriinfo' field in JMXServer
> class. When you create a response for /list or /service/*, etc, use
> UriInfo to get to the *base* UriBuilder which will represent a URI
> like "http://localhost:8080/soapdemo/jmx". Next add "mbean" and then a
> number like 1/2/etc which identifies a particular MBean, may be a
> short objectname instead of the compete canonical name, etc, so and
> have UriBuilder to return you
> 'http://localhost:8080/soapdemo/jmx/mbean/1', etc:
> 
> String href = builder.path("mbean").path(someUniqueKey).build().toString()
> 
> Now, the question is how to handle requests like
> 'http://localhost:8080/soapdemo/jmx/mbean/1'
> 
> Your JMXServer should have a subresource locator, with @Path("mbean")
> and without HttpMethod.
> This locator will return something like MBeanResource and that class,
> at this stage, will have *only*
> a single @GET resource method with @Path("{key}") and which will
> return the above MBean representaion only, without MBeans wrapper:
> 
> GET http://localhost:8080/soapdemo/jmx/mbean/1
> 
> returns
> 
> <MBean href="http://localhost:8080/soapdemo/jmx/mbean/1">
> <domain>org.apache.cxf</domain>
> <canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> </MBean>
> 
> Having a subresource handly because at the next step we will start
> working on dealing with notifications/updatiing properties or invoking
> operations somehow when applicable.
> 
> Does it make sense ? If you have any questions or suggestions - please
> ask them here or ping me on #cxf
> I guess we have two weeks or so and then I'd like to discuss how
> LogBrowser can be extended to act as a consumer of your JMXServer
> 
> I'm removing the rest of your message to make it shorter, everything
> you posted there looked OK, those who are interested can check the
> previous message if needed for more info.
> 
> You are progressing very well.
> 
> Thanks, Sergey
> 
> >
> > Thank you.
> >ld
> > Regards:
> > Shenglin Qiu
> >
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
I've no problems with Shenglin using svn or git. Does not matter.
AFAIK he already has a github account where his demo code is located.
The reason we've been asking CXF GSOC students to work with the
sandbox is that all those subscribed to the cxf-commits email can get
the immediate notifications. It's becoming part of the CXF dev
process.

That said, personally I'll be fine with Shenglin finishing the first
phase with providing a patch containing a code for JMXServer which I
can apply to the rt-management-web module. Right now Shenglin is doing
a lot of experiments with the code, catching up with JAX-RS and JMX,
so while it is not perfect, I'm fine so far with him providing the
regular updates on the dev list.

thanks, Sergey

On Tue, May 31, 2011 at 2:24 PM, Willem Jiang <wi...@gmail.com> wrote:
> That is why I suggest to use the github.
> He doesn't need anyone to approve :)
>
> BTW, it is more easy to try and test implementation codes with help of git.
>
> On 5/31/11 9:14 PM, Sergey Beryozkin wrote:
>>
>> Hi
>>
>> Shenglin submitted ICLA for him be able to start working in the
>> sandbox, he probably didn't get it approved yet
>> Cheers, Sergey
>>
>>
>> On Tue, May 31, 2011 at 2:00 PM, Willem Jiang<wi...@gmail.com>
>>  wrote:
>>>
>>> Hi Shenglin,
>>>
>>> Did you have a chance to use the SCM the manger your source code?
>>> I don't think it is a good practice to send the source code directly to
>>> the
>>> mailing list.
>>>
>>> You can use the github[1] to hold a fork a version of CXF[2] , and attach
>>> the patch to the JIRA[3] which we can trace.
>>> It worked perfectly for the GSoc project which I mentored.
>>>
>>> On 5/31/11 10:55 AM, Shenglin Qiu wrote:
>>>>
>>>> Source is also attached. I will ping you in the morning.
>>>
>>>
>>> [1]https://github.com/
>>> [2]https://github.com/apache/cxf
>>> [3]https://issues.apache.org/jira/browse/CXF
>>>
>>> --
>>> Willem
>>> ----------------------------------
>>> FuseSource
>>> Web: http://www.fusesource.com
>>> Blog:    http://willemjiang.blogspot.com (English)
>>>         http://jnn.javaeye.com (Chinese)
>>> Twitter: willemjiang
>>> Weibo: willemjiang
>>>
>>
>>
>>
>
>
> --
> Willem
> ----------------------------------
> FuseSource
> Web: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.com (English)
>         http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang
> Weibo: willemjiang
>



-- 
Sergey Beryozkin

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

Re: Expose MBeans in CXF

Posted by Willem Jiang <wi...@gmail.com>.
That is why I suggest to use the github.
He doesn't need anyone to approve :)

BTW, it is more easy to try and test implementation codes with help of git.

On 5/31/11 9:14 PM, Sergey Beryozkin wrote:
> Hi
>
> Shenglin submitted ICLA for him be able to start working in the
> sandbox, he probably didn't get it approved yet
> Cheers, Sergey
>
>
> On Tue, May 31, 2011 at 2:00 PM, Willem Jiang<wi...@gmail.com>  wrote:
>> Hi Shenglin,
>>
>> Did you have a chance to use the SCM the manger your source code?
>> I don't think it is a good practice to send the source code directly to the
>> mailing list.
>>
>> You can use the github[1] to hold a fork a version of CXF[2] , and attach
>> the patch to the JIRA[3] which we can trace.
>> It worked perfectly for the GSoc project which I mentored.
>>
>> On 5/31/11 10:55 AM, Shenglin Qiu wrote:
>>>
>>> Source is also attached. I will ping you in the morning.
>>
>>
>> [1]https://github.com/
>> [2]https://github.com/apache/cxf
>> [3]https://issues.apache.org/jira/browse/CXF
>>
>> --
>> Willem
>> ----------------------------------
>> FuseSource
>> Web: http://www.fusesource.com
>> Blog:    http://willemjiang.blogspot.com (English)
>>          http://jnn.javaeye.com (Chinese)
>> Twitter: willemjiang
>> Weibo: willemjiang
>>
>
>
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

Shenglin submitted ICLA for him be able to start working in the
sandbox, he probably didn't get it approved yet
Cheers, Sergey


On Tue, May 31, 2011 at 2:00 PM, Willem Jiang <wi...@gmail.com> wrote:
> Hi Shenglin,
>
> Did you have a chance to use the SCM the manger your source code?
> I don't think it is a good practice to send the source code directly to the
> mailing list.
>
> You can use the github[1] to hold a fork a version of CXF[2] , and attach
> the patch to the JIRA[3] which we can trace.
> It worked perfectly for the GSoc project which I mentored.
>
> On 5/31/11 10:55 AM, Shenglin Qiu wrote:
>>
>> Source is also attached. I will ping you in the morning.
>
>
> [1]https://github.com/
> [2]https://github.com/apache/cxf
> [3]https://issues.apache.org/jira/browse/CXF
>
> --
> Willem
> ----------------------------------
> FuseSource
> Web: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.com (English)
>         http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang
> Weibo: willemjiang
>



-- 
Sergey Beryozkin

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

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Shenglin

Our IRC chat is not going well as out IT connections are in bad shape today.
So, as you discovered,
/{property}/{value} catches /mbean/{id} - /{property}/{value} is
preferred because  /mbean/{id}
is a subresource locator even though it is less specific.

Thus I suggested to introduce a slightly diff scheme
/list
/list/{propertyName}/{propertyValue}
/list/objectName/{objectValue}

The above 3 resource methods return MbeanCollection

/mbean/{id} returns MBean (via MBeanResource) as discussed earlier on.

Please hurry up as you need to get /counters dealt with as well
Cheers, Sergey

On Thu, Jun 9, 2011 at 1:17 PM, Sergey Beryozkin <sb...@gmail.com> wrote:
> Hi Shenglin
>
> One thing which you are doing well is introducing subresources, given
> that both MBean and MBeanCotellection have become the ones.
> Understanding how subresources work is good in itself. I can see you
> have unique ids allocated to MBeans now. So there's some progress.
> IMHO some more code cleanup is needed.
>
> 1. At this stage please have only a ***single*** subresource,
> intoroduce a dedicated class called MBeanResource which should have
> only a single member, MBean instance. This MBeanResource should only
> have right now setMBean(MBean) and getMBean methods. getMBean method
> should be annotated with @GET.
>
> 2. MBean and MBeanCollection should have no static methods, and no
> JAX-RS resource methods at all. These are plain JAXB beans only.
>
> 3. JMXServer should have:
>  -  /mbean/{id}
>
> Note, Path value should be '/mbean/{id}'
>
>    You should use a captured {id}, such as 0, 1, 2, etc (as opposed
> to manually parsing path segments) for locating MBean, set this MBean
> on a new MBeanResource instance and return  MBeanResource,
> MBeanResource.getMBean will complete the processing. we will think
> later on how to keep MBeanResources between requests. The reason I'd
> like a dedicated MBeanResource wrap MBean is because possible
> modifications, update notifications, etc may need to be dealt with and
> thus IMHO it can be cleaner to keep MBean as a plain JAXB bean and
> have a dedicated JMX-aware handler around it as opposed to making
> MBean both JAXB and JMX-aware at the same time.
>
>  - /list
>
>  - /{property}/{value}
>
> Please note this method, /{property}/{value}, is on JMXServer. Remove
> @Path("") and replace it with  /{property}/{value}.
>
>  - /objectname/{objectname}
>
> This method should iterate over the existing MBeanCollection only
> without quering the instrumentation manager again.
>
> 3. All the methods should use the same code for accessing the map -
> which is what you already do. Some cleanup is needed there too, but
> for now please address the above
>
> thanks, Sergey
>
>
> On Thu, Jun 9, 2011 at 4:05 AM, Shenglin Qiu <da...@hotmail.com> wrote:
>> Hi Sergey:
>>
>> Sorry for replying a little bit late.
>> But I reverted the code as you mentioned /mbean/{id} must not be changed.
>>
>> Code has be synced to github:
>> https://github.com/dabaipang/services
>>
>> /**
>>  *  Specification:
>>  *  Function 1:
>>  *    Jmx Server:
>>  *    sub-resource locator
>>  *    http://localhost:8080/services/jmx/mbean/0
>>  *    http://localhost:8080/services/jmx/mbean/1
>>  *    ...
>>  *
>>  *
>>  *    Function 2:
>>  *    Note: search by bus.id, bus.id will be changed on every time server
>> had been bounced.
>>  *  http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>>  *
>> http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
>>  *    ...
>>  *
>> http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
>>  *
>> http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,port=%22SoapPort%22,type=Bus.Service.Endpoint,*
>>  *
>> http://localhost:8080/services/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
>>  *
>> http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,type=Bus.Service.Endpoint,*
>>  *
>> http://localhost:8080/services/jmx/objectname/org.apache.cxf:service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,*
>>  *
>>  *    Function 3:
>>  *    Search by service:
>>  *
>> http://localhost:8080/services/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
>>  *
>> http://localhost:8080/services/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DUserServiceImpl
>>  *
>>  *  Note, above queries are searching these 2, but replace by url encoding
>> from:
>>  *  {http://server.gsoc.apache.org/}UserServiceImpl
>>  *  {http://server.gsoc.apache.org/}CustomerServiceImpl
>>  *
>>  *    Search by type:
>>  *    http://localhost:8080/services/jmx/type/Bus.Service.Endpoint
>>  *
>>  *    Search by port:
>>  *    http://localhost:8080/services/jmx/port/UserServiceImpl
>>  *    http://localhost:8080/services/jmx/port/CustomerServiceImpl
>>  *    http://localhost:8080/services/jmx/port/SoapPort
>>  *
>>  *    Search by domain
>>  *    http://localhost:8080/services/jmx/domain/org.apache.cxf
>>  *
>>  *    Function 4:
>>  *    http://localhost:8080/services/jmx/list
>>  *
>>  * */
>>
>> Source is also attached.
>> Thank you very much on the reviewing, I am very dedicated to what you have
>> mentioned. Though there was a time in last 2 days, I reformatted the code a
>> little too much:)
>>
>>
>> Regards:
>> Shenglin Qiu
>>
>>
>>> Date: Wed, 8 Jun 2011 10:23:58 +0100
>>> Subject: Re: Expose MBeans in CXF
>>> From: sberyozkin@gmail.com
>>> To: dabaipang@hotmail.com
>>> CC: dev@cxf.apache.org
>>>
>>> Hi Shenglin
>>>
>>> I'm not sure if I'm confusing you with the comments I'm making...The
>>> source has become cleaner, good progress there,
>>> but I'm not sure what are you doing there at all now.
>>> Why MBeanCollection has become a subresource ? What happened to our
>>> /mbean/{id} handler ? Recall, you had a subresource locator method
>>> dealing with '/mbean/{id}' and you were delegating to MBean to finish
>>> the processing and the only thing I suggested is to have a dedicated
>>> MBeanResource handler which I guess should wrap an individual MBean
>>> and work with it (get its state for now, etc)
>>>
>>> What does
>>>
>>> http://localhost:8080/services/jmx/property/id/0
>>>
>>> mean ?
>>>
>>> it has to be
>>>
>>> http://localhost:8080/services/jmx/mbean/0
>>> http://localhost:8080/services/jmx/mbean/1
>>>
>>> and MBeanResource needs to deal with these URIs.
>>>
>>> Please check my previous email.
>>> have only
>>> 1. list all MBeans in org.apache.cxf domain
>>> /list
>>> 2. find MBeans in org.apache.cxf domain which have a given attribute value
>>> /{attribute}/{value}
>>> 3. find MBeans in org.apache.cxf domain their object names
>>> /objectname/{objectname}
>>> 4. get the represenation of the individual MBean (and later update it,
>>> register event listeners, etc)
>>> /mbean/{id}
>>>
>>> // we haven't discussed it yet - need to be done
>>> 5. Return the counter statistics
>>>
>>> /counters
>>>
>>> 6. Counters for a specific endpoint
>>>
>>> /counters/{servicename}
>>>
>>> Sergey
>>>
>>> On Wed, Jun 8, 2011 at 5:46 AM, Shenglin Qiu <da...@hotmail.com>
>>> wrote:
>>> > Hi Sergey:
>>> >
>>> > I attached the src and due to I am working on the mvn project only sync
>>> > to
>>> > svn, so I will take some time and sync this to github.
>>> >
>>> > And here is an update on the request:
>>> >
>>> > Self-defined demo inbound service:
>>> > http://localhost:8080/services/greeter?wsdl
>>> > http://localhost:8080/services/customerservice/customers
>>> > http://localhost:8080/services/customerservice/customer/firstname/Lois
>>> > http://localhost:8080/services/customerservice/customer/id/1
>>> > http://localhost:8080/services/userservice/users
>>> > http://localhost:8080/services/userservice/user/1
>>> > /**
>>> >  *  Specification:
>>> >  *  Function 1:
>>> >  *    Jmx Server:
>>> >  *    sub-resource locator
>>> >  *    http://localhost:8080/services/jmx/property/id/0
>>> >  *    http://localhost:8080/services/jmx/property/id/1
>>> >  *    ...
>>> >  *
>>> >  *
>>> >  *    Function 2:
>>> >  *    Note: search by bus.id, bus.id will be changed on every time
>>> > server
>>> > had been bounced.
>>> >  *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>>> >  *
>>> >
>>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
>>> >  *    ...
>>> >  *
>>> >
>>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
>>> >  *
>>> >
>>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,port=%22SoapPort%22,type=Bus.Service.Endpoint,*
>>> >  *
>>> >
>>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
>>> >  *
>>> >
>>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,type=Bus.Service.Endpoint,*
>>> >  *
>>> >
>>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,*
>>> >  *
>>> >  *    Function 3:
>>> >  *    Search by service:
>>> >  *
>>> >
>>> > http://localhost:8080/services/jmx/property/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
>>> >  *
>>> >
>>> > http://localhost:8080/services/jmx/property/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DUserServiceImpl
>>> >  *
>>> >  *  Note, above queries are searching these 2, but replace by url
>>> > encoding
>>> > from:
>>> >  *  {http://server.gsoc.apache.org/}UserServiceImpl
>>> >  *  {http://server.gsoc.apache.org/}CustomerServiceImpl
>>> >  *
>>> >  *    Search by type:
>>> >  *
>>> > http://localhost:8080/services/jmx/property/type/Bus.Service.Endpoint
>>> >  *
>>> >  *    Search by port:
>>> >  *    http://localhost:8080/services/jmx/property/port/UserServiceImpl
>>> >  *
>>> > http://localhost:8080/services/jmx/property/port/CustomerServiceImpl
>>> >  *    http://localhost:8080/services/jmx/property/port/SoapPort
>>> >  *
>>> >  *    Function 4:
>>> >  *    http://localhost:8080/services/jmx/list
>>> >  *
>>> >  * */
>>> >
>>> > I will ping you tomorrow morning.
>>> >
>>> > Thank you.
>>> > Regards:
>>> >
>>> > Shenglin Qiu
>>> >
>>> >
>>> >> Date: Wed, 1 Jun 2011 15:32:30 +0100
>>> >> Subject: Re: Expose MBeans in CXF
>>> >> From: sberyozkin@gmail.com
>>> >> To: dev@cxf.apache.org
>>> >>
>>> >> Hi Shenglin
>>> >>
>>> >> It's a step in the right direction, thanks, but JMXServer still needs
>>> >> to be cleaned up quite a bit.
>>> >> - as I said earlier you have 4 big functions basically duplicating
>>> >> each other. We can't have a method per every attribute a given MBean
>>> >> may have. Have a single function only, max two (one capturing all the
>>> >> attributes, another one - dedicated to objectname/{value}).
>>> >> - Introduce MBeanResource subresource instead of overloading MBean, it
>>> >> will be cleaner and easier to work with
>>> >> - as suggested earlier, update the domain MBean and/or MBeanAttribute
>>> >> such that you could drop a big chunk of code in JMXServer where
>>> >> individual attribute values are set, currently in getMbeanMap (if
>>> >> (attrName.equals("service") then/else)). That is because a number of
>>> >> attributes is basically unlimited, even though we have some well-known
>>> >> ones
>>> >>
>>> >> - getMBeanMap - this is so complex I can't understand what it does. I
>>> >> do understand it returns a thread-safe Map - but I'm finding it
>>> >> difficult to understand how the method achieves that. Please remove
>>> >> all those synchronized blocks and have ConcurrentHashMap. Have atomic
>>> >> integer counter, synchronized exlicitly (in a block) if you prefer,
>>> >> and try to get a simple and effective function implemented. Don't make
>>> >> the logic of that function dependent on a n
>>> >> I don't understand why you use "list" for creating MBean hrefs;
>>> >>
>>> >> - there's no need for having Mbean.id and MBean.href because
>>> >> MBean.href is identifying a given MBean uniquely and thus you could
>>> >> use that calculated href as a key.
>>> >>
>>> >> Thanks, Sergey
>>> >>
>>> >>
>>> >> On Tue, May 31, 2011 at 5:36 PM, Shenglin Qiu <da...@hotmail.com>
>>> >> wrote:
>>> >> >
>>> >> > Hi Sergey:
>>> >> >
>>> >> > Project has been synced to Github:
>>> >> >
>>> >> > Browser:
>>> >> > https://github.com/dabaipang/services
>>> >> >
>>> >> >
>>> >> > Git address:
>>> >> > https://dabaipang@github.com/dabaipang/services.git
>>> >> > or
>>> >> > git@github.com:dabaipang/services.git
>>> >> >
>>> >> >
>>> >> > Thank you.
>>> >> >
>>> >> >
>>> >> > Regards:
>>> >> > Shenglin Qiu
>>> >> >
>>> >> >
>>> >> >
>>> >> >> From: dabaipang@hotmail.com
>>> >> >> To: sberyozkin@gmail.com
>>> >> >> CC: dev@cxf.apache.org
>>> >> >> Subject: RE: Expose MBeans in CXF
>>> >> >> Date: Tue, 31 May 2011 11:23:38 -0400
>>> >> >>
>>> >> >>
>>> >> >> Hi Sergey:
>>> >> >>
>>> >> >> > > Function 1: (0 - 5 is continuous, no gap)
>>> >> >> > > Jmx Server:
>>> >> >> > > sub-resource locator
>>> >> >> > > http://localhost:8080/services/jmx/mbean/0
>>> >> >> > > http://localhost:8080/services/jmx/mbean/1
>>> >> >> >
>>> >> >> > The id allocation (0, 1, etc) has to be thread safe
>>> >> >>
>>> >> >> Done with:
>>> >> >> private synchronized Map<String, MBean> getMBeansMap(){
>>> >> >>  ....
>>> >> >> }
>>> >> >> My reason not using synchronized block but using synchronized method
>>> >> >> is:
>>> >> >> this guarantees the order on mbeansMap's initialization,  so when
>>> >> >> it's
>>> >> >> called by a lot of requests, the followings will have to wait, unit
>>> >> >> the
>>> >> >> first one finished,  after that, following requests will see
>>> >> >> mbeansMap has
>>> >> >> been initialized, and simply return mbeansMap without initializing
>>> >> >> it again.
>>> >> >>
>>> >> >>
>>> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>>> >> >> > or
>>> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
>>> >> >> >
>>> >> >> > should also work
>>> >> >> >
>>> >> >> > >
>>> >> >>
>>> >> >> http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>>> >> >> is working.
>>> >> >>
>>> >> >> > > Due to the URL duplication with /mbean/{id}, I can't put
>>> >> >> > > {searchtype}/{query}, so I put things like:
>>> >> >> >
>>> >> >> > Personally I'd  prefer to keep a URI as minimal as possible.
>>> >> >> >
>>> >> >> > /mbean/{id}
>>> >> >> > and
>>> >> >> > {searchtype}/{query}
>>> >> >> >
>>> >> >> > do not duplicate each other given that /mbean/{id} is more
>>> >> >> > specific
>>> >> >> > than {searchtype}/{query}.
>>> >> >> > Likewise /objectname/{objectname} is more specific than
>>> >> >> > {searchtype}/{query}, so consider dropping /search/ part,
>>> >> >> > we may have a dedicated /search handler later on.
>>> >> >>
>>> >> >> Done by dedicating each request per method:
>>> >> >>     @GET
>>> >> >>     @POST
>>> >> >>     @Path("/list")
>>> >> >>     public MBeanCollection list()
>>> >> >>
>>> >> >>     @Path("/mbean/")
>>> >> >>     public MBean locateMBean()
>>> >> >>
>>> >> >>
>>> >> >>     @GET
>>> >> >>     @POST
>>> >> >>     @Path("/type/{query}")
>>> >> >>     public MBeanCollection searchMBeansByType(@PathParam("query")
>>> >> >> String query)
>>> >> >>
>>> >> >>
>>> >> >>     @GET
>>> >> >>     @POST
>>> >> >>     @Path("/port/{query}")
>>> >> >>     public MBeanCollection searchMBeansByPort(@PathParam("query")
>>> >> >> String query)
>>> >> >>
>>> >> >>
>>> >> >>     @GET
>>> >> >>     @POST
>>> >> >>     @Path("/service/{query}")
>>> >> >>     public MBeanCollection searchMBeansByService(@PathParam("query")
>>> >> >> String query)
>>> >> >>
>>> >> >>
>>> >> >>     @GET
>>> >> >>     @POST
>>> >> >>     @Path("/objectname/{objectname}")
>>> >> >>     public  MBeanCollection getComponent(@PathParam("objectname")
>>> >> >> String objectname)
>>> >> >>
>>> >> >> I remembered you mentioned to handle Exceptions once, currently I am
>>> >> >> still 'throws' -ing them out, I will make the try catch block.
>>> >> >> Should I also add a new object which display the error or simply
>>> >> >> return
>>> >> >> empty?
>>> >> >>
>>> >> >>
>>> >> >> Thank you very much.
>>> >> >>
>>> >> >>
>>> >> >> Regards:
>>> >> >> Shenglin Qiu
>>> >> >>
>>> >> >>
>>> >> >> > Date: Tue, 31 May 2011 10:35:36 +0100
>>> >> >> > Subject: Re: Expose MBeans in CXF
>>> >> >> > From: sberyozkin@gmail.com
>>> >> >> > To: dev@cxf.apache.org
>>> >> >> >
>>> >> >> > Hi Shenglin
>>> >> >> >
>>> >> >> > Good progress, some comments below
>>> >> >> > >
>>> >> >> > > Function 1: (0 - 5 is continuous, no gap)
>>> >> >> > > Jmx Server:
>>> >> >> > > sub-resource locator
>>> >> >> > > http://localhost:8080/services/jmx/mbean/0
>>> >> >> > > http://localhost:8080/services/jmx/mbean/1
>>> >> >> >
>>> >> >> > The id allocation (0, 1, etc) has to be thread safe
>>> >> >> >
>>> >> >> > >
>>> >> >> > >
>>> >> >> > > Function 2:
>>> >> >> > > Note: search by bus.id, bus.id will be changed on every time
>>> >> >> > > server
>>> >> >> > > had been
>>> >> >> > > bounced.
>>> >> >> > >
>>> >> >> > >
>>> >> >> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
>>> >> >> > > ...
>>> >> >> > that is ok, a user does not have to specify them as you
>>> >> >> > demonstrated
>>> >> >> > with queries like
>>> >> >> >
>>> >> >> > >
>>> >> >> > >
>>> >> >> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
>>> >> >> > I guess
>>> >> >> >
>>> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>>> >> >> > or
>>> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
>>> >> >> >
>>> >> >> > should also work
>>> >> >> >
>>> >> >> > >
>>> >> >> > >
>>> >> >> > > I am only now use 2 methods to fulfill:
>>> >> >> > > 1 method for service/{serivce}, port/{port}, type/{type}
>>> >> >> > > 1 method for objectname/{objectname}
>>> >> >> >
>>> >> >> > OK
>>> >> >> >
>>> >> >> > >
>>> >> >> > > Due to the URL duplication with /mbean/{id}, I can't put
>>> >> >> > > {searchtype}/{query}, so I put things like:
>>> >> >> >
>>> >> >> > Personally I'd  prefer to keep a URI as minimal as possible.
>>> >> >> >
>>> >> >> > /mbean/{id}
>>> >> >> > and
>>> >> >> > {searchtype}/{query}
>>> >> >> >
>>> >> >> > do not duplicate each other given that /mbean/{id} is more
>>> >> >> > specific
>>> >> >> > than {searchtype}/{query}.
>>> >> >> > Likewise /objectname/{objectname} is more specific than
>>> >> >> > {searchtype}/{query}, so consider dropping /search/ part,
>>> >> >> > we may have a dedicated /search handler later on.
>>> >> >> >
>>> >> >> > The other thing I forgot to mention, please remove all those
>>> >> >> > System.out.println, ping me please if you need some help with
>>> >> >> > setting
>>> >> >> > up a remote debugging session
>>> >> >> >
>>> >> >> > Thanks, Sergey
>>> >> >> >
>>> >> >> > >
>>> >> >> > > Thank you so much!
>>> >> >> > >
>>> >> >> > > 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
>>
>
>
>
> --
> Sergey Beryozkin
>
> Application Integration Division of Talend
> http://sberyozkin.blogspot.com
>



-- 
Sergey Beryozkin

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

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi Sergey:

Continue from last talk in im, 
@Path("/mbean/{id}")
    public MBean searchMBeanById(@PathParam("id")String id){

@GET
    @Path("/{property}/{value}")
    public MBeanCollection searchMBeans(@PathParam("property") String property, @PathParam("value") String value)

is now working as desired.

What I did wrong is put

@Path("/mbean/")

    public MBean searchMBeanById(){

and put {id} in MBeanResource.

Thank you for clarifying this out so hard and finally I make it.
I will wrap things up real quick and give you the email update with src.

Regards:
Shenglin Qiu

> Date: Thu, 9 Jun 2011 13:17:49 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dev@cxf.apache.org
> 
> Hi Shenglin
> 
> One thing which you are doing well is introducing subresources, given
> that both MBean and MBeanCotellection have become the ones.
> Understanding how subresources work is good in itself. I can see you
> have unique ids allocated to MBeans now. So there's some progress.
> IMHO some more code cleanup is needed.
> 
> 1. At this stage please have only a ***single*** subresource,
> intoroduce a dedicated class called MBeanResource which should have
> only a single member, MBean instance. This MBeanResource should only
> have right now setMBean(MBean) and getMBean methods. getMBean method
> should be annotated with @GET.
> 
> 2. MBean and MBeanCollection should have no static methods, and no
> JAX-RS resource methods at all. These are plain JAXB beans only.
> 
> 3. JMXServer should have:
>  -  /mbean/{id}
> 
> Note, Path value should be '/mbean/{id}'
> 
>     You should use a captured {id}, such as 0, 1, 2, etc (as opposed
> to manually parsing path segments) for locating MBean, set this MBean
> on a new MBeanResource instance and return  MBeanResource,
> MBeanResource.getMBean will complete the processing. we will think
> later on how to keep MBeanResources between requests. The reason I'd
> like a dedicated MBeanResource wrap MBean is because possible
> modifications, update notifications, etc may need to be dealt with and
> thus IMHO it can be cleaner to keep MBean as a plain JAXB bean and
> have a dedicated JMX-aware handler around it as opposed to making
> MBean both JAXB and JMX-aware at the same time.
> 
>  - /list
> 
>  - /{property}/{value}
> 
> Please note this method, /{property}/{value}, is on JMXServer. Remove
> @Path("") and replace it with  /{property}/{value}.
> 
>  - /objectname/{objectname}
> 
> This method should iterate over the existing MBeanCollection only
> without quering the instrumentation manager again.
> 
> 3. All the methods should use the same code for accessing the map -
> which is what you already do. Some cleanup is needed there too, but
> for now please address the above
> 
> thanks, Sergey
> 
> 
> On Thu, Jun 9, 2011 at 4:05 AM, Shenglin Qiu <da...@hotmail.com> wrote:
> > Hi Sergey:
> >
> > Sorry for replying a little bit late.
> > But I reverted the code as you mentioned /mbean/{id} must not be changed.
> >
> > Code has be synced to github:
> > https://github.com/dabaipang/services
> >
> > /**
> >  *  Specification:
> >  *  Function 1:
> >  *    Jmx Server:
> >  *    sub-resource locator
> >  *    http://localhost:8080/services/jmx/mbean/0
> >  *    http://localhost:8080/services/jmx/mbean/1
> >  *    ...
> >  *
> >  *
> >  *    Function 2:
> >  *    Note: search by bus.id, bus.id will be changed on every time server
> > had been bounced.
> >  *  http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> >  *
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
> >  *    ...
> >  *
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
> >  *
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,port=%22SoapPort%22,type=Bus.Service.Endpoint,*
> >  *
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
> >  *
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,type=Bus.Service.Endpoint,*
> >  *
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,*
> >  *
> >  *    Function 3:
> >  *    Search by service:
> >  *
> > http://localhost:8080/services/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
> >  *
> > http://localhost:8080/services/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DUserServiceImpl
> >  *
> >  *  Note, above queries are searching these 2, but replace by url encoding
> > from:
> >  *  {http://server.gsoc.apache.org/}UserServiceImpl
> >  *  {http://server.gsoc.apache.org/}CustomerServiceImpl
> >  *
> >  *    Search by type:
> >  *    http://localhost:8080/services/jmx/type/Bus.Service.Endpoint
> >  *
> >  *    Search by port:
> >  *    http://localhost:8080/services/jmx/port/UserServiceImpl
> >  *    http://localhost:8080/services/jmx/port/CustomerServiceImpl
> >  *    http://localhost:8080/services/jmx/port/SoapPort
> >  *
> >  *    Search by domain
> >  *    http://localhost:8080/services/jmx/domain/org.apache.cxf
> >  *
> >  *    Function 4:
> >  *    http://localhost:8080/services/jmx/list
> >  *
> >  * */
> >
> > Source is also attached.
> > Thank you very much on the reviewing, I am very dedicated to what you have
> > mentioned. Though there was a time in last 2 days, I reformatted the code a
> > little too much:)
> >
> >
> > Regards:
> > Shenglin Qiu
> >
> >
> >> Date: Wed, 8 Jun 2011 10:23:58 +0100
> >> Subject: Re: Expose MBeans in CXF
> >> From: sberyozkin@gmail.com
> >> To: dabaipang@hotmail.com
> >> CC: dev@cxf.apache.org
> >>
> >> Hi Shenglin
> >>
> >> I'm not sure if I'm confusing you with the comments I'm making...The
> >> source has become cleaner, good progress there,
> >> but I'm not sure what are you doing there at all now.
> >> Why MBeanCollection has become a subresource ? What happened to our
> >> /mbean/{id} handler ? Recall, you had a subresource locator method
> >> dealing with '/mbean/{id}' and you were delegating to MBean to finish
> >> the processing and the only thing I suggested is to have a dedicated
> >> MBeanResource handler which I guess should wrap an individual MBean
> >> and work with it (get its state for now, etc)
> >>
> >> What does
> >>
> >> http://localhost:8080/services/jmx/property/id/0
> >>
> >> mean ?
> >>
> >> it has to be
> >>
> >> http://localhost:8080/services/jmx/mbean/0
> >> http://localhost:8080/services/jmx/mbean/1
> >>
> >> and MBeanResource needs to deal with these URIs.
> >>
> >> Please check my previous email.
> >> have only
> >> 1. list all MBeans in org.apache.cxf domain
> >> /list
> >> 2. find MBeans in org.apache.cxf domain which have a given attribute value
> >> /{attribute}/{value}
> >> 3. find MBeans in org.apache.cxf domain their object names
> >> /objectname/{objectname}
> >> 4. get the represenation of the individual MBean (and later update it,
> >> register event listeners, etc)
> >> /mbean/{id}
> >>
> >> // we haven't discussed it yet - need to be done
> >> 5. Return the counter statistics
> >>
> >> /counters
> >>
> >> 6. Counters for a specific endpoint
> >>
> >> /counters/{servicename}
> >>
> >> Sergey
> >>
> >> On Wed, Jun 8, 2011 at 5:46 AM, Shenglin Qiu <da...@hotmail.com>
> >> wrote:
> >> > Hi Sergey:
> >> >
> >> > I attached the src and due to I am working on the mvn project only sync
> >> > to
> >> > svn, so I will take some time and sync this to github.
> >> >
> >> > And here is an update on the request:
> >> >
> >> > Self-defined demo inbound service:
> >> > http://localhost:8080/services/greeter?wsdl
> >> > http://localhost:8080/services/customerservice/customers
> >> > http://localhost:8080/services/customerservice/customer/firstname/Lois
> >> > http://localhost:8080/services/customerservice/customer/id/1
> >> > http://localhost:8080/services/userservice/users
> >> > http://localhost:8080/services/userservice/user/1
> >> > /**
> >> >  *  Specification:
> >> >  *  Function 1:
> >> >  *    Jmx Server:
> >> >  *    sub-resource locator
> >> >  *    http://localhost:8080/services/jmx/property/id/0
> >> >  *    http://localhost:8080/services/jmx/property/id/1
> >> >  *    ...
> >> >  *
> >> >  *
> >> >  *    Function 2:
> >> >  *    Note: search by bus.id, bus.id will be changed on every time
> >> > server
> >> > had been bounced.
> >> >  *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> >> >  *
> >> >
> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
> >> >  *    ...
> >> >  *
> >> >
> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
> >> >  *
> >> >
> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,port=%22SoapPort%22,type=Bus.Service.Endpoint,*
> >> >  *
> >> >
> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
> >> >  *
> >> >
> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,type=Bus.Service.Endpoint,*
> >> >  *
> >> >
> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,*
> >> >  *
> >> >  *    Function 3:
> >> >  *    Search by service:
> >> >  *
> >> >
> >> > http://localhost:8080/services/jmx/property/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
> >> >  *
> >> >
> >> > http://localhost:8080/services/jmx/property/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DUserServiceImpl
> >> >  *
> >> >  *  Note, above queries are searching these 2, but replace by url
> >> > encoding
> >> > from:
> >> >  *  {http://server.gsoc.apache.org/}UserServiceImpl
> >> >  *  {http://server.gsoc.apache.org/}CustomerServiceImpl
> >> >  *
> >> >  *    Search by type:
> >> >  *
> >> > http://localhost:8080/services/jmx/property/type/Bus.Service.Endpoint
> >> >  *
> >> >  *    Search by port:
> >> >  *    http://localhost:8080/services/jmx/property/port/UserServiceImpl
> >> >  *
> >> > http://localhost:8080/services/jmx/property/port/CustomerServiceImpl
> >> >  *    http://localhost:8080/services/jmx/property/port/SoapPort
> >> >  *
> >> >  *    Function 4:
> >> >  *    http://localhost:8080/services/jmx/list
> >> >  *
> >> >  * */
> >> >
> >> > I will ping you tomorrow morning.
> >> >
> >> > Thank you.
> >> > Regards:
> >> >
> >> > Shenglin Qiu
> >> >
> >> >
> >> >> Date: Wed, 1 Jun 2011 15:32:30 +0100
> >> >> Subject: Re: Expose MBeans in CXF
> >> >> From: sberyozkin@gmail.com
> >> >> To: dev@cxf.apache.org
> >> >>
> >> >> Hi Shenglin
> >> >>
> >> >> It's a step in the right direction, thanks, but JMXServer still needs
> >> >> to be cleaned up quite a bit.
> >> >> - as I said earlier you have 4 big functions basically duplicating
> >> >> each other. We can't have a method per every attribute a given MBean
> >> >> may have. Have a single function only, max two (one capturing all the
> >> >> attributes, another one - dedicated to objectname/{value}).
> >> >> - Introduce MBeanResource subresource instead of overloading MBean, it
> >> >> will be cleaner and easier to work with
> >> >> - as suggested earlier, update the domain MBean and/or MBeanAttribute
> >> >> such that you could drop a big chunk of code in JMXServer where
> >> >> individual attribute values are set, currently in getMbeanMap (if
> >> >> (attrName.equals("service") then/else)). That is because a number of
> >> >> attributes is basically unlimited, even though we have some well-known
> >> >> ones
> >> >>
> >> >> - getMBeanMap - this is so complex I can't understand what it does. I
> >> >> do understand it returns a thread-safe Map - but I'm finding it
> >> >> difficult to understand how the method achieves that. Please remove
> >> >> all those synchronized blocks and have ConcurrentHashMap. Have atomic
> >> >> integer counter, synchronized exlicitly (in a block) if you prefer,
> >> >> and try to get a simple and effective function implemented. Don't make
> >> >> the logic of that function dependent on a n
> >> >> I don't understand why you use "list" for creating MBean hrefs;
> >> >>
> >> >> - there's no need for having Mbean.id and MBean.href because
> >> >> MBean.href is identifying a given MBean uniquely and thus you could
> >> >> use that calculated href as a key.
> >> >>
> >> >> Thanks, Sergey
> >> >>
> >> >>
> >> >> On Tue, May 31, 2011 at 5:36 PM, Shenglin Qiu <da...@hotmail.com>
> >> >> wrote:
> >> >> >
> >> >> > Hi Sergey:
> >> >> >
> >> >> > Project has been synced to Github:
> >> >> >
> >> >> > Browser:
> >> >> > https://github.com/dabaipang/services
> >> >> >
> >> >> >
> >> >> > Git address:
> >> >> > https://dabaipang@github.com/dabaipang/services.git
> >> >> > or
> >> >> > git@github.com:dabaipang/services.git
> >> >> >
> >> >> >
> >> >> > Thank you.
> >> >> >
> >> >> >
> >> >> > Regards:
> >> >> > Shenglin Qiu
> >> >> >
> >> >> >
> >> >> >
> >> >> >> From: dabaipang@hotmail.com
> >> >> >> To: sberyozkin@gmail.com
> >> >> >> CC: dev@cxf.apache.org
> >> >> >> Subject: RE: Expose MBeans in CXF
> >> >> >> Date: Tue, 31 May 2011 11:23:38 -0400
> >> >> >>
> >> >> >>
> >> >> >> Hi Sergey:
> >> >> >>
> >> >> >> > > Function 1: (0 - 5 is continuous, no gap)
> >> >> >> > > Jmx Server:
> >> >> >> > > sub-resource locator
> >> >> >> > > http://localhost:8080/services/jmx/mbean/0
> >> >> >> > > http://localhost:8080/services/jmx/mbean/1
> >> >> >> >
> >> >> >> > The id allocation (0, 1, etc) has to be thread safe
> >> >> >>
> >> >> >> Done with:
> >> >> >> private synchronized Map<String, MBean> getMBeansMap(){
> >> >> >>  ....
> >> >> >> }
> >> >> >> My reason not using synchronized block but using synchronized method
> >> >> >> is:
> >> >> >> this guarantees the order on mbeansMap's initialization,  so when
> >> >> >> it's
> >> >> >> called by a lot of requests, the followings will have to wait, unit
> >> >> >> the
> >> >> >> first one finished,  after that, following requests will see
> >> >> >> mbeansMap has
> >> >> >> been initialized, and simply return mbeansMap without initializing
> >> >> >> it again.
> >> >> >>
> >> >> >>
> >> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> >> >> >> > or
> >> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
> >> >> >> >
> >> >> >> > should also work
> >> >> >> >
> >> >> >> > >
> >> >> >>
> >> >> >> http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> >> >> >> is working.
> >> >> >>
> >> >> >> > > Due to the URL duplication with /mbean/{id}, I can't put
> >> >> >> > > {searchtype}/{query}, so I put things like:
> >> >> >> >
> >> >> >> > Personally I'd  prefer to keep a URI as minimal as possible.
> >> >> >> >
> >> >> >> > /mbean/{id}
> >> >> >> > and
> >> >> >> > {searchtype}/{query}
> >> >> >> >
> >> >> >> > do not duplicate each other given that /mbean/{id} is more
> >> >> >> > specific
> >> >> >> > than {searchtype}/{query}.
> >> >> >> > Likewise /objectname/{objectname} is more specific than
> >> >> >> > {searchtype}/{query}, so consider dropping /search/ part,
> >> >> >> > we may have a dedicated /search handler later on.
> >> >> >>
> >> >> >> Done by dedicating each request per method:
> >> >> >>     @GET
> >> >> >>     @POST
> >> >> >>     @Path("/list")
> >> >> >>     public MBeanCollection list()
> >> >> >>
> >> >> >>     @Path("/mbean/")
> >> >> >>     public MBean locateMBean()
> >> >> >>
> >> >> >>
> >> >> >>     @GET
> >> >> >>     @POST
> >> >> >>     @Path("/type/{query}")
> >> >> >>     public MBeanCollection searchMBeansByType(@PathParam("query")
> >> >> >> String query)
> >> >> >>
> >> >> >>
> >> >> >>     @GET
> >> >> >>     @POST
> >> >> >>     @Path("/port/{query}")
> >> >> >>     public MBeanCollection searchMBeansByPort(@PathParam("query")
> >> >> >> String query)
> >> >> >>
> >> >> >>
> >> >> >>     @GET
> >> >> >>     @POST
> >> >> >>     @Path("/service/{query}")
> >> >> >>     public MBeanCollection searchMBeansByService(@PathParam("query")
> >> >> >> String query)
> >> >> >>
> >> >> >>
> >> >> >>     @GET
> >> >> >>     @POST
> >> >> >>     @Path("/objectname/{objectname}")
> >> >> >>     public  MBeanCollection getComponent(@PathParam("objectname")
> >> >> >> String objectname)
> >> >> >>
> >> >> >> I remembered you mentioned to handle Exceptions once, currently I am
> >> >> >> still 'throws' -ing them out, I will make the try catch block.
> >> >> >> Should I also add a new object which display the error or simply
> >> >> >> return
> >> >> >> empty?
> >> >> >>
> >> >> >>
> >> >> >> Thank you very much.
> >> >> >>
> >> >> >>
> >> >> >> Regards:
> >> >> >> Shenglin Qiu
> >> >> >>
> >> >> >>
> >> >> >> > Date: Tue, 31 May 2011 10:35:36 +0100
> >> >> >> > Subject: Re: Expose MBeans in CXF
> >> >> >> > From: sberyozkin@gmail.com
> >> >> >> > To: dev@cxf.apache.org
> >> >> >> >
> >> >> >> > Hi Shenglin
> >> >> >> >
> >> >> >> > Good progress, some comments below
> >> >> >> > >
> >> >> >> > > Function 1: (0 - 5 is continuous, no gap)
> >> >> >> > > Jmx Server:
> >> >> >> > > sub-resource locator
> >> >> >> > > http://localhost:8080/services/jmx/mbean/0
> >> >> >> > > http://localhost:8080/services/jmx/mbean/1
> >> >> >> >
> >> >> >> > The id allocation (0, 1, etc) has to be thread safe
> >> >> >> >
> >> >> >> > >
> >> >> >> > >
> >> >> >> > > Function 2:
> >> >> >> > > Note: search by bus.id, bus.id will be changed on every time
> >> >> >> > > server
> >> >> >> > > had been
> >> >> >> > > bounced.
> >> >> >> > >
> >> >> >> > >
> >> >> >> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
> >> >> >> > > ...
> >> >> >> > that is ok, a user does not have to specify them as you
> >> >> >> > demonstrated
> >> >> >> > with queries like
> >> >> >> >
> >> >> >> > >
> >> >> >> > >
> >> >> >> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
> >> >> >> > I guess
> >> >> >> >
> >> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> >> >> >> > or
> >> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
> >> >> >> >
> >> >> >> > should also work
> >> >> >> >
> >> >> >> > >
> >> >> >> > >
> >> >> >> > > I am only now use 2 methods to fulfill:
> >> >> >> > > 1 method for service/{serivce}, port/{port}, type/{type}
> >> >> >> > > 1 method for objectname/{objectname}
> >> >> >> >
> >> >> >> > OK
> >> >> >> >
> >> >> >> > >
> >> >> >> > > Due to the URL duplication with /mbean/{id}, I can't put
> >> >> >> > > {searchtype}/{query}, so I put things like:
> >> >> >> >
> >> >> >> > Personally I'd  prefer to keep a URI as minimal as possible.
> >> >> >> >
> >> >> >> > /mbean/{id}
> >> >> >> > and
> >> >> >> > {searchtype}/{query}
> >> >> >> >
> >> >> >> > do not duplicate each other given that /mbean/{id} is more
> >> >> >> > specific
> >> >> >> > than {searchtype}/{query}.
> >> >> >> > Likewise /objectname/{objectname} is more specific than
> >> >> >> > {searchtype}/{query}, so consider dropping /search/ part,
> >> >> >> > we may have a dedicated /search handler later on.
> >> >> >> >
> >> >> >> > The other thing I forgot to mention, please remove all those
> >> >> >> > System.out.println, ping me please if you need some help with
> >> >> >> > setting
> >> >> >> > up a remote debugging session
> >> >> >> >
> >> >> >> > Thanks, Sergey
> >> >> >> >
> >> >> >> > >
> >> >> >> > > Thank you so much!
> >> >> >> > >
> >> >> >> > > 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
> >
> 
> 
> 
> -- 
> Sergey Beryozkin
> 
> Application Integration Division of Talend
> http://sberyozkin.blogspot.com
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Shenglin

One thing which you are doing well is introducing subresources, given
that both MBean and MBeanCotellection have become the ones.
Understanding how subresources work is good in itself. I can see you
have unique ids allocated to MBeans now. So there's some progress.
IMHO some more code cleanup is needed.

1. At this stage please have only a ***single*** subresource,
intoroduce a dedicated class called MBeanResource which should have
only a single member, MBean instance. This MBeanResource should only
have right now setMBean(MBean) and getMBean methods. getMBean method
should be annotated with @GET.

2. MBean and MBeanCollection should have no static methods, and no
JAX-RS resource methods at all. These are plain JAXB beans only.

3. JMXServer should have:
 -  /mbean/{id}

Note, Path value should be '/mbean/{id}'

    You should use a captured {id}, such as 0, 1, 2, etc (as opposed
to manually parsing path segments) for locating MBean, set this MBean
on a new MBeanResource instance and return  MBeanResource,
MBeanResource.getMBean will complete the processing. we will think
later on how to keep MBeanResources between requests. The reason I'd
like a dedicated MBeanResource wrap MBean is because possible
modifications, update notifications, etc may need to be dealt with and
thus IMHO it can be cleaner to keep MBean as a plain JAXB bean and
have a dedicated JMX-aware handler around it as opposed to making
MBean both JAXB and JMX-aware at the same time.

 - /list

 - /{property}/{value}

Please note this method, /{property}/{value}, is on JMXServer. Remove
@Path("") and replace it with  /{property}/{value}.

 - /objectname/{objectname}

This method should iterate over the existing MBeanCollection only
without quering the instrumentation manager again.

3. All the methods should use the same code for accessing the map -
which is what you already do. Some cleanup is needed there too, but
for now please address the above

thanks, Sergey


On Thu, Jun 9, 2011 at 4:05 AM, Shenglin Qiu <da...@hotmail.com> wrote:
> Hi Sergey:
>
> Sorry for replying a little bit late.
> But I reverted the code as you mentioned /mbean/{id} must not be changed.
>
> Code has be synced to github:
> https://github.com/dabaipang/services
>
> /**
>  *  Specification:
>  *  Function 1:
>  *    Jmx Server:
>  *    sub-resource locator
>  *    http://localhost:8080/services/jmx/mbean/0
>  *    http://localhost:8080/services/jmx/mbean/1
>  *    ...
>  *
>  *
>  *    Function 2:
>  *    Note: search by bus.id, bus.id will be changed on every time server
> had been bounced.
>  *  http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>  *
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
>  *    ...
>  *
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
>  *
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,port=%22SoapPort%22,type=Bus.Service.Endpoint,*
>  *
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
>  *
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,type=Bus.Service.Endpoint,*
>  *
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,*
>  *
>  *    Function 3:
>  *    Search by service:
>  *
> http://localhost:8080/services/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
>  *
> http://localhost:8080/services/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DUserServiceImpl
>  *
>  *  Note, above queries are searching these 2, but replace by url encoding
> from:
>  *  {http://server.gsoc.apache.org/}UserServiceImpl
>  *  {http://server.gsoc.apache.org/}CustomerServiceImpl
>  *
>  *    Search by type:
>  *    http://localhost:8080/services/jmx/type/Bus.Service.Endpoint
>  *
>  *    Search by port:
>  *    http://localhost:8080/services/jmx/port/UserServiceImpl
>  *    http://localhost:8080/services/jmx/port/CustomerServiceImpl
>  *    http://localhost:8080/services/jmx/port/SoapPort
>  *
>  *    Search by domain
>  *    http://localhost:8080/services/jmx/domain/org.apache.cxf
>  *
>  *    Function 4:
>  *    http://localhost:8080/services/jmx/list
>  *
>  * */
>
> Source is also attached.
> Thank you very much on the reviewing, I am very dedicated to what you have
> mentioned. Though there was a time in last 2 days, I reformatted the code a
> little too much:)
>
>
> Regards:
> Shenglin Qiu
>
>
>> Date: Wed, 8 Jun 2011 10:23:58 +0100
>> Subject: Re: Expose MBeans in CXF
>> From: sberyozkin@gmail.com
>> To: dabaipang@hotmail.com
>> CC: dev@cxf.apache.org
>>
>> Hi Shenglin
>>
>> I'm not sure if I'm confusing you with the comments I'm making...The
>> source has become cleaner, good progress there,
>> but I'm not sure what are you doing there at all now.
>> Why MBeanCollection has become a subresource ? What happened to our
>> /mbean/{id} handler ? Recall, you had a subresource locator method
>> dealing with '/mbean/{id}' and you were delegating to MBean to finish
>> the processing and the only thing I suggested is to have a dedicated
>> MBeanResource handler which I guess should wrap an individual MBean
>> and work with it (get its state for now, etc)
>>
>> What does
>>
>> http://localhost:8080/services/jmx/property/id/0
>>
>> mean ?
>>
>> it has to be
>>
>> http://localhost:8080/services/jmx/mbean/0
>> http://localhost:8080/services/jmx/mbean/1
>>
>> and MBeanResource needs to deal with these URIs.
>>
>> Please check my previous email.
>> have only
>> 1. list all MBeans in org.apache.cxf domain
>> /list
>> 2. find MBeans in org.apache.cxf domain which have a given attribute value
>> /{attribute}/{value}
>> 3. find MBeans in org.apache.cxf domain their object names
>> /objectname/{objectname}
>> 4. get the represenation of the individual MBean (and later update it,
>> register event listeners, etc)
>> /mbean/{id}
>>
>> // we haven't discussed it yet - need to be done
>> 5. Return the counter statistics
>>
>> /counters
>>
>> 6. Counters for a specific endpoint
>>
>> /counters/{servicename}
>>
>> Sergey
>>
>> On Wed, Jun 8, 2011 at 5:46 AM, Shenglin Qiu <da...@hotmail.com>
>> wrote:
>> > Hi Sergey:
>> >
>> > I attached the src and due to I am working on the mvn project only sync
>> > to
>> > svn, so I will take some time and sync this to github.
>> >
>> > And here is an update on the request:
>> >
>> > Self-defined demo inbound service:
>> > http://localhost:8080/services/greeter?wsdl
>> > http://localhost:8080/services/customerservice/customers
>> > http://localhost:8080/services/customerservice/customer/firstname/Lois
>> > http://localhost:8080/services/customerservice/customer/id/1
>> > http://localhost:8080/services/userservice/users
>> > http://localhost:8080/services/userservice/user/1
>> > /**
>> >  *  Specification:
>> >  *  Function 1:
>> >  *    Jmx Server:
>> >  *    sub-resource locator
>> >  *    http://localhost:8080/services/jmx/property/id/0
>> >  *    http://localhost:8080/services/jmx/property/id/1
>> >  *    ...
>> >  *
>> >  *
>> >  *    Function 2:
>> >  *    Note: search by bus.id, bus.id will be changed on every time
>> > server
>> > had been bounced.
>> >  *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>> >  *
>> >
>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
>> >  *    ...
>> >  *
>> >
>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
>> >  *
>> >
>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,port=%22SoapPort%22,type=Bus.Service.Endpoint,*
>> >  *
>> >
>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
>> >  *
>> >
>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,type=Bus.Service.Endpoint,*
>> >  *
>> >
>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,*
>> >  *
>> >  *    Function 3:
>> >  *    Search by service:
>> >  *
>> >
>> > http://localhost:8080/services/jmx/property/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
>> >  *
>> >
>> > http://localhost:8080/services/jmx/property/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DUserServiceImpl
>> >  *
>> >  *  Note, above queries are searching these 2, but replace by url
>> > encoding
>> > from:
>> >  *  {http://server.gsoc.apache.org/}UserServiceImpl
>> >  *  {http://server.gsoc.apache.org/}CustomerServiceImpl
>> >  *
>> >  *    Search by type:
>> >  *
>> > http://localhost:8080/services/jmx/property/type/Bus.Service.Endpoint
>> >  *
>> >  *    Search by port:
>> >  *    http://localhost:8080/services/jmx/property/port/UserServiceImpl
>> >  *
>> > http://localhost:8080/services/jmx/property/port/CustomerServiceImpl
>> >  *    http://localhost:8080/services/jmx/property/port/SoapPort
>> >  *
>> >  *    Function 4:
>> >  *    http://localhost:8080/services/jmx/list
>> >  *
>> >  * */
>> >
>> > I will ping you tomorrow morning.
>> >
>> > Thank you.
>> > Regards:
>> >
>> > Shenglin Qiu
>> >
>> >
>> >> Date: Wed, 1 Jun 2011 15:32:30 +0100
>> >> Subject: Re: Expose MBeans in CXF
>> >> From: sberyozkin@gmail.com
>> >> To: dev@cxf.apache.org
>> >>
>> >> Hi Shenglin
>> >>
>> >> It's a step in the right direction, thanks, but JMXServer still needs
>> >> to be cleaned up quite a bit.
>> >> - as I said earlier you have 4 big functions basically duplicating
>> >> each other. We can't have a method per every attribute a given MBean
>> >> may have. Have a single function only, max two (one capturing all the
>> >> attributes, another one - dedicated to objectname/{value}).
>> >> - Introduce MBeanResource subresource instead of overloading MBean, it
>> >> will be cleaner and easier to work with
>> >> - as suggested earlier, update the domain MBean and/or MBeanAttribute
>> >> such that you could drop a big chunk of code in JMXServer where
>> >> individual attribute values are set, currently in getMbeanMap (if
>> >> (attrName.equals("service") then/else)). That is because a number of
>> >> attributes is basically unlimited, even though we have some well-known
>> >> ones
>> >>
>> >> - getMBeanMap - this is so complex I can't understand what it does. I
>> >> do understand it returns a thread-safe Map - but I'm finding it
>> >> difficult to understand how the method achieves that. Please remove
>> >> all those synchronized blocks and have ConcurrentHashMap. Have atomic
>> >> integer counter, synchronized exlicitly (in a block) if you prefer,
>> >> and try to get a simple and effective function implemented. Don't make
>> >> the logic of that function dependent on a n
>> >> I don't understand why you use "list" for creating MBean hrefs;
>> >>
>> >> - there's no need for having Mbean.id and MBean.href because
>> >> MBean.href is identifying a given MBean uniquely and thus you could
>> >> use that calculated href as a key.
>> >>
>> >> Thanks, Sergey
>> >>
>> >>
>> >> On Tue, May 31, 2011 at 5:36 PM, Shenglin Qiu <da...@hotmail.com>
>> >> wrote:
>> >> >
>> >> > Hi Sergey:
>> >> >
>> >> > Project has been synced to Github:
>> >> >
>> >> > Browser:
>> >> > https://github.com/dabaipang/services
>> >> >
>> >> >
>> >> > Git address:
>> >> > https://dabaipang@github.com/dabaipang/services.git
>> >> > or
>> >> > git@github.com:dabaipang/services.git
>> >> >
>> >> >
>> >> > Thank you.
>> >> >
>> >> >
>> >> > Regards:
>> >> > Shenglin Qiu
>> >> >
>> >> >
>> >> >
>> >> >> From: dabaipang@hotmail.com
>> >> >> To: sberyozkin@gmail.com
>> >> >> CC: dev@cxf.apache.org
>> >> >> Subject: RE: Expose MBeans in CXF
>> >> >> Date: Tue, 31 May 2011 11:23:38 -0400
>> >> >>
>> >> >>
>> >> >> Hi Sergey:
>> >> >>
>> >> >> > > Function 1: (0 - 5 is continuous, no gap)
>> >> >> > > Jmx Server:
>> >> >> > > sub-resource locator
>> >> >> > > http://localhost:8080/services/jmx/mbean/0
>> >> >> > > http://localhost:8080/services/jmx/mbean/1
>> >> >> >
>> >> >> > The id allocation (0, 1, etc) has to be thread safe
>> >> >>
>> >> >> Done with:
>> >> >> private synchronized Map<String, MBean> getMBeansMap(){
>> >> >>  ....
>> >> >> }
>> >> >> My reason not using synchronized block but using synchronized method
>> >> >> is:
>> >> >> this guarantees the order on mbeansMap's initialization,  so when
>> >> >> it's
>> >> >> called by a lot of requests, the followings will have to wait, unit
>> >> >> the
>> >> >> first one finished,  after that, following requests will see
>> >> >> mbeansMap has
>> >> >> been initialized, and simply return mbeansMap without initializing
>> >> >> it again.
>> >> >>
>> >> >>
>> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>> >> >> > or
>> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
>> >> >> >
>> >> >> > should also work
>> >> >> >
>> >> >> > >
>> >> >>
>> >> >> http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>> >> >> is working.
>> >> >>
>> >> >> > > Due to the URL duplication with /mbean/{id}, I can't put
>> >> >> > > {searchtype}/{query}, so I put things like:
>> >> >> >
>> >> >> > Personally I'd  prefer to keep a URI as minimal as possible.
>> >> >> >
>> >> >> > /mbean/{id}
>> >> >> > and
>> >> >> > {searchtype}/{query}
>> >> >> >
>> >> >> > do not duplicate each other given that /mbean/{id} is more
>> >> >> > specific
>> >> >> > than {searchtype}/{query}.
>> >> >> > Likewise /objectname/{objectname} is more specific than
>> >> >> > {searchtype}/{query}, so consider dropping /search/ part,
>> >> >> > we may have a dedicated /search handler later on.
>> >> >>
>> >> >> Done by dedicating each request per method:
>> >> >>     @GET
>> >> >>     @POST
>> >> >>     @Path("/list")
>> >> >>     public MBeanCollection list()
>> >> >>
>> >> >>     @Path("/mbean/")
>> >> >>     public MBean locateMBean()
>> >> >>
>> >> >>
>> >> >>     @GET
>> >> >>     @POST
>> >> >>     @Path("/type/{query}")
>> >> >>     public MBeanCollection searchMBeansByType(@PathParam("query")
>> >> >> String query)
>> >> >>
>> >> >>
>> >> >>     @GET
>> >> >>     @POST
>> >> >>     @Path("/port/{query}")
>> >> >>     public MBeanCollection searchMBeansByPort(@PathParam("query")
>> >> >> String query)
>> >> >>
>> >> >>
>> >> >>     @GET
>> >> >>     @POST
>> >> >>     @Path("/service/{query}")
>> >> >>     public MBeanCollection searchMBeansByService(@PathParam("query")
>> >> >> String query)
>> >> >>
>> >> >>
>> >> >>     @GET
>> >> >>     @POST
>> >> >>     @Path("/objectname/{objectname}")
>> >> >>     public  MBeanCollection getComponent(@PathParam("objectname")
>> >> >> String objectname)
>> >> >>
>> >> >> I remembered you mentioned to handle Exceptions once, currently I am
>> >> >> still 'throws' -ing them out, I will make the try catch block.
>> >> >> Should I also add a new object which display the error or simply
>> >> >> return
>> >> >> empty?
>> >> >>
>> >> >>
>> >> >> Thank you very much.
>> >> >>
>> >> >>
>> >> >> Regards:
>> >> >> Shenglin Qiu
>> >> >>
>> >> >>
>> >> >> > Date: Tue, 31 May 2011 10:35:36 +0100
>> >> >> > Subject: Re: Expose MBeans in CXF
>> >> >> > From: sberyozkin@gmail.com
>> >> >> > To: dev@cxf.apache.org
>> >> >> >
>> >> >> > Hi Shenglin
>> >> >> >
>> >> >> > Good progress, some comments below
>> >> >> > >
>> >> >> > > Function 1: (0 - 5 is continuous, no gap)
>> >> >> > > Jmx Server:
>> >> >> > > sub-resource locator
>> >> >> > > http://localhost:8080/services/jmx/mbean/0
>> >> >> > > http://localhost:8080/services/jmx/mbean/1
>> >> >> >
>> >> >> > The id allocation (0, 1, etc) has to be thread safe
>> >> >> >
>> >> >> > >
>> >> >> > >
>> >> >> > > Function 2:
>> >> >> > > Note: search by bus.id, bus.id will be changed on every time
>> >> >> > > server
>> >> >> > > had been
>> >> >> > > bounced.
>> >> >> > >
>> >> >> > >
>> >> >> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
>> >> >> > > ...
>> >> >> > that is ok, a user does not have to specify them as you
>> >> >> > demonstrated
>> >> >> > with queries like
>> >> >> >
>> >> >> > >
>> >> >> > >
>> >> >> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
>> >> >> > I guess
>> >> >> >
>> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>> >> >> > or
>> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
>> >> >> >
>> >> >> > should also work
>> >> >> >
>> >> >> > >
>> >> >> > >
>> >> >> > > I am only now use 2 methods to fulfill:
>> >> >> > > 1 method for service/{serivce}, port/{port}, type/{type}
>> >> >> > > 1 method for objectname/{objectname}
>> >> >> >
>> >> >> > OK
>> >> >> >
>> >> >> > >
>> >> >> > > Due to the URL duplication with /mbean/{id}, I can't put
>> >> >> > > {searchtype}/{query}, so I put things like:
>> >> >> >
>> >> >> > Personally I'd  prefer to keep a URI as minimal as possible.
>> >> >> >
>> >> >> > /mbean/{id}
>> >> >> > and
>> >> >> > {searchtype}/{query}
>> >> >> >
>> >> >> > do not duplicate each other given that /mbean/{id} is more
>> >> >> > specific
>> >> >> > than {searchtype}/{query}.
>> >> >> > Likewise /objectname/{objectname} is more specific than
>> >> >> > {searchtype}/{query}, so consider dropping /search/ part,
>> >> >> > we may have a dedicated /search handler later on.
>> >> >> >
>> >> >> > The other thing I forgot to mention, please remove all those
>> >> >> > System.out.println, ping me please if you need some help with
>> >> >> > setting
>> >> >> > up a remote debugging session
>> >> >> >
>> >> >> > Thanks, Sergey
>> >> >> >
>> >> >> > >
>> >> >> > > Thank you so much!
>> >> >> > >
>> >> >> > > 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
>



-- 
Sergey Beryozkin

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

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi Sergey:

Sorry for replying a little bit late.
But I reverted the code as you mentioned /mbean/{id} must not be changed.

Code has be synced to github: 
https://github.com/dabaipang/services

/**
 *  Specification:
 *  Function 1:
 *    Jmx Server: 
 *    sub-resource locator
 *    http://localhost:8080/services/jmx/mbean/0
 *    http://localhost:8080/services/jmx/mbean/1
 *    ...
 *    
 *    
 *    Function 2:
 *    Note: search by bus.id, bus.id will be changed on every time server had been bounced.
 *  http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
 *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
 *    ...
 *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
 *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,port=%22SoapPort%22,type=Bus.Service.Endpoint,*
 *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
 *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,type=Bus.Service.Endpoint,*
 *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,*
 *    
 *    Function 3:
 *    Search by service:
 *    http://localhost:8080/services/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
 *    http://localhost:8080/services/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DUserServiceImpl
 *    
 *  Note, above queries are searching these 2, but replace by url encoding from:
 *  {http://server.gsoc.apache.org/}UserServiceImpl
 *  {http://server.gsoc.apache.org/}CustomerServiceImpl
 *  
 *    Search by type:
 *    http://localhost:8080/services/jmx/type/Bus.Service.Endpoint
 *    
 *    Search by port:
 *    http://localhost:8080/services/jmx/port/UserServiceImpl
 *    http://localhost:8080/services/jmx/port/CustomerServiceImpl
 *    http://localhost:8080/services/jmx/port/SoapPort
 *    
 *    Search by domain
 *    http://localhost:8080/services/jmx/domain/org.apache.cxf
 *
 *    Function 4:
 *    http://localhost:8080/services/jmx/list
 * 
 * */

Source is also attached.
Thank you very much on the reviewing, I am very dedicated to what you have mentioned. Though there was a time in last 2 days, I reformatted the code a little too much:)


Regards:
Shenglin Qiu


> Date: Wed, 8 Jun 2011 10:23:58 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dabaipang@hotmail.com
> CC: dev@cxf.apache.org
> 
> Hi Shenglin
> 
> I'm not sure if I'm confusing you with the comments I'm making...The
> source has become cleaner, good progress there,
> but I'm not sure what are you doing there at all now.
> Why MBeanCollection has become a subresource ? What happened to our
> /mbean/{id} handler ? Recall, you had  a subresource locator method
> dealing with '/mbean/{id}' and you were delegating to MBean to finish
> the processing and the only thing I suggested is to have a dedicated
> MBeanResource handler which I guess should wrap an individual MBean
> and work with it (get its state for now, etc)
> 
> What does
> 
> http://localhost:8080/services/jmx/property/id/0
> 
> mean ?
> 
> it has to be
> 
> http://localhost:8080/services/jmx/mbean/0
> http://localhost:8080/services/jmx/mbean/1
> 
> and MBeanResource needs to deal with these URIs.
> 
> Please check my previous email.
> have only
> 1. list all MBeans in org.apache.cxf domain
> /list
> 2. find  MBeans in org.apache.cxf domain which have a given attribute value
> /{attribute}/{value}
> 3. find  MBeans in org.apache.cxf domain their object names
> /objectname/{objectname}
> 4. get the represenation of the individual MBean (and later update it,
> register event listeners, etc)
> /mbean/{id}
> 
> // we haven't discussed it yet - need to be done
> 5. Return the counter statistics
> 
> /counters
> 
> 6. Counters for a specific endpoint
> 
> /counters/{servicename}
> 
> Sergey
> 
> On Wed, Jun 8, 2011 at 5:46 AM, Shenglin Qiu <da...@hotmail.com> wrote:
> > Hi Sergey:
> >
> > I attached the src and due to I am working on the mvn project only sync to
> > svn, so I will take some time and sync this to github.
> >
> > And here is an update on the request:
> >
> > Self-defined demo inbound service:
> > http://localhost:8080/services/greeter?wsdl
> > http://localhost:8080/services/customerservice/customers
> > http://localhost:8080/services/customerservice/customer/firstname/Lois
> > http://localhost:8080/services/customerservice/customer/id/1
> > http://localhost:8080/services/userservice/users
> > http://localhost:8080/services/userservice/user/1
> > /**
> >  *  Specification:
> >  *  Function 1:
> >  *    Jmx Server:
> >  *    sub-resource locator
> >  *    http://localhost:8080/services/jmx/property/id/0
> >  *    http://localhost:8080/services/jmx/property/id/1
> >  *    ...
> >  *
> >  *
> >  *    Function 2:
> >  *    Note: search by bus.id, bus.id will be changed on every time server
> > had been bounced.
> >  *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> >  *
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
> >  *    ...
> >  *
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
> >  *
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,port=%22SoapPort%22,type=Bus.Service.Endpoint,*
> >  *
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
> >  *
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,type=Bus.Service.Endpoint,*
> >  *
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,*
> >  *
> >  *    Function 3:
> >  *    Search by service:
> >  *
> > http://localhost:8080/services/jmx/property/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
> >  *
> > http://localhost:8080/services/jmx/property/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DUserServiceImpl
> >  *
> >  *  Note, above queries are searching these 2, but replace by url encoding
> > from:
> >  *  {http://server.gsoc.apache.org/}UserServiceImpl
> >  *  {http://server.gsoc.apache.org/}CustomerServiceImpl
> >  *
> >  *    Search by type:
> >  *    http://localhost:8080/services/jmx/property/type/Bus.Service.Endpoint
> >  *
> >  *    Search by port:
> >  *    http://localhost:8080/services/jmx/property/port/UserServiceImpl
> >  *    http://localhost:8080/services/jmx/property/port/CustomerServiceImpl
> >  *    http://localhost:8080/services/jmx/property/port/SoapPort
> >  *
> >  *    Function 4:
> >  *    http://localhost:8080/services/jmx/list
> >  *
> >  * */
> >
> > I will ping you tomorrow morning.
> >
> > Thank you.
> > Regards:
> >
> > Shenglin Qiu
> >
> >
> >> Date: Wed, 1 Jun 2011 15:32:30 +0100
> >> Subject: Re: Expose MBeans in CXF
> >> From: sberyozkin@gmail.com
> >> To: dev@cxf.apache.org
> >>
> >> Hi Shenglin
> >>
> >> It's a step in the right direction, thanks, but JMXServer still needs
> >> to be cleaned up quite a bit.
> >> - as I said earlier you have 4 big functions basically duplicating
> >> each other. We can't have a method per every attribute a given MBean
> >> may have. Have a single function only, max two (one capturing all the
> >> attributes, another one - dedicated to objectname/{value}).
> >> - Introduce MBeanResource subresource instead of overloading MBean, it
> >> will be cleaner and easier to work with
> >> - as suggested earlier, update the domain MBean and/or MBeanAttribute
> >> such that you could drop a big chunk of code in JMXServer where
> >> individual attribute values are set, currently in getMbeanMap (if
> >> (attrName.equals("service") then/else)). That is because a number of
> >> attributes is basically unlimited, even though we have some well-known
> >> ones
> >>
> >> - getMBeanMap - this is so complex I can't understand what it does. I
> >> do understand it returns a thread-safe Map - but I'm finding it
> >> difficult to understand how the method achieves that. Please remove
> >> all those synchronized blocks and have ConcurrentHashMap. Have atomic
> >> integer counter, synchronized exlicitly (in a block) if you prefer,
> >> and try to get a simple and effective function implemented. Don't make
> >> the logic of that function dependent on a n
> >> I don't understand why you use "list" for creating MBean hrefs;
> >>
> >> - there's no need for having Mbean.id and MBean.href because
> >> MBean.href is identifying a given MBean uniquely and thus you could
> >> use that calculated href as a key.
> >>
> >> Thanks, Sergey
> >>
> >>
> >> On Tue, May 31, 2011 at 5:36 PM, Shenglin Qiu <da...@hotmail.com>
> >> wrote:
> >> >
> >> > Hi Sergey:
> >> >
> >> > Project has been synced to Github:
> >> >
> >> > Browser:
> >> > https://github.com/dabaipang/services
> >> >
> >> >
> >> > Git address:
> >> > https://dabaipang@github.com/dabaipang/services.git
> >> > or
> >> > git@github.com:dabaipang/services.git
> >> >
> >> >
> >> > Thank you.
> >> >
> >> >
> >> > Regards:
> >> > Shenglin Qiu
> >> >
> >> >
> >> >
> >> >> From: dabaipang@hotmail.com
> >> >> To: sberyozkin@gmail.com
> >> >> CC: dev@cxf.apache.org
> >> >> Subject: RE: Expose MBeans in CXF
> >> >> Date: Tue, 31 May 2011 11:23:38 -0400
> >> >>
> >> >>
> >> >> Hi Sergey:
> >> >>
> >> >> > > Function 1: (0 - 5 is continuous, no gap)
> >> >> > > Jmx Server:
> >> >> > > sub-resource locator
> >> >> > > http://localhost:8080/services/jmx/mbean/0
> >> >> > > http://localhost:8080/services/jmx/mbean/1
> >> >> >
> >> >> > The id allocation (0, 1, etc) has to be thread safe
> >> >>
> >> >> Done with:
> >> >> private synchronized Map<String, MBean> getMBeansMap(){
> >> >>  ....
> >> >> }
> >> >> My reason not using synchronized block but using synchronized method
> >> >> is:
> >> >> this guarantees the order on mbeansMap's initialization,  so when it's
> >> >> called by a lot of requests, the followings will have to wait, unit the
> >> >> first one finished,  after that, following requests will see mbeansMap has
> >> >> been initialized, and simply return mbeansMap without initializing it again.
> >> >>
> >> >>
> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> >> >> > or
> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
> >> >> >
> >> >> > should also work
> >> >> >
> >> >> > >
> >> >>
> >> >> http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> >> >> is working.
> >> >>
> >> >> > > Due to the URL duplication with /mbean/{id}, I can't put
> >> >> > > {searchtype}/{query}, so I put things like:
> >> >> >
> >> >> > Personally I'd  prefer to keep a URI as minimal as possible.
> >> >> >
> >> >> > /mbean/{id}
> >> >> > and
> >> >> > {searchtype}/{query}
> >> >> >
> >> >> > do not duplicate each other given that /mbean/{id} is more specific
> >> >> > than {searchtype}/{query}.
> >> >> > Likewise /objectname/{objectname} is more specific than
> >> >> > {searchtype}/{query}, so consider dropping /search/ part,
> >> >> > we may have a dedicated /search handler later on.
> >> >>
> >> >> Done by dedicating each request per method:
> >> >>     @GET
> >> >>     @POST
> >> >>     @Path("/list")
> >> >>     public MBeanCollection list()
> >> >>
> >> >>     @Path("/mbean/")
> >> >>     public MBean locateMBean()
> >> >>
> >> >>
> >> >>     @GET
> >> >>     @POST
> >> >>     @Path("/type/{query}")
> >> >>     public MBeanCollection searchMBeansByType(@PathParam("query")
> >> >> String query)
> >> >>
> >> >>
> >> >>     @GET
> >> >>     @POST
> >> >>     @Path("/port/{query}")
> >> >>     public MBeanCollection searchMBeansByPort(@PathParam("query")
> >> >> String query)
> >> >>
> >> >>
> >> >>     @GET
> >> >>     @POST
> >> >>     @Path("/service/{query}")
> >> >>     public MBeanCollection searchMBeansByService(@PathParam("query")
> >> >> String query)
> >> >>
> >> >>
> >> >>     @GET
> >> >>     @POST
> >> >>     @Path("/objectname/{objectname}")
> >> >>     public  MBeanCollection getComponent(@PathParam("objectname")
> >> >> String objectname)
> >> >>
> >> >> I remembered you mentioned to handle Exceptions once, currently I am
> >> >> still 'throws' -ing them out, I will make the try catch block.
> >> >> Should I also add a new object which display the error or simply return
> >> >> empty?
> >> >>
> >> >>
> >> >> Thank you very much.
> >> >>
> >> >>
> >> >> Regards:
> >> >> Shenglin Qiu
> >> >>
> >> >>
> >> >> > Date: Tue, 31 May 2011 10:35:36 +0100
> >> >> > Subject: Re: Expose MBeans in CXF
> >> >> > From: sberyozkin@gmail.com
> >> >> > To: dev@cxf.apache.org
> >> >> >
> >> >> > Hi Shenglin
> >> >> >
> >> >> > Good progress, some comments below
> >> >> > >
> >> >> > > Function 1: (0 - 5 is continuous, no gap)
> >> >> > > Jmx Server:
> >> >> > > sub-resource locator
> >> >> > > http://localhost:8080/services/jmx/mbean/0
> >> >> > > http://localhost:8080/services/jmx/mbean/1
> >> >> >
> >> >> > The id allocation (0, 1, etc) has to be thread safe
> >> >> >
> >> >> > >
> >> >> > >
> >> >> > > Function 2:
> >> >> > > Note: search by bus.id, bus.id will be changed on every time server
> >> >> > > had been
> >> >> > > bounced.
> >> >> > >
> >> >> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
> >> >> > > ...
> >> >> > that is ok, a user does not have to specify them as you demonstrated
> >> >> > with queries like
> >> >> >
> >> >> > >
> >> >> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
> >> >> > I guess
> >> >> >
> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> >> >> > or
> >> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
> >> >> >
> >> >> > should also work
> >> >> >
> >> >> > >
> >> >> > >
> >> >> > > I am only now use 2 methods to fulfill:
> >> >> > > 1 method for service/{serivce}, port/{port}, type/{type}
> >> >> > > 1 method for objectname/{objectname}
> >> >> >
> >> >> > OK
> >> >> >
> >> >> > >
> >> >> > > Due to the URL duplication with /mbean/{id}, I can't put
> >> >> > > {searchtype}/{query}, so I put things like:
> >> >> >
> >> >> > Personally I'd  prefer to keep a URI as minimal as possible.
> >> >> >
> >> >> > /mbean/{id}
> >> >> > and
> >> >> > {searchtype}/{query}
> >> >> >
> >> >> > do not duplicate each other given that /mbean/{id} is more specific
> >> >> > than {searchtype}/{query}.
> >> >> > Likewise /objectname/{objectname} is more specific than
> >> >> > {searchtype}/{query}, so consider dropping /search/ part,
> >> >> > we may have a dedicated /search handler later on.
> >> >> >
> >> >> > The other thing I forgot to mention, please remove all those
> >> >> > System.out.println, ping me please if you need some help with setting
> >> >> > up a remote debugging session
> >> >> >
> >> >> > Thanks, Sergey
> >> >> >
> >> >> > >
> >> >> > > Thank you so much!
> >> >> > >
> >> >> > > 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
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Shenglin

I'm not sure if I'm confusing you with the comments I'm making...The
source has become cleaner, good progress there,
but I'm not sure what are you doing there at all now.
Why MBeanCollection has become a subresource ? What happened to our
/mbean/{id} handler ? Recall, you had  a subresource locator method
dealing with '/mbean/{id}' and you were delegating to MBean to finish
the processing and the only thing I suggested is to have a dedicated
MBeanResource handler which I guess should wrap an individual MBean
and work with it (get its state for now, etc)

What does

http://localhost:8080/services/jmx/property/id/0

mean ?

it has to be

http://localhost:8080/services/jmx/mbean/0
http://localhost:8080/services/jmx/mbean/1

and MBeanResource needs to deal with these URIs.

Please check my previous email.
have only
1. list all MBeans in org.apache.cxf domain
/list
2. find  MBeans in org.apache.cxf domain which have a given attribute value
/{attribute}/{value}
3. find  MBeans in org.apache.cxf domain their object names
/objectname/{objectname}
4. get the represenation of the individual MBean (and later update it,
register event listeners, etc)
/mbean/{id}

// we haven't discussed it yet - need to be done
5. Return the counter statistics

/counters

6. Counters for a specific endpoint

/counters/{servicename}

Sergey

On Wed, Jun 8, 2011 at 5:46 AM, Shenglin Qiu <da...@hotmail.com> wrote:
> Hi Sergey:
>
> I attached the src and due to I am working on the mvn project only sync to
> svn, so I will take some time and sync this to github.
>
> And here is an update on the request:
>
> Self-defined demo inbound service:
> http://localhost:8080/services/greeter?wsdl
> http://localhost:8080/services/customerservice/customers
> http://localhost:8080/services/customerservice/customer/firstname/Lois
> http://localhost:8080/services/customerservice/customer/id/1
> http://localhost:8080/services/userservice/users
> http://localhost:8080/services/userservice/user/1
> /**
>  *  Specification:
>  *  Function 1:
>  *    Jmx Server:
>  *    sub-resource locator
>  *    http://localhost:8080/services/jmx/property/id/0
>  *    http://localhost:8080/services/jmx/property/id/1
>  *    ...
>  *
>  *
>  *    Function 2:
>  *    Note: search by bus.id, bus.id will be changed on every time server
> had been bounced.
>  *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>  *
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
>  *    ...
>  *
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
>  *
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,port=%22SoapPort%22,type=Bus.Service.Endpoint,*
>  *
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
>  *
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,type=Bus.Service.Endpoint,*
>  *
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,*
>  *
>  *    Function 3:
>  *    Search by service:
>  *
> http://localhost:8080/services/jmx/property/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
>  *
> http://localhost:8080/services/jmx/property/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DUserServiceImpl
>  *
>  *  Note, above queries are searching these 2, but replace by url encoding
> from:
>  *  {http://server.gsoc.apache.org/}UserServiceImpl
>  *  {http://server.gsoc.apache.org/}CustomerServiceImpl
>  *
>  *    Search by type:
>  *    http://localhost:8080/services/jmx/property/type/Bus.Service.Endpoint
>  *
>  *    Search by port:
>  *    http://localhost:8080/services/jmx/property/port/UserServiceImpl
>  *    http://localhost:8080/services/jmx/property/port/CustomerServiceImpl
>  *    http://localhost:8080/services/jmx/property/port/SoapPort
>  *
>  *    Function 4:
>  *    http://localhost:8080/services/jmx/list
>  *
>  * */
>
> I will ping you tomorrow morning.
>
> Thank you.
> Regards:
>
> Shenglin Qiu
>
>
>> Date: Wed, 1 Jun 2011 15:32:30 +0100
>> Subject: Re: Expose MBeans in CXF
>> From: sberyozkin@gmail.com
>> To: dev@cxf.apache.org
>>
>> Hi Shenglin
>>
>> It's a step in the right direction, thanks, but JMXServer still needs
>> to be cleaned up quite a bit.
>> - as I said earlier you have 4 big functions basically duplicating
>> each other. We can't have a method per every attribute a given MBean
>> may have. Have a single function only, max two (one capturing all the
>> attributes, another one - dedicated to objectname/{value}).
>> - Introduce MBeanResource subresource instead of overloading MBean, it
>> will be cleaner and easier to work with
>> - as suggested earlier, update the domain MBean and/or MBeanAttribute
>> such that you could drop a big chunk of code in JMXServer where
>> individual attribute values are set, currently in getMbeanMap (if
>> (attrName.equals("service") then/else)). That is because a number of
>> attributes is basically unlimited, even though we have some well-known
>> ones
>>
>> - getMBeanMap - this is so complex I can't understand what it does. I
>> do understand it returns a thread-safe Map - but I'm finding it
>> difficult to understand how the method achieves that. Please remove
>> all those synchronized blocks and have ConcurrentHashMap. Have atomic
>> integer counter, synchronized exlicitly (in a block) if you prefer,
>> and try to get a simple and effective function implemented. Don't make
>> the logic of that function dependent on a n
>> I don't understand why you use "list" for creating MBean hrefs;
>>
>> - there's no need for having Mbean.id and MBean.href because
>> MBean.href is identifying a given MBean uniquely and thus you could
>> use that calculated href as a key.
>>
>> Thanks, Sergey
>>
>>
>> On Tue, May 31, 2011 at 5:36 PM, Shenglin Qiu <da...@hotmail.com>
>> wrote:
>> >
>> > Hi Sergey:
>> >
>> > Project has been synced to Github:
>> >
>> > Browser:
>> > https://github.com/dabaipang/services
>> >
>> >
>> > Git address:
>> > https://dabaipang@github.com/dabaipang/services.git
>> > or
>> > git@github.com:dabaipang/services.git
>> >
>> >
>> > Thank you.
>> >
>> >
>> > Regards:
>> > Shenglin Qiu
>> >
>> >
>> >
>> >> From: dabaipang@hotmail.com
>> >> To: sberyozkin@gmail.com
>> >> CC: dev@cxf.apache.org
>> >> Subject: RE: Expose MBeans in CXF
>> >> Date: Tue, 31 May 2011 11:23:38 -0400
>> >>
>> >>
>> >> Hi Sergey:
>> >>
>> >> > > Function 1: (0 - 5 is continuous, no gap)
>> >> > > Jmx Server:
>> >> > > sub-resource locator
>> >> > > http://localhost:8080/services/jmx/mbean/0
>> >> > > http://localhost:8080/services/jmx/mbean/1
>> >> >
>> >> > The id allocation (0, 1, etc) has to be thread safe
>> >>
>> >> Done with:
>> >> private synchronized Map<String, MBean> getMBeansMap(){
>> >>  ....
>> >> }
>> >> My reason not using synchronized block but using synchronized method
>> >> is:
>> >> this guarantees the order on mbeansMap's initialization,  so when it's
>> >> called by a lot of requests, the followings will have to wait, unit the
>> >> first one finished,  after that, following requests will see mbeansMap has
>> >> been initialized, and simply return mbeansMap without initializing it again.
>> >>
>> >>
>> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>> >> > or
>> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
>> >> >
>> >> > should also work
>> >> >
>> >> > >
>> >>
>> >> http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>> >> is working.
>> >>
>> >> > > Due to the URL duplication with /mbean/{id}, I can't put
>> >> > > {searchtype}/{query}, so I put things like:
>> >> >
>> >> > Personally I'd  prefer to keep a URI as minimal as possible.
>> >> >
>> >> > /mbean/{id}
>> >> > and
>> >> > {searchtype}/{query}
>> >> >
>> >> > do not duplicate each other given that /mbean/{id} is more specific
>> >> > than {searchtype}/{query}.
>> >> > Likewise /objectname/{objectname} is more specific than
>> >> > {searchtype}/{query}, so consider dropping /search/ part,
>> >> > we may have a dedicated /search handler later on.
>> >>
>> >> Done by dedicating each request per method:
>> >>     @GET
>> >>     @POST
>> >>     @Path("/list")
>> >>     public MBeanCollection list()
>> >>
>> >>     @Path("/mbean/")
>> >>     public MBean locateMBean()
>> >>
>> >>
>> >>     @GET
>> >>     @POST
>> >>     @Path("/type/{query}")
>> >>     public MBeanCollection searchMBeansByType(@PathParam("query")
>> >> String query)
>> >>
>> >>
>> >>     @GET
>> >>     @POST
>> >>     @Path("/port/{query}")
>> >>     public MBeanCollection searchMBeansByPort(@PathParam("query")
>> >> String query)
>> >>
>> >>
>> >>     @GET
>> >>     @POST
>> >>     @Path("/service/{query}")
>> >>     public MBeanCollection searchMBeansByService(@PathParam("query")
>> >> String query)
>> >>
>> >>
>> >>     @GET
>> >>     @POST
>> >>     @Path("/objectname/{objectname}")
>> >>     public  MBeanCollection getComponent(@PathParam("objectname")
>> >> String objectname)
>> >>
>> >> I remembered you mentioned to handle Exceptions once, currently I am
>> >> still 'throws' -ing them out, I will make the try catch block.
>> >> Should I also add a new object which display the error or simply return
>> >> empty?
>> >>
>> >>
>> >> Thank you very much.
>> >>
>> >>
>> >> Regards:
>> >> Shenglin Qiu
>> >>
>> >>
>> >> > Date: Tue, 31 May 2011 10:35:36 +0100
>> >> > Subject: Re: Expose MBeans in CXF
>> >> > From: sberyozkin@gmail.com
>> >> > To: dev@cxf.apache.org
>> >> >
>> >> > Hi Shenglin
>> >> >
>> >> > Good progress, some comments below
>> >> > >
>> >> > > Function 1: (0 - 5 is continuous, no gap)
>> >> > > Jmx Server:
>> >> > > sub-resource locator
>> >> > > http://localhost:8080/services/jmx/mbean/0
>> >> > > http://localhost:8080/services/jmx/mbean/1
>> >> >
>> >> > The id allocation (0, 1, etc) has to be thread safe
>> >> >
>> >> > >
>> >> > >
>> >> > > Function 2:
>> >> > > Note: search by bus.id, bus.id will be changed on every time server
>> >> > > had been
>> >> > > bounced.
>> >> > >
>> >> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
>> >> > > ...
>> >> > that is ok, a user does not have to specify them as you demonstrated
>> >> > with queries like
>> >> >
>> >> > >
>> >> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
>> >> > I guess
>> >> >
>> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>> >> > or
>> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
>> >> >
>> >> > should also work
>> >> >
>> >> > >
>> >> > >
>> >> > > I am only now use 2 methods to fulfill:
>> >> > > 1 method for service/{serivce}, port/{port}, type/{type}
>> >> > > 1 method for objectname/{objectname}
>> >> >
>> >> > OK
>> >> >
>> >> > >
>> >> > > Due to the URL duplication with /mbean/{id}, I can't put
>> >> > > {searchtype}/{query}, so I put things like:
>> >> >
>> >> > Personally I'd  prefer to keep a URI as minimal as possible.
>> >> >
>> >> > /mbean/{id}
>> >> > and
>> >> > {searchtype}/{query}
>> >> >
>> >> > do not duplicate each other given that /mbean/{id} is more specific
>> >> > than {searchtype}/{query}.
>> >> > Likewise /objectname/{objectname} is more specific than
>> >> > {searchtype}/{query}, so consider dropping /search/ part,
>> >> > we may have a dedicated /search handler later on.
>> >> >
>> >> > The other thing I forgot to mention, please remove all those
>> >> > System.out.println, ping me please if you need some help with setting
>> >> > up a remote debugging session
>> >> >
>> >> > Thanks, Sergey
>> >> >
>> >> > >
>> >> > > Thank you so much!
>> >> > >
>> >> > > 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

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi Sergey:

I attached the src and due to I am working on the mvn project only sync to svn, so I will take some time and sync this to github.

And here is an update on the request:

Self-defined demo inbound service:
http://localhost:8080/services/greeter?wsdl
http://localhost:8080/services/customerservice/customers
http://localhost:8080/services/customerservice/customer/firstname/Lois
http://localhost:8080/services/customerservice/customer/id/1
http://localhost:8080/services/userservice/users
http://localhost:8080/services/userservice/user/1
/**
 *  Specification:
 *  Function 1:
 *    Jmx Server: 
 *    sub-resource locator
 *    http://localhost:8080/services/jmx/property/id/0
 *    http://localhost:8080/services/jmx/property/id/1
 *    ...
 *    
 *    
 *    Function 2:
 *    Note: search by bus.id, bus.id will be changed on every time server had been bounced.
 *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
 *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
 *    ...
 *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
 *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,port=%22SoapPort%22,type=Bus.Service.Endpoint,*
 *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
 *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,type=Bus.Service.Endpoint,*
 *    http://localhost:8080/services/jmx/objectname/org.apache.cxf:service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,*
 *    
 *    Function 3:
 *    Search by service:
 *    http://localhost:8080/services/jmx/property/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
 *    http://localhost:8080/services/jmx/property/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DUserServiceImpl
 *    
 *  Note, above queries are searching these 2, but replace by url encoding from:
 *  {http://server.gsoc.apache.org/}UserServiceImpl
 *  {http://server.gsoc.apache.org/}CustomerServiceImpl
 *  
 *    Search by type:
 *    http://localhost:8080/services/jmx/property/type/Bus.Service.Endpoint
 *    
 *    Search by port:
 *    http://localhost:8080/services/jmx/property/port/UserServiceImpl
 *    http://localhost:8080/services/jmx/property/port/CustomerServiceImpl
 *    http://localhost:8080/services/jmx/property/port/SoapPort
 *    
 *    Function 4:
 *    http://localhost:8080/services/jmx/list
 * 
 * */

I will ping you tomorrow morning.

Thank you.
Regards:

Shenglin Qiu


> Date: Wed, 1 Jun 2011 15:32:30 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dev@cxf.apache.org
> 
> Hi Shenglin
> 
> It's a step in the right direction, thanks, but JMXServer still needs
> to be cleaned up quite a bit.
> - as I said earlier you have 4 big functions basically duplicating
> each other. We can't have a method per every attribute a given MBean
> may have. Have a single function only, max two (one capturing all the
> attributes, another one - dedicated to objectname/{value}).
> - Introduce MBeanResource subresource instead of overloading MBean, it
> will be cleaner and easier to work with
> - as suggested earlier, update the domain MBean and/or MBeanAttribute
> such that you could drop a big chunk of code in JMXServer where
> individual attribute values are set, currently in getMbeanMap (if
> (attrName.equals("service") then/else)). That is because a number of
> attributes is basically unlimited, even though we have some well-known
> ones
> 
> - getMBeanMap - this is so complex I can't understand what it does. I
> do understand it returns a thread-safe Map - but I'm finding it
> difficult to understand how the method achieves that.  Please remove
> all those synchronized blocks and have ConcurrentHashMap. Have atomic
> integer counter, synchronized exlicitly (in a block) if you prefer,
> and try to get a simple and effective function implemented. Don't make
> the logic of that function dependent on a n
> I don't understand why you use "list" for creating MBean hrefs;
> 
> - there's no need for having Mbean.id and MBean.href because
> MBean.href is identifying a given MBean uniquely and thus you could
> use that calculated href as a key.
> 
> Thanks, Sergey
> 
> 
> On Tue, May 31, 2011 at 5:36 PM, Shenglin Qiu <da...@hotmail.com> wrote:
> >
> > Hi Sergey:
> >
> > Project has been synced to Github:
> >
> > Browser:
> > https://github.com/dabaipang/services
> >
> >
> > Git address:
> > https://dabaipang@github.com/dabaipang/services.git
> > or
> > git@github.com:dabaipang/services.git
> >
> >
> > Thank you.
> >
> >
> > Regards:
> > Shenglin Qiu
> >
> >
> >
> >> From: dabaipang@hotmail.com
> >> To: sberyozkin@gmail.com
> >> CC: dev@cxf.apache.org
> >> Subject: RE: Expose MBeans in CXF
> >> Date: Tue, 31 May 2011 11:23:38 -0400
> >>
> >>
> >> Hi Sergey:
> >>
> >> > > Function 1: (0 - 5 is continuous, no gap)
> >> > > Jmx Server:
> >> > > sub-resource locator
> >> > > http://localhost:8080/services/jmx/mbean/0
> >> > > http://localhost:8080/services/jmx/mbean/1
> >> >
> >> > The id allocation (0, 1, etc) has to be thread safe
> >>
> >> Done with:
> >> private synchronized Map<String, MBean> getMBeansMap(){
> >>  ....
> >> }
> >> My reason not using synchronized block but using synchronized method is:
> >> this guarantees the order on mbeansMap's initialization,  so when it's called by a lot of requests, the followings will have to wait, unit the first one finished,  after that, following requests will see mbeansMap has been initialized, and simply return mbeansMap without initializing it again.
> >>
> >>
> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> >> > or
> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
> >> >
> >> > should also work
> >> >
> >> > >
> >>
> >> http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> >> is working.
> >>
> >> > > Due to the URL duplication with /mbean/{id}, I can't put
> >> > > {searchtype}/{query}, so I put things like:
> >> >
> >> > Personally I'd  prefer to keep a URI as minimal as possible.
> >> >
> >> > /mbean/{id}
> >> > and
> >> > {searchtype}/{query}
> >> >
> >> > do not duplicate each other given that /mbean/{id} is more specific
> >> > than {searchtype}/{query}.
> >> > Likewise /objectname/{objectname} is more specific than
> >> > {searchtype}/{query}, so consider dropping /search/ part,
> >> > we may have a dedicated /search handler later on.
> >>
> >> Done by dedicating each request per method:
> >>     @GET
> >>     @POST
> >>     @Path("/list")
> >>     public MBeanCollection list()
> >>
> >>     @Path("/mbean/")
> >>     public MBean locateMBean()
> >>
> >>
> >>     @GET
> >>     @POST
> >>     @Path("/type/{query}")
> >>     public MBeanCollection searchMBeansByType(@PathParam("query") String query)
> >>
> >>
> >>     @GET
> >>     @POST
> >>     @Path("/port/{query}")
> >>     public MBeanCollection searchMBeansByPort(@PathParam("query") String query)
> >>
> >>
> >>     @GET
> >>     @POST
> >>     @Path("/service/{query}")
> >>     public MBeanCollection searchMBeansByService(@PathParam("query") String query)
> >>
> >>
> >>     @GET
> >>     @POST
> >>     @Path("/objectname/{objectname}")
> >>     public  MBeanCollection getComponent(@PathParam("objectname") String objectname)
> >>
> >> I remembered you mentioned to handle Exceptions once, currently I am still 'throws' -ing them out, I will make the try catch block.
> >> Should I also add a new object which display the error or simply return empty?
> >>
> >>
> >> Thank you very much.
> >>
> >>
> >> Regards:
> >> Shenglin Qiu
> >>
> >>
> >> > Date: Tue, 31 May 2011 10:35:36 +0100
> >> > Subject: Re: Expose MBeans in CXF
> >> > From: sberyozkin@gmail.com
> >> > To: dev@cxf.apache.org
> >> >
> >> > Hi Shenglin
> >> >
> >> > Good progress, some comments below
> >> > >
> >> > > Function 1: (0 - 5 is continuous, no gap)
> >> > > Jmx Server:
> >> > > sub-resource locator
> >> > > http://localhost:8080/services/jmx/mbean/0
> >> > > http://localhost:8080/services/jmx/mbean/1
> >> >
> >> > The id allocation (0, 1, etc) has to be thread safe
> >> >
> >> > >
> >> > >
> >> > > Function 2:
> >> > > Note: search by bus.id, bus.id will be changed on every time server had been
> >> > > bounced.
> >> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
> >> > > ...
> >> > that is ok, a user does not have to specify them as you demonstrated
> >> > with queries like
> >> >
> >> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
> >> > I guess
> >> >
> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> >> > or
> >> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
> >> >
> >> > should also work
> >> >
> >> > >
> >> > >
> >> > > I am only now use 2 methods to fulfill:
> >> > > 1 method for service/{serivce}, port/{port}, type/{type}
> >> > > 1 method for objectname/{objectname}
> >> >
> >> > OK
> >> >
> >> > >
> >> > > Due to the URL duplication with /mbean/{id}, I can't put
> >> > > {searchtype}/{query}, so I put things like:
> >> >
> >> > Personally I'd  prefer to keep a URI as minimal as possible.
> >> >
> >> > /mbean/{id}
> >> > and
> >> > {searchtype}/{query}
> >> >
> >> > do not duplicate each other given that /mbean/{id} is more specific
> >> > than {searchtype}/{query}.
> >> > Likewise /objectname/{objectname} is more specific than
> >> > {searchtype}/{query}, so consider dropping /search/ part,
> >> > we may have a dedicated /search handler later on.
> >> >
> >> > The other thing I forgot to mention, please remove all those
> >> > System.out.println, ping me please if you need some help with setting
> >> > up a remote debugging session
> >> >
> >> > Thanks, Sergey
> >> >
> >> > >
> >> > > Thank you so much!
> >> > >
> >> > > Regards:
> >> > > Shenglin Qiu
> >> > >
> >>
> >
> 
> 
> 
> -- 
> Sergey Beryozkin
> 
> Application Integration Division of Talend
> http://sberyozkin.blogspot.com
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Shenglin

It's a step in the right direction, thanks, but JMXServer still needs
to be cleaned up quite a bit.
- as I said earlier you have 4 big functions basically duplicating
each other. We can't have a method per every attribute a given MBean
may have. Have a single function only, max two (one capturing all the
attributes, another one - dedicated to objectname/{value}).
- Introduce MBeanResource subresource instead of overloading MBean, it
will be cleaner and easier to work with
- as suggested earlier, update the domain MBean and/or MBeanAttribute
such that you could drop a big chunk of code in JMXServer where
individual attribute values are set, currently in getMbeanMap (if
(attrName.equals("service") then/else)). That is because a number of
attributes is basically unlimited, even though we have some well-known
ones

- getMBeanMap - this is so complex I can't understand what it does. I
do understand it returns a thread-safe Map - but I'm finding it
difficult to understand how the method achieves that.  Please remove
all those synchronized blocks and have ConcurrentHashMap. Have atomic
integer counter, synchronized exlicitly (in a block) if you prefer,
and try to get a simple and effective function implemented. Don't make
the logic of that function dependent on a n
I don't understand why you use "list" for creating MBean hrefs;

- there's no need for having Mbean.id and MBean.href because
MBean.href is identifying a given MBean uniquely and thus you could
use that calculated href as a key.

Thanks, Sergey


On Tue, May 31, 2011 at 5:36 PM, Shenglin Qiu <da...@hotmail.com> wrote:
>
> Hi Sergey:
>
> Project has been synced to Github:
>
> Browser:
> https://github.com/dabaipang/services
>
>
> Git address:
> https://dabaipang@github.com/dabaipang/services.git
> or
> git@github.com:dabaipang/services.git
>
>
> Thank you.
>
>
> Regards:
> Shenglin Qiu
>
>
>
>> From: dabaipang@hotmail.com
>> To: sberyozkin@gmail.com
>> CC: dev@cxf.apache.org
>> Subject: RE: Expose MBeans in CXF
>> Date: Tue, 31 May 2011 11:23:38 -0400
>>
>>
>> Hi Sergey:
>>
>> > > Function 1: (0 - 5 is continuous, no gap)
>> > > Jmx Server:
>> > > sub-resource locator
>> > > http://localhost:8080/services/jmx/mbean/0
>> > > http://localhost:8080/services/jmx/mbean/1
>> >
>> > The id allocation (0, 1, etc) has to be thread safe
>>
>> Done with:
>> private synchronized Map<String, MBean> getMBeansMap(){
>>  ....
>> }
>> My reason not using synchronized block but using synchronized method is:
>> this guarantees the order on mbeansMap's initialization,  so when it's called by a lot of requests, the followings will have to wait, unit the first one finished,  after that, following requests will see mbeansMap has been initialized, and simply return mbeansMap without initializing it again.
>>
>>
>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>> > or
>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
>> >
>> > should also work
>> >
>> > >
>>
>> http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>> is working.
>>
>> > > Due to the URL duplication with /mbean/{id}, I can't put
>> > > {searchtype}/{query}, so I put things like:
>> >
>> > Personally I'd  prefer to keep a URI as minimal as possible.
>> >
>> > /mbean/{id}
>> > and
>> > {searchtype}/{query}
>> >
>> > do not duplicate each other given that /mbean/{id} is more specific
>> > than {searchtype}/{query}.
>> > Likewise /objectname/{objectname} is more specific than
>> > {searchtype}/{query}, so consider dropping /search/ part,
>> > we may have a dedicated /search handler later on.
>>
>> Done by dedicating each request per method:
>>     @GET
>>     @POST
>>     @Path("/list")
>>     public MBeanCollection list()
>>
>>     @Path("/mbean/")
>>     public MBean locateMBean()
>>
>>
>>     @GET
>>     @POST
>>     @Path("/type/{query}")
>>     public MBeanCollection searchMBeansByType(@PathParam("query") String query)
>>
>>
>>     @GET
>>     @POST
>>     @Path("/port/{query}")
>>     public MBeanCollection searchMBeansByPort(@PathParam("query") String query)
>>
>>
>>     @GET
>>     @POST
>>     @Path("/service/{query}")
>>     public MBeanCollection searchMBeansByService(@PathParam("query") String query)
>>
>>
>>     @GET
>>     @POST
>>     @Path("/objectname/{objectname}")
>>     public  MBeanCollection getComponent(@PathParam("objectname") String objectname)
>>
>> I remembered you mentioned to handle Exceptions once, currently I am still 'throws' -ing them out, I will make the try catch block.
>> Should I also add a new object which display the error or simply return empty?
>>
>>
>> Thank you very much.
>>
>>
>> Regards:
>> Shenglin Qiu
>>
>>
>> > Date: Tue, 31 May 2011 10:35:36 +0100
>> > Subject: Re: Expose MBeans in CXF
>> > From: sberyozkin@gmail.com
>> > To: dev@cxf.apache.org
>> >
>> > Hi Shenglin
>> >
>> > Good progress, some comments below
>> > >
>> > > Function 1: (0 - 5 is continuous, no gap)
>> > > Jmx Server:
>> > > sub-resource locator
>> > > http://localhost:8080/services/jmx/mbean/0
>> > > http://localhost:8080/services/jmx/mbean/1
>> >
>> > The id allocation (0, 1, etc) has to be thread safe
>> >
>> > >
>> > >
>> > > Function 2:
>> > > Note: search by bus.id, bus.id will be changed on every time server had been
>> > > bounced.
>> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
>> > > ...
>> > that is ok, a user does not have to specify them as you demonstrated
>> > with queries like
>> >
>> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
>> > I guess
>> >
>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
>> > or
>> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
>> >
>> > should also work
>> >
>> > >
>> > >
>> > > I am only now use 2 methods to fulfill:
>> > > 1 method for service/{serivce}, port/{port}, type/{type}
>> > > 1 method for objectname/{objectname}
>> >
>> > OK
>> >
>> > >
>> > > Due to the URL duplication with /mbean/{id}, I can't put
>> > > {searchtype}/{query}, so I put things like:
>> >
>> > Personally I'd  prefer to keep a URI as minimal as possible.
>> >
>> > /mbean/{id}
>> > and
>> > {searchtype}/{query}
>> >
>> > do not duplicate each other given that /mbean/{id} is more specific
>> > than {searchtype}/{query}.
>> > Likewise /objectname/{objectname} is more specific than
>> > {searchtype}/{query}, so consider dropping /search/ part,
>> > we may have a dedicated /search handler later on.
>> >
>> > The other thing I forgot to mention, please remove all those
>> > System.out.println, ping me please if you need some help with setting
>> > up a remote debugging session
>> >
>> > Thanks, Sergey
>> >
>> > >
>> > > Thank you so much!
>> > >
>> > > Regards:
>> > > Shenglin Qiu
>> > >
>>
>



-- 
Sergey Beryozkin

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

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi Sergey:

Project has been synced to Github:

Browser:
https://github.com/dabaipang/services


Git address:
https://dabaipang@github.com/dabaipang/services.git
or
git@github.com:dabaipang/services.git


Thank you.


Regards:
Shenglin Qiu



> From: dabaipang@hotmail.com
> To: sberyozkin@gmail.com
> CC: dev@cxf.apache.org
> Subject: RE: Expose MBeans in CXF
> Date: Tue, 31 May 2011 11:23:38 -0400
> 
> 
> Hi Sergey:
> 
> > > Function 1: (0 - 5 is continuous, no gap)
> > > Jmx Server:
> > > sub-resource locator
> > > http://localhost:8080/services/jmx/mbean/0
> > > http://localhost:8080/services/jmx/mbean/1
> > 
> > The id allocation (0, 1, etc) has to be thread safe
> 
> Done with:
> private synchronized Map<String, MBean> getMBeansMap(){
>  ....
> }
> My reason not using synchronized block but using synchronized method is:
> this guarantees the order on mbeansMap's initialization,  so when it's called by a lot of requests, the followings will have to wait, unit the first one finished,  after that, following requests will see mbeansMap has been initialized, and simply return mbeansMap without initializing it again.
> 
> 
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> > or
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
> > 
> > should also work
> > 
> > >
> 
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> is working.
> 
> > > Due to the URL duplication with /mbean/{id}, I can't put
> > > {searchtype}/{query}, so I put things like:
> > 
> > Personally I'd  prefer to keep a URI as minimal as possible.
> > 
> > /mbean/{id}
> > and
> > {searchtype}/{query}
> > 
> > do not duplicate each other given that /mbean/{id} is more specific
> > than {searchtype}/{query}.
> > Likewise /objectname/{objectname} is more specific than
> > {searchtype}/{query}, so consider dropping /search/ part,
> > we may have a dedicated /search handler later on.
> 
> Done by dedicating each request per method:
>     @GET
>     @POST
>     @Path("/list")
>     public MBeanCollection list()
> 
>     @Path("/mbean/")
>     public MBean locateMBean()
> 
> 
>     @GET
>     @POST
>     @Path("/type/{query}")
>     public MBeanCollection searchMBeansByType(@PathParam("query") String query)
> 
> 
>     @GET
>     @POST
>     @Path("/port/{query}")
>     public MBeanCollection searchMBeansByPort(@PathParam("query") String query)
> 
> 
>     @GET
>     @POST
>     @Path("/service/{query}")
>     public MBeanCollection searchMBeansByService(@PathParam("query") String query)
> 
> 
>     @GET
>     @POST
>     @Path("/objectname/{objectname}")
>     public  MBeanCollection getComponent(@PathParam("objectname") String objectname)
> 
> I remembered you mentioned to handle Exceptions once, currently I am still 'throws' -ing them out, I will make the try catch block.
> Should I also add a new object which display the error or simply return empty?
> 
> 
> Thank you very much.
> 
> 
> Regards:
> Shenglin Qiu
> 
> 
> > Date: Tue, 31 May 2011 10:35:36 +0100
> > Subject: Re: Expose MBeans in CXF
> > From: sberyozkin@gmail.com
> > To: dev@cxf.apache.org
> > 
> > Hi Shenglin
> > 
> > Good progress, some comments below
> > >
> > > Function 1: (0 - 5 is continuous, no gap)
> > > Jmx Server:
> > > sub-resource locator
> > > http://localhost:8080/services/jmx/mbean/0
> > > http://localhost:8080/services/jmx/mbean/1
> > 
> > The id allocation (0, 1, etc) has to be thread safe
> > 
> > >
> > >
> > > Function 2:
> > > Note: search by bus.id, bus.id will be changed on every time server had been
> > > bounced.
> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
> > > ...
> > that is ok, a user does not have to specify them as you demonstrated
> > with queries like
> > 
> > > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
> > I guess
> > 
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> > or
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf
> > 
> > should also work
> > 
> > >
> > >
> > > I am only now use 2 methods to fulfill:
> > > 1 method for service/{serivce}, port/{port}, type/{type}
> > > 1 method for objectname/{objectname}
> > 
> > OK
> > 
> > >
> > > Due to the URL duplication with /mbean/{id}, I can't put
> > > {searchtype}/{query}, so I put things like:
> > 
> > Personally I'd  prefer to keep a URI as minimal as possible.
> > 
> > /mbean/{id}
> > and
> > {searchtype}/{query}
> > 
> > do not duplicate each other given that /mbean/{id} is more specific
> > than {searchtype}/{query}.
> > Likewise /objectname/{objectname} is more specific than
> > {searchtype}/{query}, so consider dropping /search/ part,
> > we may have a dedicated /search handler later on.
> > 
> > The other thing I forgot to mention, please remove all those
> > System.out.println, ping me please if you need some help with setting
> > up a remote debugging session
> > 
> > Thanks, Sergey
> > 
> > >
> > > Thank you so much!
> > >
> > > Regards:
> > > Shenglin Qiu
> > >
>  		 	   		  
 		 	   		  

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi Sergey:

> > Function 1: (0 - 5 is continuous, no gap)
> > Jmx Server:
> > sub-resource locator
> > http://localhost:8080/services/jmx/mbean/0
> > http://localhost:8080/services/jmx/mbean/1
> 
> The id allocation (0, 1, etc) has to be thread safe

Done with:
private synchronized Map<String, MBean> getMBeansMap(){
 ....
}
My reason not using synchronized block but using synchronized method is:
this guarantees the order on mbeansMap's initialization,  so when it's called by a lot of requests, the followings will have to wait, unit the first one finished,  after that, following requests will see mbeansMap has been initialized, and simply return mbeansMap without initializing it again.


> http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> or
> http://localhost:8080/services/jmx/objectname/org.apache.cxf
> 
> should also work
> 
> >

http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
is working.

> > Due to the URL duplication with /mbean/{id}, I can't put
> > {searchtype}/{query}, so I put things like:
> 
> Personally I'd  prefer to keep a URI as minimal as possible.
> 
> /mbean/{id}
> and
> {searchtype}/{query}
> 
> do not duplicate each other given that /mbean/{id} is more specific
> than {searchtype}/{query}.
> Likewise /objectname/{objectname} is more specific than
> {searchtype}/{query}, so consider dropping /search/ part,
> we may have a dedicated /search handler later on.

Done by dedicating each request per method:
    @GET
    @POST
    @Path("/list")
    public MBeanCollection list()

    @Path("/mbean/")
    public MBean locateMBean()


    @GET
    @POST
    @Path("/type/{query}")
    public MBeanCollection searchMBeansByType(@PathParam("query") String query)


    @GET
    @POST
    @Path("/port/{query}")
    public MBeanCollection searchMBeansByPort(@PathParam("query") String query)


    @GET
    @POST
    @Path("/service/{query}")
    public MBeanCollection searchMBeansByService(@PathParam("query") String query)


    @GET
    @POST
    @Path("/objectname/{objectname}")
    public  MBeanCollection getComponent(@PathParam("objectname") String objectname)

I remembered you mentioned to handle Exceptions once, currently I am still 'throws' -ing them out, I will make the try catch block.
Should I also add a new object which display the error or simply return empty?


Thank you very much.


Regards:
Shenglin Qiu


> Date: Tue, 31 May 2011 10:35:36 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dev@cxf.apache.org
> 
> Hi Shenglin
> 
> Good progress, some comments below
> >
> > Function 1: (0 - 5 is continuous, no gap)
> > Jmx Server:
> > sub-resource locator
> > http://localhost:8080/services/jmx/mbean/0
> > http://localhost:8080/services/jmx/mbean/1
> 
> The id allocation (0, 1, etc) has to be thread safe
> 
> >
> >
> > Function 2:
> > Note: search by bus.id, bus.id will be changed on every time server had been
> > bounced.
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
> > ...
> that is ok, a user does not have to specify them as you demonstrated
> with queries like
> 
> > http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
> I guess
> 
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
> or
> http://localhost:8080/services/jmx/objectname/org.apache.cxf
> 
> should also work
> 
> >
> >
> > I am only now use 2 methods to fulfill:
> > 1 method for service/{serivce}, port/{port}, type/{type}
> > 1 method for objectname/{objectname}
> 
> OK
> 
> >
> > Due to the URL duplication with /mbean/{id}, I can't put
> > {searchtype}/{query}, so I put things like:
> 
> Personally I'd  prefer to keep a URI as minimal as possible.
> 
> /mbean/{id}
> and
> {searchtype}/{query}
> 
> do not duplicate each other given that /mbean/{id} is more specific
> than {searchtype}/{query}.
> Likewise /objectname/{objectname} is more specific than
> {searchtype}/{query}, so consider dropping /search/ part,
> we may have a dedicated /search handler later on.
> 
> The other thing I forgot to mention, please remove all those
> System.out.println, ping me please if you need some help with setting
> up a remote debugging session
> 
> Thanks, Sergey
> 
> >
> > Thank you so much!
> >
> > Regards:
> > Shenglin Qiu
> >
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Shenglin

Good progress, some comments below
>
> Function 1: (0 - 5 is continuous, no gap)
> Jmx Server:
> sub-resource locator
> http://localhost:8080/services/jmx/mbean/0
> http://localhost:8080/services/jmx/mbean/1

The id allocation (0, 1, etc) has to be thread safe

>
>
> Function 2:
> Note: search by bus.id, bus.id will be changed on every time server had been
> bounced.
> http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
> ...
that is ok, a user does not have to specify them as you demonstrated
with queries like

> http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
I guess

http://localhost:8080/services/jmx/objectname/org.apache.cxf:*
or
http://localhost:8080/services/jmx/objectname/org.apache.cxf

should also work

>
>
> I am only now use 2 methods to fulfill:
> 1 method for service/{serivce}, port/{port}, type/{type}
> 1 method for objectname/{objectname}

OK

>
> Due to the URL duplication with /mbean/{id}, I can't put
> {searchtype}/{query}, so I put things like:

Personally I'd  prefer to keep a URI as minimal as possible.

/mbean/{id}
and
{searchtype}/{query}

do not duplicate each other given that /mbean/{id} is more specific
than {searchtype}/{query}.
Likewise /objectname/{objectname} is more specific than
{searchtype}/{query}, so consider dropping /search/ part,
we may have a dedicated /search handler later on.

The other thing I forgot to mention, please remove all those
System.out.println, ping me please if you need some help with setting
up a remote debugging session

Thanks, Sergey

>
> Thank you so much!
>
> Regards:
> Shenglin Qiu
>

Re: Expose MBeans in CXF

Posted by Willem Jiang <wi...@gmail.com>.
Hi Shenglin,

Did you have a chance to use the SCM the manger your source code?
I don't think it is a good practice to send the source code directly to 
the mailing list.

You can use the github[1] to hold a fork a version of CXF[2] , and 
attach the patch to the JIRA[3] which we can trace.
It worked perfectly for the GSoc project which I mentored.

On 5/31/11 10:55 AM, Shenglin Qiu wrote:
> Source is also attached. I will ping you in the morning.


[1]https://github.com/
[2]https://github.com/apache/cxf
[3]https://issues.apache.org/jira/browse/CXF

-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi, Sergey:

Thank you so much for the comments which actually makes me much more aware of what I am doing,

I put current function specification and my progress according to your comment below:

Self-defined demo inbound service:
http://localhost:8080/services/greeter?wsdl
http://localhost:8080/services/customerservice/customers
http://localhost:8080/services/customerservice/customer/firstname/Lois
http://localhost:8080/services/customerservice/customer/id/1
http://localhost:8080/services/userservice/users
http://localhost:8080/services/userservice/user/1

Function 1: (0 - 5 is continuous, no gap)
Jmx Server: 
sub-resource locator
http://localhost:8080/services/jmx/mbean/0
http://localhost:8080/services/jmx/mbean/1
...
http://localhost:8080/services/jmx/mbean/5


Function 2:
Note: search by bus.id, bus.id will be changed on every time server had been bounced.
http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,*
...
http://localhost:8080/services/jmx/objectname/org.apache.cxf:port=%22CustomerServiceImpl%22,*
http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,port=%22SoapPort%22,type=Bus.Service.Endpoint,*
http://localhost:8080/services/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,type=Bus.Service.Endpoint,*
http://localhost:8080/services/jmx/objectname/org.apache.cxf:service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,*

Function 3:
Search by service:
http://localhost:8080/services/jmx/search/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
http://localhost:8080/services/jmx/search/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DUserServiceImpl

Search by type:
http://localhost:8080/services/jmx/search/type/Bus.Service.Endpoint

Search by port:
http://localhost:8080/services/jmx/search/port/UserServiceImpl
http://localhost:8080/services/jmx/search/port/CustomerServiceImpl
http://localhost:8080/services/jmx/search/port/SoapPort


Function 4:
http://localhost:8080/services/jmx/list

> So here are the comments:
> - You need to make sure list() function, when called multiple times,
> returns the same result. What will happen, with the way you wrote it,
> is that individual MBeans will have different hrefs every time list()
> is called. That means the ID allocator also has to be a JAX-RS server
> field. Make sure the ID allocator and Map are thread-safe.
> 
Done.

> - resource methods handling service/{service}, port/{port},
> type/{type} and objectname/{objectname} are just duplicating each
> other - can you please review what we were discussion about having a
> single resource method which deals with queries where individual
> attributes such as 'service' or 'port' are provided ?  We can have
> many attributes so we can' allocate a new resource method per every
> possible attribute a given MBean may have.
> 
Done.

I am only now use 2 methods to fulfill:
1 method for service/{serivce}, port/{port}, type/{type}
1 method for objectname/{objectname}

Due to the URL duplication with /mbean/{id}, I can't put {searchtype}/{query}, so I put things like:
Search by service:
http://localhost:8080/services/jmx/search/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
http://localhost:8080/services/jmx/search/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DUserServiceImpl

Search by type:
http://localhost:8080/services/jmx/search/type/Bus.Service.Endpoint

Search by port:
http://localhost:8080/services/jmx/search/port/UserServiceImpl
http://localhost:8080/services/jmx/search/port/CustomerServiceImpl
http://localhost:8080/services/jmx/search/port/SoapPort

Search by objectname:
http://localhost:8080/services/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
http://localhost:8080/services/jmx/objectname/org.apache.cxf:bus.id=cxf28619341,service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,type=Bus.Service.Endpoint,*
http://localhost:8080/services/jmx/objectname/org.apache.cxf:service=%22%7Bhttp%3A%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl%22,

Note, this bus.id value will be changed every time server's bounced.

> - list() and resource methods handling service/{service}/etc return
> different MBean representations, service/{service}/etc methods should
> also return MBeans with *href* attributes. Basically all JMXServer
> resource methods returning MBeans should return MBeans with hrefs, and
> those hrefs should be the same for a particular MBean across multiple
> calls. The order of calls (ex, list() is called first or
> service/{service}) must not make any difference as far as creating and
> locating correct MBean href values is concerned. Just make sure that
> all of those methods delegate to some common function which checks if
> an 'id' has already been allocated for a given MBean and if yes then
> use the existing href.
> 
Done.


> - /mbean handler is correct, as far as using subresource locator is
> concerned, very good. Note it should only use list() if no mbean with
> a given id has already been saved in the map before. Another thing is
> that CxfMBean which is also a JAXB bean is better not to be a
> subresource. It will be cleaner for our purposes to have a dedicated
> subresource handler, MBeanResource for ex, because we will need to
> deal with property updates and handling notification updates, etc.
> CxfMBean will just grow too large and it may also affect  its JAXB
> serialization/etc
> 
> - Remove Cxf prefixes from all you domain classes, and instead of
> adding individual CxfMBeanAttribute setters such as setService, etc,
> add some Pair class which holds name and value and then add a
> List<Pair> to CxfMBeanAttribute, this is to make sure new attributes
> can be handled easily
Done.

Source is also attached. I will ping you in the morning.

Thank you so much!

Regards:
Shenglin Qiu




> Date: Fri, 27 May 2011 10:36:45 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dabaipang@hotmail.com
> CC: dev@cxf.apache.org
> 
> Hi Shenglin
> 
> Sorry for a few days delay in commenting about your test project which
> you posted to me,
> I just looked at the code, here are the comments.
> First of all, it's a good progress, I think you are on the way to
> completing the 1st phase of the project, we should aim at the end of
> the next week. The code needs some cleanup and a bit of refactoring,
> but overall it's not too bad at all.
> 
> So here are the comments:
> - You need to make sure list() function, when called multiple times,
> returns the same result. What will happen, with the way you wrote it,
> is that individual MBeans will have different hrefs every time list()
> is called. That means the ID allocator also has to be a JAX-RS server
> field. Make sure the ID allocator and Map are thread-safe.
> 
> - resource methods handling service/{service}, port/{port},
> type/{type} and objectname/{objectname} are just duplicating each
> other - can you please review what we were discussion about having a
> single resource method which deals with queries where individual
> attributes such as 'service' or 'port' are provided ?  We can have
> many attributes so we can' allocate a new resource method per every
> possible attribute a given MBean may have.
> 
> - list() and resource methods handling service/{service}/etc return
> different MBean representations, service/{service}/etc methods should
> also return MBeans with *href* attributes. Basically all JMXServer
> resource methods returning MBeans should return MBeans with hrefs, and
> those hrefs should be the same for a particular MBean across multiple
> calls. The order of calls (ex, list() is called first or
> service/{service}) must not make any difference as far as creating and
> locating correct MBean href values is concerned. Just make sure that
> all of those methods delegate to some common function which checks if
> an 'id' has already been allocated for a given MBean and if yes then
> use the existing href.
> 
> - /mbean handler is correct, as far as using subresource locator is
> concerned, very good. Note it should only use list() if no mbean with
> a given id has already been saved in the map before. Another thing is
> that CxfMBean which is also a JAXB bean is better not to be a
> subresource. It will be cleaner for our purposes to have a dedicated
> subresource handler, MBeanResource for ex, because we will need to
> deal with property updates and handling notification updates, etc.
> CxfMBean will just grow too large and it may also affect  its JAXB
> serialization/etc
> 
> - Remove Cxf prefixes from all you domain classes, and instead of
> adding individual CxfMBeanAttribute setters such as setService, etc,
> add some Pair class which holds name and value and then add a
> List<Pair> to CxfMBeanAttribute, this is to make sure new attributes
> can be handled easily
> 
> Please focus on the above, once you are done we'll discuss again how
> to avoid registering lists of JAXWS and JAX-RS endpoints with JAX-RS
> server, as well as what we can do about dealing with the CXF Mbean
> dealing with statistics, and how to handle notifications to do with
> changes of individual CXF MBeans.
> 
> Thanks, Sergey
> 
> On Sat, May 21, 2011 at 7:39 PM, Shenglin Qiu <da...@hotmail.com> wrote:
> > Hi Sergey:
> >
> > I am able to use sub-resource locator and @UriInfo and implement:
> > class JMXServer:
> >
> >     @Path("/mbean/")
> >     public CxfMBean locateMBean() throws MalformedObjectNameException,
> > NullPointerException{
> >         UriBuilder uriBuilder =
> > uriInfo.getBaseUriBuilder().path(this.getClass(), "list");
> >         System.out.println("uriInfo.getPath() = "+uriInfo.getPath());
> >         String key = uriInfo.getPath().substring("mbean/".length());
> >         System.out.println(key);
> >         CxfMBeanCollection cxfMBeans = list();
> >         CxfMBean cxfMBean = cxfMBeans.getCxfMBean(key);
> >         return cxfMBean;
> >     }
> >
> > class CxfMBeanCollection:
> >
> >     public CxfMBean getCxfMBean(String key){
> >         for(CxfMBean cxfMBean : cxfMBeans){
> >             if(cxfMBean.getId() != null && cxfMBean.getId().equals(key)){
> >                 return cxfMBean;
> >             }
> >         }
> >         return null;
> >     }
> >
> > class CxfMBean:
> >
> >     @GET
> >     @Path("{key}")
> >     public CxfMBean getCxfMBean(@PathParam("key") String key){
> >         if(id != null && id.equals(key)){
> >             return this;
> >         }else{
> >             return null;
> >         }
> >     }
> >
> >
> > Request:
> > http://localhost:8080/services/jmx/mbean/5
> > Response:
> > <MBean href="http://localhost:8080/services/jmx/mbean/5">
> >       <attribute>
> >             <busId>cxf32436715</busId>
> >             <port>"UserServiceImpl"</port>
> >             <service>"{http://server.gsoc.apache.org/}UserServiceImpl"</service>
> >             <type>Bus.Service.Endpoint</type>
> >       </attribute>
> >       <canonicalName>org.apache.cxf:bus.id=cxf32436715,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> >       <domain>org.apache.cxf</domain>
> >       <id>5</id>
> > </MBean>
> >
> > And so on for other mbean with id 1, 3, 4, 5, 6 and response with the same
> > format
> > <MBean href="http://localhost:8080/services/jmx/mbean/3">
> >       <attribute>
> >             <busId>cxf32436715</busId>
> >             <type>Bus</type>
> >       </attribute>
> >       <canonicalName>org.apache.cxf:bus.id=cxf32436715,type=Bus</canonicalName>
> >       <domain>org.apache.cxf</domain>
> >       <id>3</id>
> > </MBean>
> >
> >
> > Request:
> > http://localhost:8080/services/jmx/list
> > Response:
> > <MBeans>
> >       <MBean href="http://localhost:8080/services/jmx/mbean/5">
> >             <attribute>
> >                   <busId>cxf32436715</busId>
> >                   <port>"UserServiceImpl"</port>
> >                   <service>"{http://server.gsoc.apache.org/}UserServiceImpl"</service>
> >                   <type>Bus.Service.Endpoint</type>
> >             </attribute>
> >             <canonicalName>org.apache.cxf:bus.id=cxf32436715,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> >             <domain>org.apache.cxf</domain>
> >             <id>5</id>
> >       </MBean>
> >       <MBean href="http://localhost:8080/services/jmx/mbean/4">
> >             <attribute>
> >                   <busId>cxf32436715</busId>
> >                   <port>"SoapPort"</port>
> >                   <service>"{http://org.apache.gsoc.server/Greeter_Soap}SOAPService"</service>
> >                   <type>Bus.Service.Endpoint</type>
> >             </attribute>
> >             <canonicalName>org.apache.cxf:bus.id=cxf32436715,port="SoapPort",service="{http://org.apache.gsoc.server/Greeter_Soap}SOAPService",type=Bus.Service.Endpoint</canonicalName>
> >             <domain>org.apache.cxf</domain>
> >             <id>4</id>
> >       </MBean>
> >       <MBean href="http://localhost:8080/services/jmx/mbean/3">
> >             <attribute>
> >                   <busId>cxf32436715</busId>
> >                   <type>Bus</type>
> >             </attribute>
> >             <canonicalName>org.apache.cxf:bus.id=cxf32436715,type=Bus</canonicalName>
> >             <domain>org.apache.cxf</domain>
> >             <id>3</id>
> >       </MBean>
> >       <MBean href="http://localhost:8080/services/jmx/mbean/1">
> >             <attribute>
> >                   <busId>cxf32436715</busId>
> >                   <port>"CustomerServiceImpl"</port>
> >                   <service>"{http://server.gsoc.apache.org/}CustomerServiceImpl"</service>
> >                   <type>Bus.Service.Endpoint</type>
> >             </attribute>
> >             <canonicalName>org.apache.cxf:bus.id=cxf32436715,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> >             <domain>org.apache.cxf</domain>
> >             <id>1</id>
> >       </MBean>
> >       <MBean href="http://localhost:8080/services/jmx/mbean/6">
> >             <attribute>
> >                   <type>MBeanServerDelegate</type>
> >             </attribute>
> >             <canonicalName>JMImplementation:type=MBeanServerDelegate</canonicalName>
> >             <domain>JMImplementation</domain>
> >             <id>6</id>
> >       </MBean>
> > </MBeans>
> >
> >
> > I will clean up my code a little for the next step.
> >
> > Thank you.
> >
> > Regards:
> > Shenglin Qiu
> >
> >
> >> Date: Sat, 21 May 2011 16:37:29 +0100
> >> Subject: Re: Expose MBeans in CXF
> >> From: sberyozkin@gmail.com
> >> To: dev@cxf.apache.org
> >>
> >> >> Are you saying that you have to use UriInfo and UriBuilder for
> >> >> creating hrefs whenever you need to
> >> >> build an MBean representation ?
> >> >>
> >> >
> >> > After everytime server bounces, I need to at first use this url request:
> >> >  http://localhost:8080/services/jmx/, the good thing is, this request only
> >> > need once,
> >> >
> >>
> >> What do you mean it is needed only once ?
> >>
> >> > Then my JMXServer will save the UriInfo and also all the href values in
> >> > MBean are fixed, no further change until another server's bounce.
> >> >
> >>
> >> I don't understand - as I said on IRC JMXServer should expect
> >> endpoints created dynamically
> >>
> >> Cheers, Sergey
> >>
> >> >> Please have UriInfo injected in one of the JMXServer's fields, remove
> >> >> NPE declaration
> >> >>
> >> > Done.
> >> >
> >> >
> >> > I will do a fewer more rounds of testing, and put up the source code
> >> > again.
> >> >
> >> >
> >> >
> >> > Thank you.
> >> >
> >> >
> >> > Regards:
> >> > Shenglin Qiu
> >> >
> >> >
> >> >
> >> >> Date: Fri, 20 May 2011 11:39:55 +0100
> >> >> Subject: Re: Expose MBeans in CXF
> >> >> From: sberyozkin@gmail.com
> >> >> To: dabaipang@hotmail.com
> >> >> CC: dev@cxf.apache.org
> >> >>
> >> >> 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: sberyozkin@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
> >> >> >> <da...@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: sberyozkin@gmail.com
> >> >> >> >> To: dev@cxf.apache.org
> >> >> >> >>
> >> >> >> >> HI Shenglin
> >> >> >> >>
> >> >> >> >> On Thu, May 19, 2011 at 2:54 PM, Shenglin Qiu
> >> >> >> >> <da...@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
> >> >
> >>
> >>
> >>
> >> --
> >> Sergey Beryozkin
> >>
> >> Application Integration Division of Talend
> >> http://sberyozkin.blogspot.com
> >
> 
> 
> 
> -- 
> Sergey Beryozkin
> 
> Application Integration Division of Talend
> http://sberyozkin.blogspot.com
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Shenglin

Sorry for a few days delay in commenting about your test project which
you posted to me,
I just looked at the code, here are the comments.
First of all, it's a good progress, I think you are on the way to
completing the 1st phase of the project, we should aim at the end of
the next week. The code needs some cleanup and a bit of refactoring,
but overall it's not too bad at all.

So here are the comments:
- You need to make sure list() function, when called multiple times,
returns the same result. What will happen, with the way you wrote it,
is that individual MBeans will have different hrefs every time list()
is called. That means the ID allocator also has to be a JAX-RS server
field. Make sure the ID allocator and Map are thread-safe.

- resource methods handling service/{service}, port/{port},
type/{type} and objectname/{objectname} are just duplicating each
other - can you please review what we were discussion about having a
single resource method which deals with queries where individual
attributes such as 'service' or 'port' are provided ?  We can have
many attributes so we can' allocate a new resource method per every
possible attribute a given MBean may have.

- list() and resource methods handling service/{service}/etc return
different MBean representations, service/{service}/etc methods should
also return MBeans with *href* attributes. Basically all JMXServer
resource methods returning MBeans should return MBeans with hrefs, and
those hrefs should be the same for a particular MBean across multiple
calls. The order of calls (ex, list() is called first or
service/{service}) must not make any difference as far as creating and
locating correct MBean href values is concerned. Just make sure that
all of those methods delegate to some common function which checks if
an 'id' has already been allocated for a given MBean and if yes then
use the existing href.

- /mbean handler is correct, as far as using subresource locator is
concerned, very good. Note it should only use list() if no mbean with
a given id has already been saved in the map before. Another thing is
that CxfMBean which is also a JAXB bean is better not to be a
subresource. It will be cleaner for our purposes to have a dedicated
subresource handler, MBeanResource for ex, because we will need to
deal with property updates and handling notification updates, etc.
CxfMBean will just grow too large and it may also affect  its JAXB
serialization/etc

- Remove Cxf prefixes from all you domain classes, and instead of
adding individual CxfMBeanAttribute setters such as setService, etc,
add some Pair class which holds name and value and then add a
List<Pair> to CxfMBeanAttribute, this is to make sure new attributes
can be handled easily

Please focus on the above, once you are done we'll discuss again how
to avoid registering lists of JAXWS and JAX-RS endpoints with JAX-RS
server, as well as what we can do about dealing with the CXF Mbean
dealing with statistics, and how to handle notifications to do with
changes of individual CXF MBeans.

Thanks, Sergey

On Sat, May 21, 2011 at 7:39 PM, Shenglin Qiu <da...@hotmail.com> wrote:
> Hi Sergey:
>
> I am able to use sub-resource locator and @UriInfo and implement:
> class JMXServer:
>
>     @Path("/mbean/")
>     public CxfMBean locateMBean() throws MalformedObjectNameException,
> NullPointerException{
>         UriBuilder uriBuilder =
> uriInfo.getBaseUriBuilder().path(this.getClass(), "list");
>         System.out.println("uriInfo.getPath() = "+uriInfo.getPath());
>         String key = uriInfo.getPath().substring("mbean/".length());
>         System.out.println(key);
>         CxfMBeanCollection cxfMBeans = list();
>         CxfMBean cxfMBean = cxfMBeans.getCxfMBean(key);
>         return cxfMBean;
>     }
>
> class CxfMBeanCollection:
>
>     public CxfMBean getCxfMBean(String key){
>         for(CxfMBean cxfMBean : cxfMBeans){
>             if(cxfMBean.getId() != null && cxfMBean.getId().equals(key)){
>                 return cxfMBean;
>             }
>         }
>         return null;
>     }
>
> class CxfMBean:
>
>     @GET
>     @Path("{key}")
>     public CxfMBean getCxfMBean(@PathParam("key") String key){
>         if(id != null && id.equals(key)){
>             return this;
>         }else{
>             return null;
>         }
>     }
>
>
> Request:
> http://localhost:8080/services/jmx/mbean/5
> Response:
> <MBean href="http://localhost:8080/services/jmx/mbean/5">
>       <attribute>
>             <busId>cxf32436715</busId>
>             <port>"UserServiceImpl"</port>
>             <service>"{http://server.gsoc.apache.org/}UserServiceImpl"</service>
>             <type>Bus.Service.Endpoint</type>
>       </attribute>
>       <canonicalName>org.apache.cxf:bus.id=cxf32436715,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
>       <domain>org.apache.cxf</domain>
>       <id>5</id>
> </MBean>
>
> And so on for other mbean with id 1, 3, 4, 5, 6 and response with the same
> format
> <MBean href="http://localhost:8080/services/jmx/mbean/3">
>       <attribute>
>             <busId>cxf32436715</busId>
>             <type>Bus</type>
>       </attribute>
>       <canonicalName>org.apache.cxf:bus.id=cxf32436715,type=Bus</canonicalName>
>       <domain>org.apache.cxf</domain>
>       <id>3</id>
> </MBean>
>
>
> Request:
> http://localhost:8080/services/jmx/list
> Response:
> <MBeans>
>       <MBean href="http://localhost:8080/services/jmx/mbean/5">
>             <attribute>
>                   <busId>cxf32436715</busId>
>                   <port>"UserServiceImpl"</port>
>                   <service>"{http://server.gsoc.apache.org/}UserServiceImpl"</service>
>                   <type>Bus.Service.Endpoint</type>
>             </attribute>
>             <canonicalName>org.apache.cxf:bus.id=cxf32436715,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
>             <domain>org.apache.cxf</domain>
>             <id>5</id>
>       </MBean>
>       <MBean href="http://localhost:8080/services/jmx/mbean/4">
>             <attribute>
>                   <busId>cxf32436715</busId>
>                   <port>"SoapPort"</port>
>                   <service>"{http://org.apache.gsoc.server/Greeter_Soap}SOAPService"</service>
>                   <type>Bus.Service.Endpoint</type>
>             </attribute>
>             <canonicalName>org.apache.cxf:bus.id=cxf32436715,port="SoapPort",service="{http://org.apache.gsoc.server/Greeter_Soap}SOAPService",type=Bus.Service.Endpoint</canonicalName>
>             <domain>org.apache.cxf</domain>
>             <id>4</id>
>       </MBean>
>       <MBean href="http://localhost:8080/services/jmx/mbean/3">
>             <attribute>
>                   <busId>cxf32436715</busId>
>                   <type>Bus</type>
>             </attribute>
>             <canonicalName>org.apache.cxf:bus.id=cxf32436715,type=Bus</canonicalName>
>             <domain>org.apache.cxf</domain>
>             <id>3</id>
>       </MBean>
>       <MBean href="http://localhost:8080/services/jmx/mbean/1">
>             <attribute>
>                   <busId>cxf32436715</busId>
>                   <port>"CustomerServiceImpl"</port>
>                   <service>"{http://server.gsoc.apache.org/}CustomerServiceImpl"</service>
>                   <type>Bus.Service.Endpoint</type>
>             </attribute>
>             <canonicalName>org.apache.cxf:bus.id=cxf32436715,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
>             <domain>org.apache.cxf</domain>
>             <id>1</id>
>       </MBean>
>       <MBean href="http://localhost:8080/services/jmx/mbean/6">
>             <attribute>
>                   <type>MBeanServerDelegate</type>
>             </attribute>
>             <canonicalName>JMImplementation:type=MBeanServerDelegate</canonicalName>
>             <domain>JMImplementation</domain>
>             <id>6</id>
>       </MBean>
> </MBeans>
>
>
> I will clean up my code a little for the next step.
>
> Thank you.
>
> Regards:
> Shenglin Qiu
>
>
>> Date: Sat, 21 May 2011 16:37:29 +0100
>> Subject: Re: Expose MBeans in CXF
>> From: sberyozkin@gmail.com
>> To: dev@cxf.apache.org
>>
>> >> Are you saying that you have to use UriInfo and UriBuilder for
>> >> creating hrefs whenever you need to
>> >> build an MBean representation ?
>> >>
>> >
>> > After everytime server bounces, I need to at first use this url request:
>> >  http://localhost:8080/services/jmx/, the good thing is, this request only
>> > need once,
>> >
>>
>> What do you mean it is needed only once ?
>>
>> > Then my JMXServer will save the UriInfo and also all the href values in
>> > MBean are fixed, no further change until another server's bounce.
>> >
>>
>> I don't understand - as I said on IRC JMXServer should expect
>> endpoints created dynamically
>>
>> Cheers, Sergey
>>
>> >> Please have UriInfo injected in one of the JMXServer's fields, remove
>> >> NPE declaration
>> >>
>> > Done.
>> >
>> >
>> > I will do a fewer more rounds of testing, and put up the source code
>> > again.
>> >
>> >
>> >
>> > Thank you.
>> >
>> >
>> > Regards:
>> > Shenglin Qiu
>> >
>> >
>> >
>> >> Date: Fri, 20 May 2011 11:39:55 +0100
>> >> Subject: Re: Expose MBeans in CXF
>> >> From: sberyozkin@gmail.com
>> >> To: dabaipang@hotmail.com
>> >> CC: dev@cxf.apache.org
>> >>
>> >> 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: sberyozkin@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
>> >> >> <da...@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: sberyozkin@gmail.com
>> >> >> >> To: dev@cxf.apache.org
>> >> >> >>
>> >> >> >> HI Shenglin
>> >> >> >>
>> >> >> >> On Thu, May 19, 2011 at 2:54 PM, Shenglin Qiu
>> >> >> >> <da...@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
>> >
>>
>>
>>
>> --
>> Sergey Beryozkin
>>
>> Application Integration Division of Talend
>> http://sberyozkin.blogspot.com
>



-- 
Sergey Beryozkin

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

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi Sergey:

I am able to use sub-resource locator and @UriInfo and implement:
class JMXServer:

    @Path("/mbean/")
    public CxfMBean locateMBean() throws MalformedObjectNameException, NullPointerException{
        UriBuilder uriBuilder = uriInfo.getBaseUriBuilder().path(this.getClass(), "list");
        System.out.println("uriInfo.getPath() = "+uriInfo.getPath());
        String key = uriInfo.getPath().substring("mbean/".length());
        System.out.println(key);
        CxfMBeanCollection cxfMBeans = list();
        CxfMBean cxfMBean = cxfMBeans.getCxfMBean(key);
        return cxfMBean;
    }

class CxfMBeanCollection:

    public CxfMBean getCxfMBean(String key){
        for(CxfMBean cxfMBean : cxfMBeans){
            if(cxfMBean.getId() != null && cxfMBean.getId().equals(key)){
                return cxfMBean;
            }
        }
        return null;
    }

class CxfMBean:

    @GET
    @Path("{key}")
    public CxfMBean getCxfMBean(@PathParam("key") String key){
        if(id != null && id.equals(key)){
            return this;
        }else{
            return null;
        }
    }


Request:
http://localhost:8080/services/jmx/mbean/5
Response:
<MBean href="http://localhost:8080/services/jmx/mbean/5">

      <attribute>

            <busId>cxf32436715</busId>

            <port>"UserServiceImpl"</port>

            <service>"{http://server.gsoc.apache.org/}UserServiceImpl"</service>

            <type>Bus.Service.Endpoint</type>

      </attribute>

      <canonicalName>org.apache.cxf:bus.id=cxf32436715,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>

      <domain>org.apache.cxf</domain>

      <id>5</id>

</MBean>

And so on for other mbean with id 1, 3, 4, 5, 6 and response with the same format
<MBean href="http://localhost:8080/services/jmx/mbean/3">

      <attribute>

            <busId>cxf32436715</busId>

            <type>Bus</type>

      </attribute>

      <canonicalName>org.apache.cxf:bus.id=cxf32436715,type=Bus</canonicalName>

      <domain>org.apache.cxf</domain>

      <id>3</id>

</MBean>


Request:
http://localhost:8080/services/jmx/list
Response:
<MBeans>

      <MBean href="http://localhost:8080/services/jmx/mbean/5">

            <attribute>

                  <busId>cxf32436715</busId>

                  <port>"UserServiceImpl"</port>

                  <service>"{http://server.gsoc.apache.org/}UserServiceImpl"</service>

                  <type>Bus.Service.Endpoint</type>

            </attribute>

            <canonicalName>org.apache.cxf:bus.id=cxf32436715,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>

            <domain>org.apache.cxf</domain>

            <id>5</id>

      </MBean>

      <MBean href="http://localhost:8080/services/jmx/mbean/4">

            <attribute>

                  <busId>cxf32436715</busId>

                  <port>"SoapPort"</port>

                  <service>"{http://org.apache.gsoc.server/Greeter_Soap}SOAPService"</service>

                  <type>Bus.Service.Endpoint</type>

            </attribute>

            <canonicalName>org.apache.cxf:bus.id=cxf32436715,port="SoapPort",service="{http://org.apache.gsoc.server/Greeter_Soap}SOAPService",type=Bus.Service.Endpoint</canonicalName>

            <domain>org.apache.cxf</domain>

            <id>4</id>

      </MBean>

      <MBean href="http://localhost:8080/services/jmx/mbean/3">

            <attribute>

                  <busId>cxf32436715</busId>

                  <type>Bus</type>

            </attribute>

            <canonicalName>org.apache.cxf:bus.id=cxf32436715,type=Bus</canonicalName>

            <domain>org.apache.cxf</domain>

            <id>3</id>

      </MBean>

      <MBean href="http://localhost:8080/services/jmx/mbean/1">

            <attribute>

                  <busId>cxf32436715</busId>

                  <port>"CustomerServiceImpl"</port>

                  <service>"{http://server.gsoc.apache.org/}CustomerServiceImpl"</service>

                  <type>Bus.Service.Endpoint</type>

            </attribute>

            <canonicalName>org.apache.cxf:bus.id=cxf32436715,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>

            <domain>org.apache.cxf</domain>

            <id>1</id>

      </MBean>

      <MBean href="http://localhost:8080/services/jmx/mbean/6">

            <attribute>

                  <type>MBeanServerDelegate</type>

            </attribute>

            <canonicalName>JMImplementation:type=MBeanServerDelegate</canonicalName>

            <domain>JMImplementation</domain>

            <id>6</id>

      </MBean>

</MBeans>


I will clean up my code a little for the next step.

Thank you.

Regards:
Shenglin Qiu


> Date: Sat, 21 May 2011 16:37:29 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dev@cxf.apache.org
> 
> >> Are you saying that you have to use UriInfo and UriBuilder for
> >> creating hrefs whenever you need to
> >> build an MBean representation ?
> >>
> >
> > After everytime server bounces, I need to at first use this url request:  http://localhost:8080/services/jmx/, the good thing is, this request only need once,
> >
> 
> What do you mean it is needed only once ?
> 
> > Then my JMXServer will save the UriInfo and also all the href values in MBean are fixed, no further change until another server's bounce.
> >
> 
> I don't understand - as I said on IRC JMXServer should expect
> endpoints created dynamically
> 
> Cheers, Sergey
> 
> >> Please have UriInfo injected in one of the JMXServer's fields, remove
> >> NPE declaration
> >>
> > Done.
> >
> >
> > I will do a fewer more rounds of testing, and put up the source code again.
> >
> >
> >
> > Thank you.
> >
> >
> > Regards:
> > Shenglin Qiu
> >
> >
> >
> >> Date: Fri, 20 May 2011 11:39:55 +0100
> >> Subject: Re: Expose MBeans in CXF
> >> From: sberyozkin@gmail.com
> >> To: dabaipang@hotmail.com
> >> CC: dev@cxf.apache.org
> >>
> >> 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: sberyozkin@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 <da...@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: sberyozkin@gmail.com
> >> >> >> To: dev@cxf.apache.org
> >> >> >>
> >> >> >> HI Shenglin
> >> >> >>
> >> >> >> On Thu, May 19, 2011 at 2:54 PM, Shenglin Qiu <da...@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
> >
> 
> 
> 
> -- 
> Sergey Beryozkin
> 
> Application Integration Division of Talend
> http://sberyozkin.blogspot.com
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
>> Are you saying that you have to use UriInfo and UriBuilder for
>> creating hrefs whenever you need to
>> build an MBean representation ?
>>
>
> After everytime server bounces, I need to at first use this url request:  http://localhost:8080/services/jmx/, the good thing is, this request only need once,
>

What do you mean it is needed only once ?

> Then my JMXServer will save the UriInfo and also all the href values in MBean are fixed, no further change until another server's bounce.
>

I don't understand - as I said on IRC JMXServer should expect
endpoints created dynamically

Cheers, Sergey

>> Please have UriInfo injected in one of the JMXServer's fields, remove
>> NPE declaration
>>
> Done.
>
>
> I will do a fewer more rounds of testing, and put up the source code again.
>
>
>
> Thank you.
>
>
> Regards:
> Shenglin Qiu
>
>
>
>> Date: Fri, 20 May 2011 11:39:55 +0100
>> Subject: Re: Expose MBeans in CXF
>> From: sberyozkin@gmail.com
>> To: dabaipang@hotmail.com
>> CC: dev@cxf.apache.org
>>
>> 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: sberyozkin@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 <da...@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: sberyozkin@gmail.com
>> >> >> To: dev@cxf.apache.org
>> >> >>
>> >> >> HI Shenglin
>> >> >>
>> >> >> On Thu, May 19, 2011 at 2:54 PM, Shenglin Qiu <da...@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
>



-- 
Sergey Beryozkin

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

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi Sergey:

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

After everytime server bounces, I need to at first use this url request:  http://localhost:8080/services/jmx/, the good thing is, this request only need once, 

Then my JMXServer will save the UriInfo and also all the href values in MBean are fixed, no further change until another server's bounce.

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


I will do a fewer more rounds of testing, and put up the source code again.



Thank you.


Regards:
Shenglin Qiu



> Date: Fri, 20 May 2011 11:39:55 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dabaipang@hotmail.com
> CC: dev@cxf.apache.org
> 
> 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: sberyozkin@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 <da...@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: sberyozkin@gmail.com
> >> >> To: dev@cxf.apache.org
> >> >>
> >> >> HI Shenglin
> >> >>
> >> >> On Thu, May 19, 2011 at 2:54 PM, Shenglin Qiu <da...@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
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
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: sberyozkin@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 <da...@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: sberyozkin@gmail.com
>> >> To: dev@cxf.apache.org
>> >>
>> >> HI Shenglin
>> >>
>> >> On Thu, May 19, 2011 at 2:54 PM, Shenglin Qiu <da...@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

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
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 <da...@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: sberyozkin@gmail.com
>> To: dev@cxf.apache.org
>>
>> HI Shenglin
>>
>> On Thu, May 19, 2011 at 2:54 PM, Shenglin Qiu <da...@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

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
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: sberyozkin@gmail.com
> To: dev@cxf.apache.org
> 
> HI Shenglin
> 
> On Thu, May 19, 2011 at 2:54 PM, Shenglin Qiu <da...@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
> >
> >
> >
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
HI Shenglin

On Thu, May 19, 2011 at 2:54 PM, Shenglin Qiu <da...@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
>
>
>

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
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.


Regards:

Shenglin Qiu




> Date: Thu, 19 May 2011 14:19:13 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dabaipang@hotmail.com
> CC: dev@cxf.apache.org
> 
> Hi Shenglin
> 
> Please don't copy all the response collection, copy only relevant fragments.
> 
> >
> > Because there are 2 unrelated MBean filtered out,
> >
> > http://localhost:8080/services/jmx/list/mbean/0 -> CXF BUS
> 
> CXF Bus is definitely relevant, as it is in the org.apache.cxf domain.
> Please include it whenever suitable, ex, when listing all MBeans, when
> a /type/* query matches it, etc
> 
> 
> > therefore,  now href is somehow not continuous as followed, is it ok just
> > for a unique identifier for the MBean we want?
> >
> > http://localhost:8080/services/jmx/list/mbean/0/mbean/1
> > -> restful UserService
> > http://localhost:8080/services/jmx/list/mbean/0/mbean/1/mbean/2/mbean/3
> > -> restful CustomerService
> > http://localhost:8080/services/jmx/list/mbean/0/mbean/1/mbean/2/mbean/3/mbean/4
> > -> soap Greeter
> 
> All MBeans, irrespectively of whether you used /list or /service/*,
> etc query, should have this format:
> 
> http://localhost:8080/services/jmx/mbean/1
> or
> http://localhost:8080/services/jmx/mbean/23
> or
> http://localhost:8080/services/jmx/mbean/99
> or
> http://localhost:8080/services/jmx/mbean/bus.service.id.1
> 
> Note, no 'list' is there. And the key is a simple value like 1 or 23, etc.
> 
> Do you see what I mean ?
> 
> Cheers, Sergey
> 
> >
> > Thank you.
> >
> >
> > Regards:
> > Shenglin Qiu
> >
> >
> >
> >> Date: Thu, 19 May 2011 10:20:19 +0100
> >> Subject: Re: Expose MBeans in CXF
> >> From: sberyozkin@gmail.com
> >> To: dabaipang@hotmail.com
> >> CC: dev@cxf.apache.org
> >>
> >> HI Shenglin
> >>
> >> >>
> >> >> String href =
> >> >> builder.path("mbean").path(someUniqueKey).build().toString()
> >> >
> >> >
> >> > Here is my progress, I use  UriBuilder uriBuilder =
> >> > uriInfo.getAbsolutePathBuilder().path(this.getClass(), "list"); and
> >> >             String uniqueKey = Integer.toString(index++);
> >> >              String href =
> >> > uriBuilder.path(uniqueKey).build().toString();
> >> > in each MBean.
> >> >
> >> >
> >> > (Actually, the result is something I never studied before. This is a
> >> > very
> >> > interesting topic. I will spend more time on it.)
> >>
> >> Indeed, it's interesting.
> >>
> >> You actually need to use uriInfo.getBaseUriBuilder() instead and add
> >> "mbean" segment followed by some
> >> unikey key. Using uriInfo.getBaseUriBuilder() will make sure that
> >> irrespectively of whether you have a /list or /service/* or /type/*
> >> query, you will alway get the same result for MBean href.
> >>
> >> More comments below.
> >>
> >> >
> >> > My current response on this url: http://localhost:8080/services/jmx/
> >>
> >> > <MBeans>
> >>
> >> >    <MBean href="http://localhost:8080/services/jmx/list/0/1/2/3/4/5">
> >> >       <attribute>
> >> >          <type>MBeanServerDelegate</type>
> >> >       </attribute>
> >> >
> >> > <canonicalName>JMImplementation:type=MBeanServerDelegate</canonicalName>
> >> >       <domain>JMImplementation</domain>
> >> >    </MBean>
> >>
> >>
> >> MBeans which are not in the org.apace.cxf domain have to be dropped.
> >> We can have the name of the domain injected as a property in the
> >> future. At the moment have a 'final String DOMAIN_NAME' constant and
> >> use it to filter out non-CXF MBeans
> >>
> >> The other note is that it should always be
> >> "http://localhost:8080/services/jmx/mbean/{someuniquekey}"
> >> with the key being 1, 2, or something more descriptive which can
> >> uniquely identify a given MBean. You probably need to keep a
> >> ConcurrentHashMap, where keys are 1, 2, and values are canonical
> >> names, something like that, so that when you get a request like
> >> "http://localhost:8080/services/jmx/mbean/1" you can retrieve the
> >> corresponding Object name and do something with it
> >>
> >> >    <MBean href="http://localhost:8080/services/jmx/list/0/1">
> >> >       <attribute>
> >> >          <busId>cxf33425430</busId>
> >> >          <port>"JMXServer"</port>
> >> >          <service>"{http://server.gsoc.apache.org/}JMXServer"</service>
> >> >          <type>Bus.Service.Endpoint</type>
> >> >       </attribute>
> >> >
> >> >
> >> > <canonicalName>org.apache.cxf:bus.id=cxf33425430,port="JMXServer",service="{http://server.gsoc.apache.org/}JMXServer",type=Bus.Service.Endpoint</canonicalName>
> >> >       <domain>org.apache.cxf</domain>
> >> >    </MBean>
> >>
> >> This bean has to be excluded as well, at least by default.
> >> What you can do in the short term is to qualify the jmx server
> >> endpoint like this:
> >> <jaxrs:server xmlns:s="http://cxf.apache.org/jmx"
> >> serviceName="s:JMXServer" address="/jmx">
> >> <property name="serviceName"
> >> value="{http://cxf.apache.org/jmx}JMXServer"/>
> >> </jaxrs:server>
> >>
> >> This will give you enough info for checking MBeans which have
> >> 'service' attribute and blocking the one which matches this
> >> serviceName. Another solution is use jaxrs:property or jaxws:property
> >> to indicate that a given endpoint should not be JMX-exposed and update
> >> InstrumnetationManager to check such a property - perhaps we can do it
> >> later
> >>
> >> >
> >> > Of course, as you required, I format the output.
> >>
> >> Sorry, I may've confused you, please don't format,
> >>
> >> thanks, Sergey
> >>
> >> >
> >> > Regards:
> >> > Shenglin Qiu
> >> >
> >> >
> >
> 
> 
> 
> -- 
> Sergey Beryozkin
> 
> Application Integration Division of Talend
> http://sberyozkin.blogspot.com
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Shenglin

Please don't copy all the response collection, copy only relevant fragments.

>
> Because there are 2 unrelated MBean filtered out,
>
> http://localhost:8080/services/jmx/list/mbean/0 -> CXF BUS

CXF Bus is definitely relevant, as it is in the org.apache.cxf domain.
Please include it whenever suitable, ex, when listing all MBeans, when
a /type/* query matches it, etc


> therefore,  now href is somehow not continuous as followed, is it ok just
> for a unique identifier for the MBean we want?
>
> http://localhost:8080/services/jmx/list/mbean/0/mbean/1
> -> restful UserService
> http://localhost:8080/services/jmx/list/mbean/0/mbean/1/mbean/2/mbean/3
> -> restful CustomerService
> http://localhost:8080/services/jmx/list/mbean/0/mbean/1/mbean/2/mbean/3/mbean/4
> -> soap Greeter

All MBeans, irrespectively of whether you used /list or /service/*,
etc query, should have this format:

http://localhost:8080/services/jmx/mbean/1
or
http://localhost:8080/services/jmx/mbean/23
or
http://localhost:8080/services/jmx/mbean/99
or
http://localhost:8080/services/jmx/mbean/bus.service.id.1

Note, no 'list' is there. And the key is a simple value like 1 or 23, etc.

Do you see what I mean ?

Cheers, Sergey

>
> Thank you.
>
>
> Regards:
> Shenglin Qiu
>
>
>
>> Date: Thu, 19 May 2011 10:20:19 +0100
>> Subject: Re: Expose MBeans in CXF
>> From: sberyozkin@gmail.com
>> To: dabaipang@hotmail.com
>> CC: dev@cxf.apache.org
>>
>> HI Shenglin
>>
>> >>
>> >> String href =
>> >> builder.path("mbean").path(someUniqueKey).build().toString()
>> >
>> >
>> > Here is my progress, I use  UriBuilder uriBuilder =
>> > uriInfo.getAbsolutePathBuilder().path(this.getClass(), "list"); and
>> >             String uniqueKey = Integer.toString(index++);
>> >              String href =
>> > uriBuilder.path(uniqueKey).build().toString();
>> > in each MBean.
>> >
>> >
>> > (Actually, the result is something I never studied before. This is a
>> > very
>> > interesting topic. I will spend more time on it.)
>>
>> Indeed, it's interesting.
>>
>> You actually need to use uriInfo.getBaseUriBuilder() instead and add
>> "mbean" segment followed by some
>> unikey key. Using uriInfo.getBaseUriBuilder() will make sure that
>> irrespectively of whether you have a /list or /service/* or /type/*
>> query, you will alway get the same result for MBean href.
>>
>> More comments below.
>>
>> >
>> > My current response on this url: http://localhost:8080/services/jmx/
>>
>> > <MBeans>
>>
>> >    <MBean href="http://localhost:8080/services/jmx/list/0/1/2/3/4/5">
>> >       <attribute>
>> >          <type>MBeanServerDelegate</type>
>> >       </attribute>
>> >
>> > <canonicalName>JMImplementation:type=MBeanServerDelegate</canonicalName>
>> >       <domain>JMImplementation</domain>
>> >    </MBean>
>>
>>
>> MBeans which are not in the org.apace.cxf domain have to be dropped.
>> We can have the name of the domain injected as a property in the
>> future. At the moment have a 'final String DOMAIN_NAME' constant and
>> use it to filter out non-CXF MBeans
>>
>> The other note is that it should always be
>> "http://localhost:8080/services/jmx/mbean/{someuniquekey}"
>> with the key being 1, 2, or something more descriptive which can
>> uniquely identify a given MBean. You probably need to keep a
>> ConcurrentHashMap, where keys are 1, 2, and values are canonical
>> names, something like that, so that when you get a request like
>> "http://localhost:8080/services/jmx/mbean/1" you can retrieve the
>> corresponding Object name and do something with it
>>
>> >    <MBean href="http://localhost:8080/services/jmx/list/0/1">
>> >       <attribute>
>> >          <busId>cxf33425430</busId>
>> >          <port>"JMXServer"</port>
>> >          <service>"{http://server.gsoc.apache.org/}JMXServer"</service>
>> >          <type>Bus.Service.Endpoint</type>
>> >       </attribute>
>> >
>> >
>> > <canonicalName>org.apache.cxf:bus.id=cxf33425430,port="JMXServer",service="{http://server.gsoc.apache.org/}JMXServer",type=Bus.Service.Endpoint</canonicalName>
>> >       <domain>org.apache.cxf</domain>
>> >    </MBean>
>>
>> This bean has to be excluded as well, at least by default.
>> What you can do in the short term is to qualify the jmx server
>> endpoint like this:
>> <jaxrs:server xmlns:s="http://cxf.apache.org/jmx"
>> serviceName="s:JMXServer" address="/jmx">
>> <property name="serviceName"
>> value="{http://cxf.apache.org/jmx}JMXServer"/>
>> </jaxrs:server>
>>
>> This will give you enough info for checking MBeans which have
>> 'service' attribute and blocking the one which matches this
>> serviceName. Another solution is use jaxrs:property or jaxws:property
>> to indicate that a given endpoint should not be JMX-exposed and update
>> InstrumnetationManager to check such a property - perhaps we can do it
>> later
>>
>> >
>> > Of course, as you required, I format the output.
>>
>> Sorry, I may've confused you, please don't format,
>>
>> thanks, Sergey
>>
>> >
>> > Regards:
>> > Shenglin Qiu
>> >
>> >
>



-- 
Sergey Beryozkin

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

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi Sergey

I have now having this response as you commented:
 
<MBeans>
   <MBean href="http://localhost:8080/services/jmx/list/mbean/0/mbean/1/mbean/2/mbean/3/mbean/4">
      <attribute>
         <busId>cxf29162475</busId>
         <port>"SoapPort"</port>
         <service>"{http://org.apache.gsoc.server/Greeter_Soap}SOAPService"</service>
         <type>Bus.Service.Endpoint</type>
      </attribute>
      <canonicalName>org.apache.cxf:bus.id=cxf29162475,port="SoapPort",service="{http://org.apache.gsoc.server/Greeter_Soap}SOAPService",type=Bus.Service.Endpoint</canonicalName>
      <domain>org.apache.cxf</domain>
   </MBean>
   <MBean href="http://localhost:8080/services/jmx/list/mbean/0/mbean/1/mbean/2/mbean/3">
      <attribute>
         <busId>cxf29162475</busId>
         <port>"CustomerServiceImpl"</port>
         <service>"{http://server.gsoc.apache.org/}CustomerServiceImpl"</service>
         <type>Bus.Service.Endpoint</type>
      </attribute>
      <canonicalName>org.apache.cxf:bus.id=cxf29162475,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
      <domain>org.apache.cxf</domain>
   </MBean>
   <MBean href="http://localhost:8080/services/jmx/list/mbean/0/mbean/1">
      <attribute>
         <busId>cxf29162475</busId>
         <port>"UserServiceImpl"</port>
         <service>"{http://server.gsoc.apache.org/}UserServiceImpl"</service>
         <type>Bus.Service.Endpoint</type>
      </attribute>
      <canonicalName>org.apache.cxf:bus.id=cxf29162475,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
      <domain>org.apache.cxf</domain>
   </MBean>
</MBeans>
 
Because there are 2 unrelated MBean filtered out, 
 
http://localhost:8080/services/jmx/list/mbean/0 -> CXF BUS
http://localhost:8080/services/jmx/list/mbean/0/mbean/1/mbean/2 -> My own jaxrs mbean server as you mentioned it must be filtered
 
and also , this is filtered out as you mentioned
> > <MBeans>
> 
> > <MBean href="http://localhost:8080/services/jmx/list/0/1/2/3/4/5">
> > <attribute>
> > <type>MBeanServerDelegate</type>
> > </attribute>
> >
> > <canonicalName>JMImplementation:type=MBeanServerDelegate</canonicalName>
> > <domain>JMImplementation</domain>
> > </MBean>
 
 
therefore,  now href is somehow not continuous as followed, is it ok just for a unique identifier for the MBean we want?
 
http://localhost:8080/services/jmx/list/mbean/0/mbean/1                      -> restful UserService
http://localhost:8080/services/jmx/list/mbean/0/mbean/1/mbean/2/mbean/3     -> restful CustomerService
http://localhost:8080/services/jmx/list/mbean/0/mbean/1/mbean/2/mbean/3/mbean/4    -> soap Greeter
 
Thank you.
 
 
Regards:
Shenglin Qiu
 
 
 
> Date: Thu, 19 May 2011 10:20:19 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dabaipang@hotmail.com
> CC: dev@cxf.apache.org
> 
> HI Shenglin
> 
> >>
> >> String href = builder.path("mbean").path(someUniqueKey).build().toString()
> >
> >
> > Here is my progress, I use  UriBuilder uriBuilder =
> > uriInfo.getAbsolutePathBuilder().path(this.getClass(), "list"); and
> >             String uniqueKey = Integer.toString(index++);
> >              String href = uriBuilder.path(uniqueKey).build().toString();
> > in each MBean.
> >
> >
> > (Actually, the result is something I never studied before. This is a very
> > interesting topic. I will spend more time on it.)
> 
> Indeed, it's interesting.
> 
> You actually need to use uriInfo.getBaseUriBuilder() instead and add
> "mbean" segment followed by some
> unikey key. Using uriInfo.getBaseUriBuilder() will make sure that
> irrespectively of whether you have a /list or /service/* or /type/*
> query, you will alway get the same result for MBean href.
> 
> More comments below.
> 
> >
> > My current response on this url: http://localhost:8080/services/jmx/
> 
> > <MBeans>
> 
> >    <MBean href="http://localhost:8080/services/jmx/list/0/1/2/3/4/5">
> >       <attribute>
> >          <type>MBeanServerDelegate</type>
> >       </attribute>
> >
> > <canonicalName>JMImplementation:type=MBeanServerDelegate</canonicalName>
> >       <domain>JMImplementation</domain>
> >    </MBean>
> 
> 
> MBeans which are not in the org.apace.cxf domain have to be dropped.
> We can have the name of the domain injected as a property in the
> future. At the moment have a 'final String DOMAIN_NAME' constant and
> use it to filter out non-CXF MBeans
> 
> The other note is that it should always be
> "http://localhost:8080/services/jmx/mbean/{someuniquekey}"
> with the key being 1, 2, or something more descriptive which can
> uniquely identify a given MBean. You probably need to keep a
> ConcurrentHashMap, where keys are 1, 2, and values are canonical
> names, something like that, so that when you get a request like
> "http://localhost:8080/services/jmx/mbean/1" you can retrieve the
> corresponding Object name and do something with it
> 
> >    <MBean href="http://localhost:8080/services/jmx/list/0/1">
> >       <attribute>
> >          <busId>cxf33425430</busId>
> >          <port>"JMXServer"</port>
> >          <service>"{http://server.gsoc.apache.org/}JMXServer"</service>
> >          <type>Bus.Service.Endpoint</type>
> >       </attribute>
> >
> > <canonicalName>org.apache.cxf:bus.id=cxf33425430,port="JMXServer",service="{http://server.gsoc.apache.org/}JMXServer",type=Bus.Service.Endpoint</canonicalName>
> >       <domain>org.apache.cxf</domain>
> >    </MBean>
> 
> This bean has to be excluded as well, at least by default.
> What you can do in the short term is to qualify the jmx server
> endpoint like this:
> <jaxrs:server xmlns:s="http://cxf.apache.org/jmx"
> serviceName="s:JMXServer" address="/jmx">
> <property name="serviceName" value="{http://cxf.apache.org/jmx}JMXServer"/>
> </jaxrs:server>
> 
> This will give you enough info for checking MBeans which have
> 'service' attribute and blocking the one which matches this
> serviceName. Another solution is use jaxrs:property or jaxws:property
> to indicate that a given endpoint should not be JMX-exposed and update
> InstrumnetationManager to check such a property - perhaps we can do it
> later
> 
> >
> > Of course, as you required, I format the output.
> 
> Sorry, I may've confused you, please don't format,
> 
> thanks, Sergey
> 
> >
> > Regards:
> > Shenglin Qiu
> >
> >
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
HI Shenglin

>>
>> String href = builder.path("mbean").path(someUniqueKey).build().toString()
>
>
> Here is my progress, I use  UriBuilder uriBuilder =
> uriInfo.getAbsolutePathBuilder().path(this.getClass(), "list"); and
>             String uniqueKey = Integer.toString(index++);
>              String href = uriBuilder.path(uniqueKey).build().toString();
> in each MBean.
>
>
> (Actually, the result is something I never studied before. This is a very
> interesting topic. I will spend more time on it.)

Indeed, it's interesting.

You actually need to use uriInfo.getBaseUriBuilder() instead and add
"mbean" segment followed by some
unikey key. Using uriInfo.getBaseUriBuilder() will make sure that
irrespectively of whether you have a /list or /service/* or /type/*
query, you will alway get the same result for MBean href.

More comments below.

>
> My current response on this url: http://localhost:8080/services/jmx/

> <MBeans>

>    <MBean href="http://localhost:8080/services/jmx/list/0/1/2/3/4/5">
>       <attribute>
>          <type>MBeanServerDelegate</type>
>       </attribute>
>
> <canonicalName>JMImplementation:type=MBeanServerDelegate</canonicalName>
>       <domain>JMImplementation</domain>
>    </MBean>


MBeans which are not in the org.apace.cxf domain have to be dropped.
We can have the name of the domain injected as a property in the
future. At the moment have a 'final String DOMAIN_NAME' constant and
use it to filter  out non-CXF MBeans

The other note is that it should always be
"http://localhost:8080/services/jmx/mbean/{someuniquekey}"
with the key being 1, 2, or something more descriptive which can
uniquely identify a given MBean. You probably need to keep a
ConcurrentHashMap, where keys are 1, 2, and values are canonical
names, something like that, so that when you get a request like
"http://localhost:8080/services/jmx/mbean/1" you can retrieve the
corresponding Object name and do something with it

>    <MBean href="http://localhost:8080/services/jmx/list/0/1">
>       <attribute>
>          <busId>cxf33425430</busId>
>          <port>"JMXServer"</port>
>          <service>"{http://server.gsoc.apache.org/}JMXServer"</service>
>          <type>Bus.Service.Endpoint</type>
>       </attribute>
>
> <canonicalName>org.apache.cxf:bus.id=cxf33425430,port="JMXServer",service="{http://server.gsoc.apache.org/}JMXServer",type=Bus.Service.Endpoint</canonicalName>
>       <domain>org.apache.cxf</domain>
>    </MBean>

This bean has to be excluded as well, at least by default.
What you can do in the short term is to qualify the jmx server
endpoint like this:
<jaxrs:server xmlns:s="http://cxf.apache.org/jmx"
serviceName="s:JMXServer" address="/jmx">
<property name="serviceName" value="{http://cxf.apache.org/jmx}JMXServer"/>
</jaxrs:server>

This will give you enough info for checking MBeans which have
'service' attribute and blocking the one which matches this
serviceName. Another solution is use jaxrs:property or jaxws:property
to indicate that a given endpoint should not be JMX-exposed and update
InstrumnetationManager to check such a property - perhaps we can do it
later

>
> Of course, as you required, I format the output.

Sorry, I may've confused you, please don't format,

thanks, Sergey

>
> Regards:
> Shenglin Qiu
>
>

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi Sergey:

I am now at this step from your comment:
> Now, there's one thing which is missing from the above representation
> and it is a link to a resource which will deal with a particular MBean
> (possible updates of properties, handling the notifications). We need
> to put it all into a more practical surface so it should be something
> like
> 
> <MBeans>
> <MBean href="http://localhost:8080/soapdemo/jmx/mbean/1">
>  <domain>org.apache.cxf</domain>
>
  
<canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> <MBean>
> <MBean href="http://localhost:8080/soapdemo/jmx/mbean/2">
>  <domain>org.apache.cxf</domain>
>
  
<canonicalName>org.apache.cxf:bus.id=cxf5663551,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> <MBean>
> </MBeans>
> 
> where http://localhost:8080/soapdemo/jmx/mbean/1,
> http://localhost:8080/soapdemo/jmx/mbean/2, etc, uniquely identify
> those individual MBeans only.
> 
> So please update MBean class to have "href" attribute (with
> @XmlAttribute). Have a '@Context UriInfo uriinfo' field in JMXServer
> class. When you create a response for /list or /service/*, etc, use
> UriInfo to get to the *base* UriBuilder which will represent a URI
> like "http://localhost:8080/soapdemo/jmx". Next add "mbean" and then a
> number like 1/2/etc which identifies a particular MBean, may be a
> short objectname instead of the compete canonical name, etc, so and
> have UriBuilder to return you
> 'http://localhost:8080/soapdemo/jmx/mbean/1', etc:
> 
> String href = builder.path("mbean").path(someUniqueKey).build().toString()


Here is my progress, I use  UriBuilder uriBuilder = uriInfo.getAbsolutePathBuilder().path(this.getClass(), "list"); and 
            String uniqueKey = Integer.toString(index++);
             String href = uriBuilder.path(uniqueKey).build().toString();
in each MBean.


(Actually, the result is something I never studied before. This is a very interesting topic. I will spend more time on it.)

My current response on this url: http://localhost:8080/services/jmx/ 
<MBeans>
   <MBean href="http://localhost:8080/services/jmx/list/0">
      <attribute>
         <busId>cxf33425430</busId>
         <port>"UserServiceImpl"</port>
         <service>"{http://server.gsoc.apache.org/}UserServiceImpl"</service>
         <type>Bus.Service.Endpoint</type>
      </attribute>
      <canonicalName>org.apache.cxf:bus.id=cxf33425430,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
      <domain>org.apache.cxf</domain>
   </MBean>
   <MBean href="http://localhost:8080/services/jmx/list/0/1/2/3/4/5">
      <attribute>
         <type>MBeanServerDelegate</type>
      </attribute>
      <canonicalName>JMImplementation:type=MBeanServerDelegate</canonicalName>
      <domain>JMImplementation</domain>
   </MBean>
   <MBean href="http://localhost:8080/services/jmx/list/0/1/2/3">
      <attribute>
         <busId>cxf33425430</busId>
         <type>Bus</type>
      </attribute>
      <canonicalName>org.apache.cxf:bus.id=cxf33425430,type=Bus</canonicalName>
      <domain>org.apache.cxf</domain>
   </MBean>
   <MBean href="http://localhost:8080/services/jmx/list/0/1/2/3/4">
      <attribute>
         <busId>cxf33425430</busId>
         <port>"SoapPort"</port>
         <service>"{http://org.apache.gsoc.server/Greeter_Soap}SOAPService"</service>
         <type>Bus.Service.Endpoint</type>
      </attribute>
      <canonicalName>org.apache.cxf:bus.id=cxf33425430,port="SoapPort",service="{http://org.apache.gsoc.server/Greeter_Soap}SOAPService",type=Bus.Service.Endpoint</canonicalName>
      <domain>org.apache.cxf</domain>
   </MBean>
   <MBean href="http://localhost:8080/services/jmx/list/0/1">
      <attribute>
         <busId>cxf33425430</busId>
         <port>"JMXServer"</port>
         <service>"{http://server.gsoc.apache.org/}JMXServer"</service>
         <type>Bus.Service.Endpoint</type>
      </attribute>
      <canonicalName>org.apache.cxf:bus.id=cxf33425430,port="JMXServer",service="{http://server.gsoc.apache.org/}JMXServer",type=Bus.Service.Endpoint</canonicalName>
      <domain>org.apache.cxf</domain>
   </MBean>
   <MBean href="http://localhost:8080/services/jmx/list/0/1/2">
      <attribute>
         <busId>cxf33425430</busId>
         <port>"CustomerServiceImpl"</port>
         <service>"{http://server.gsoc.apache.org/}CustomerServiceImpl"</service>
         <type>Bus.Service.Endpoint</type>
      </attribute>
      <canonicalName>org.apache.cxf:bus.id=cxf33425430,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
      <domain>org.apache.cxf</domain>
   </MBean>
</MBeans>

Of course, as you required, I format the output.

Regards:
Shenglin Qiu


> Date: Wed, 18 May 2011 11:38:24 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dev@cxf.apache.org
> 
> Hi Shenglin
> 
> Well done, you are progressing well.
> 
> Note that you don't have to start formatting the updates to the dev
> list, it's just
> the work as usual, keep it simple please :-). And don't CC to the secretary :-)
> 
> Some comments below.
> 
> > I am fully upgrade it to 2.4.0, I have some testing phase exceptions
> > ocurring even I don't have a test case in maven test src folder. I will
> > figure this out later after this doc.
> >
> If you are seeing some unrelated test failures when building the trunk
> then add '-Pfastinstall'
> 
> > The RAR src is attached, hope this 'soap' won't confuse you, it actually has
> > 1 soap inbound and 2 restful inbounds. I am always stuck at the naming,
> > previous demoserver has been down when I was upgrading, that's another
> > story, and I will fix it.
> >
> 
> Well, /soapdemo is confusing.
> Have the context named as "/services" or "/application" and set the
> address of SOAP endpoint as "/soap/greeter" or simply "/greeter" as
> you do now.
> 
> <snip/>
> >
> > Here are the 3 enabled inbound service, including 1 soap webservice and 2
> > Restful service:(They are up and running)
> >
> > http://localhost:8080/soapdemo/greeter?wsdl
> >
> > http://localhost:8080/soapdemo/customerservice/customers
> >
> > http://localhost:8080/soapdemo/customerservice/customer/firstname/Lois
> >
> > http://localhost:8080/soapdemo/customerservice/customer/id/1
> >
> > http://localhost:8080/soapdemo/userservice/users
> >
> > http://localhost:8080/soapdemo/userservice/user/1
> >
> 
> OK, lets have
> http://localhost:8080/services/greeter
> http://localhost:8080/services/customerservice
> http://localhost:8080/services/userservice
> 
> >
> >
> > And here is the demo inbound Restful service url which is holding the above
> > 3 services MBeans:
> >
> > http://localhost:8080/soapdemo/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
> >
> 
> I think you meant to say:
> 
> > http://localhost:8080/soapdemo/jmx
> 
> which is the address of your JMX server endpoint which should be changed to say
> "http://localhost:8080/services/jmx".
> 
> > which is:
> >
> > http://localhost:8080/soapdemo/jmx/service/{http://server.gsoc.apache.org/}CustomerServiceImpl
> >
> > http://localhost:8080/soapdemo/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
> >
> > http://localhost:8080/soapdemo/jmx/type/Bus.Service.Endpoint
> >
> > http://localhost:8080/soapdemo/jmx/list
> >
> >
> 
> Ok, so what are you saying is that you can have a list of all MBeans
> returned, using "/list" or a list of all MBeans which have a matching
> objectname or attribute (such as type, service, port, etc)
> 
> I like "http://localhost:8080/soapdemo/jmx/list and
> http://localhost:8080/soapdemo/jmx/objectname/" though I think we can
> simplify those,  but right now make sure that you have something like
> @Path("{attribute}/{value}") for a method which serves /service/*, and
> /type/* requests. because 'service' and 'type' are attributes and we
> can have many attributes.
> 
> >
> > Request:
> >
> > http://localhost:8080/soapdemo/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
> >
> > Note: this is actually an url encoded string which is  from:
> >
> > http://localhost:8080/soapdemo/jmx/service/{http://server.gsoc.apache.org/}CustomerServiceImpl
> >
> OK, we should also be able to support
> 
> http://localhost:8080/soapdemo/jmx/service/{http://server.gsoc.apache.org/}*
> 
> which means get all MBeans which have a service attribute with
> namespace equal to 'http://server.gsoc.apache.org'
> 
> 
> > Response:
> >
> > <MBeanCollection>
> >
> >    <MBeans>
> >
> >       <MBean>
> >
> >
> > <canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> >
> >          <domain>org.apache.cxf</domain>
> >
> >
> > <endpointName>"{http://server.gsoc.apache.org/}CustomerServiceImpl"</endpointName>
> >
> >       </MBean>
> >
> >    </MBeans>
> >
> > </MBeanCollection>
> >
> OK. Please remove MBeanCollection wrapper, you have another wrapper, MBeans.
> No need to have quotes around endpointName's value.
> How about having MBean representation structured like this:
> 
> <MBean>
> <domain>org.apache.cxf</domain>
> <canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> <!-- this is another representation of canonical's name
> <attributes>
>    <type>Bus.Service.Endpoint</type>
>    <service>{http://server.gsoc.apache.org/}CustomerServiceImpl</service>
>    <endpoint>CustomerServiceImpl</endpoint>
> <attributes>
> <!--
> This can be ignored for now
> <properties/>
> -->
> </MBean>
> 
> This will make it simpler for consumers to understand - we may support
> returning canonicalNames only or alternative, structured reps but for
> now just have MBean representation updated as suggested.
> 
> Now, there's one thing which is missing from the above representation
> and it is a link to a resource which will deal with a particular MBean
> (possible updates of properties, handling the notifications). We need
> to put it all into a more practical surface so it should be something
> like
> 
> <MBeans>
> <MBean href="http://localhost:8080/soapdemo/jmx/mbean/1">
>  <domain>org.apache.cxf</domain>
>  <canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> <MBean>
> <MBean href="http://localhost:8080/soapdemo/jmx/mbean/2">
>  <domain>org.apache.cxf</domain>
>  <canonicalName>org.apache.cxf:bus.id=cxf5663551,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> <MBean>
> </MBeans>
> 
> where http://localhost:8080/soapdemo/jmx/mbean/1,
> http://localhost:8080/soapdemo/jmx/mbean/2, etc, uniquely identify
> those individual MBeans only.
> 
> So please update MBean class to have "href" attribute (with
> @XmlAttribute). Have a '@Context UriInfo uriinfo' field in JMXServer
> class. When you create a response for /list or /service/*, etc, use
> UriInfo to get to the *base* UriBuilder which will represent a URI
> like "http://localhost:8080/soapdemo/jmx". Next add "mbean" and then a
> number like 1/2/etc which identifies a particular MBean, may be a
> short objectname instead of the compete canonical name, etc, so and
> have UriBuilder to return you
> 'http://localhost:8080/soapdemo/jmx/mbean/1', etc:
> 
> String href = builder.path("mbean").path(someUniqueKey).build().toString()
> 
> Now, the question is how to handle requests like
> 'http://localhost:8080/soapdemo/jmx/mbean/1'
> 
> Your JMXServer should have a subresource locator, with @Path("mbean")
> and without HttpMethod.
> This locator will return something like MBeanResource and that class,
> at this stage, will have *only*
> a single @GET resource method with @Path("{key}") and which will
> return the above MBean representaion only, without MBeans wrapper:
> 
> GET http://localhost:8080/soapdemo/jmx/mbean/1
> 
> returns
> 
> <MBean href="http://localhost:8080/soapdemo/jmx/mbean/1">
>  <domain>org.apache.cxf</domain>
>  <canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> </MBean>
> 
> Having a subresource handly because at the next step we will start
> working on dealing with notifications/updatiing properties or invoking
> operations somehow when applicable.
> 
> Does it make sense ? If you have any questions or suggestions - please
> ask them here or ping me on #cxf
> I guess we have two weeks or so and then I'd like to discuss how
> LogBrowser can be extended to act as a consumer of your JMXServer
> 
> I'm removing the rest of your message to make it shorter, everything
> you posted there looked OK, those who are interested can check the
> previous message if needed for more info.
> 
> You are progressing very well.
> 
> Thanks, Sergey
> 
> >
> > Thank you.
> >ld
> > Regards:
> > Shenglin Qiu
> >
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Shenglin

Well done, you are progressing well.

Note that you don't have to start formatting the updates to the dev
list, it's just
the work as usual, keep it simple please :-). And don't CC to the secretary :-)

Some comments below.

> I am fully upgrade it to 2.4.0, I have some testing phase exceptions
> ocurring even I don't have a test case in maven test src folder. I will
> figure this out later after this doc.
>
If you are seeing some unrelated test failures when building the trunk
then add '-Pfastinstall'

> The RAR src is attached, hope this 'soap' won't confuse you, it actually has
> 1 soap inbound and 2 restful inbounds. I am always stuck at the naming,
> previous demoserver has been down when I was upgrading, that's another
> story, and I will fix it.
>

Well, /soapdemo is confusing.
Have the context named as "/services" or "/application" and set the
address of SOAP endpoint as "/soap/greeter" or simply "/greeter" as
you do now.

<snip/>
>
> Here are the 3 enabled inbound service, including 1 soap webservice and 2
> Restful service:(They are up and running)
>
> http://localhost:8080/soapdemo/greeter?wsdl
>
> http://localhost:8080/soapdemo/customerservice/customers
>
> http://localhost:8080/soapdemo/customerservice/customer/firstname/Lois
>
> http://localhost:8080/soapdemo/customerservice/customer/id/1
>
> http://localhost:8080/soapdemo/userservice/users
>
> http://localhost:8080/soapdemo/userservice/user/1
>

OK, lets have
http://localhost:8080/services/greeter
http://localhost:8080/services/customerservice
http://localhost:8080/services/userservice

>
>
> And here is the demo inbound Restful service url which is holding the above
> 3 services MBeans:
>
> http://localhost:8080/soapdemo/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
>

I think you meant to say:

> http://localhost:8080/soapdemo/jmx

which is the address of your JMX server endpoint which should be changed to say
"http://localhost:8080/services/jmx".

> which is:
>
> http://localhost:8080/soapdemo/jmx/service/{http://server.gsoc.apache.org/}CustomerServiceImpl
>
> http://localhost:8080/soapdemo/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
>
> http://localhost:8080/soapdemo/jmx/type/Bus.Service.Endpoint
>
> http://localhost:8080/soapdemo/jmx/list
>
>

Ok, so what are you saying is that you can have a list of all MBeans
returned, using "/list" or a list of all MBeans which have a matching
objectname or attribute (such as type, service, port, etc)

I like "http://localhost:8080/soapdemo/jmx/list and
http://localhost:8080/soapdemo/jmx/objectname/" though I think we can
simplify those,  but right now make sure that you have something like
@Path("{attribute}/{value}") for a method which serves /service/*, and
/type/* requests. because 'service' and 'type' are attributes and we
can have many attributes.

>
> Request:
>
> http://localhost:8080/soapdemo/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl
>
> Note: this is actually an url encoded string which is  from:
>
> http://localhost:8080/soapdemo/jmx/service/{http://server.gsoc.apache.org/}CustomerServiceImpl
>
OK, we should also be able to support

http://localhost:8080/soapdemo/jmx/service/{http://server.gsoc.apache.org/}*

which means get all MBeans which have a service attribute with
namespace equal to 'http://server.gsoc.apache.org'


> Response:
>
> <MBeanCollection>
>
>    <MBeans>
>
>       <MBean>
>
>
> <canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
>
>          <domain>org.apache.cxf</domain>
>
>
> <endpointName>"{http://server.gsoc.apache.org/}CustomerServiceImpl"</endpointName>
>
>       </MBean>
>
>    </MBeans>
>
> </MBeanCollection>
>
OK. Please remove MBeanCollection wrapper, you have another wrapper, MBeans.
No need to have quotes around endpointName's value.
How about having MBean representation structured like this:

<MBean>
<domain>org.apache.cxf</domain>
<canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
<!-- this is another representation of canonical's name
<attributes>
   <type>Bus.Service.Endpoint</type>
   <service>{http://server.gsoc.apache.org/}CustomerServiceImpl</service>
   <endpoint>CustomerServiceImpl</endpoint>
<attributes>
<!--
This can be ignored for now
<properties/>
-->
</MBean>

This will make it simpler for consumers to understand - we may support
returning canonicalNames only or alternative, structured reps but for
now just have MBean representation updated as suggested.

Now, there's one thing which is missing from the above representation
and it is a link to a resource which will deal with a particular MBean
(possible updates of properties, handling the notifications). We need
to put it all into a more practical surface so it should be something
like

<MBeans>
<MBean href="http://localhost:8080/soapdemo/jmx/mbean/1">
 <domain>org.apache.cxf</domain>
 <canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
<MBean>
<MBean href="http://localhost:8080/soapdemo/jmx/mbean/2">
 <domain>org.apache.cxf</domain>
 <canonicalName>org.apache.cxf:bus.id=cxf5663551,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
<MBean>
</MBeans>

where http://localhost:8080/soapdemo/jmx/mbean/1,
http://localhost:8080/soapdemo/jmx/mbean/2, etc, uniquely identify
those individual MBeans only.

So please update MBean class to have "href" attribute (with
@XmlAttribute). Have a '@Context UriInfo uriinfo' field in JMXServer
class. When you create a response for /list or /service/*, etc, use
UriInfo to get to the *base* UriBuilder which will represent a URI
like "http://localhost:8080/soapdemo/jmx". Next add "mbean" and then a
number like 1/2/etc which identifies a particular MBean, may be a
short objectname instead of the compete canonical name, etc, so and
have UriBuilder to return you
'http://localhost:8080/soapdemo/jmx/mbean/1', etc:

String href = builder.path("mbean").path(someUniqueKey).build().toString()

Now, the question is how to handle requests like
'http://localhost:8080/soapdemo/jmx/mbean/1'

Your JMXServer should have a subresource locator, with @Path("mbean")
and without HttpMethod.
This locator will return something like MBeanResource and that class,
at this stage, will have *only*
a single @GET resource method with @Path("{key}") and which will
return the above MBean representaion only, without MBeans wrapper:

GET http://localhost:8080/soapdemo/jmx/mbean/1

returns

<MBean href="http://localhost:8080/soapdemo/jmx/mbean/1">
 <domain>org.apache.cxf</domain>
 <canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
</MBean>

Having a subresource handly because at the next step we will start
working on dealing with notifications/updatiing properties or invoking
operations somehow when applicable.

Does it make sense ? If you have any questions or suggestions - please
ask them here or ping me on #cxf
I guess we have two weeks or so and then I'd like to discuss how
LogBrowser can be extended to act as a consumer of your JMXServer

I'm removing the rest of your message to make it shorter, everything
you posted there looked OK, those who are interested can check the
previous message if needed for more info.

You are progressing very well.

Thanks, Sergey

>
> Thank you.
>ld
> Regards:
> Shenglin Qiu
>

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi Sergey:

I am putting up the document, the formatting work of xml in Word is kind of a headache, but here is the actual outline of my document, after having a better format, I will email it again in Word07. 

I am fully upgrade it to 2.4.0, I have some testing phase exceptions ocurring even I don't have a test case in maven test src folder. I will figure this out later after this doc.

The RAR src is attached, hope this 'soap' won't confuse you, it actually has 1 soap inbound and 2 restful inbounds. I am always stuck at the naming, previous demoserver has been down when I was upgrading, that's another story, and I will fix it.




Title: 
Cxf 3388 - Expose CXF JMX MBeans as the JAX-RS resources


Description:

The JAX-RS application exposing CXF JMX MBeans over HTTP
needs to be added to the rt/management-web component.

 https://issues.apache.org/jira/browse/CXF-3388

Reference:I studied and referenced the cxf-tr-management the most, and take InstrumentationManagerImpl as the core in my implementation.


First Phase:

Develop inbound server prototype which has JMX MBean
enabled:


Here are the 3 enabled inbound service, including 1 soap
webservice and 2 Restful service:(They are up and running)

http://localhost:8080/soapdemo/greeter?wsdl


http://localhost:8080/soapdemo/customerservice/customers


http://localhost:8080/soapdemo/customerservice/customer/firstname/Lois


http://localhost:8080/soapdemo/customerservice/customer/id/1


http://localhost:8080/soapdemo/userservice/users

http://localhost:8080/soapdemo/userservice/user/1

 

And here is the demo inbound Restful service url which is holding
the above 3 services MBeans:

http://localhost:8080/soapdemo/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl


which is:

http://localhost:8080/soapdemo/jmx/service/{http://server.gsoc.apache.org/}CustomerServiceImpl


http://localhost:8080/soapdemo/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*


http://localhost:8080/soapdemo/jmx/type/Bus.Service.Endpoint


http://localhost:8080/soapdemo/jmx/list


 


Request: 


http://localhost:8080/soapdemo/jmx/service/%7Bhttp:%2F%2Fserver.gsoc.apache.org%2F%7DCustomerServiceImpl

Note: this is actually an url encoded string which is  from:


http://localhost:8080/soapdemo/jmx/service/{http://server.gsoc.apache.org/}CustomerServiceImpl
Response:<MBeanCollection>

   <MBeans>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>

        
<domain>org.apache.cxf</domain>

        
<endpointName>"{http://server.gsoc.apache.org/}CustomerServiceImpl"</endpointName>

      </MBean>

   </MBeans>

</MBeanCollection>

 


Request: 


http://localhost:8080/soapdemo/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*

Response:
<MBeanCollection>

   <MBeans>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf31085410,port="SoapPort",service="{http://org.apache.gsoc.server/Greeter_Soap}SOAPService",type=Bus.Service.Endpoint</canonicalName>

        
<domain>org.apache.cxf</domain>

      </MBean>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf31085410,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>

        
<domain>org.apache.cxf</domain>

      </MBean>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf31085410,port="JMXServer",service="{http://server.gsoc.apache.org/}JMXServer",type=Bus.Service.Endpoint</canonicalName>

        
<domain>org.apache.cxf</domain>

      </MBean>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf31085410,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>

        
<domain>org.apache.cxf</domain>

      </MBean>

   </MBeans>

</MBeanCollection>

 Request:


http://localhost:8080/soapdemo/jmx/type/Bus.Service.Endpoint

Response:
<MBeanCollection>

   <MBeans>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf5663550,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>

        
<domain>org.apache.cxf</domain>

        
<endpointName>Bus.Service.Endpoint</endpointName>

      </MBean>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf5663550,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>

        
<domain>org.apache.cxf</domain>

        
<endpointName>Bus.Service.Endpoint</endpointName>

      </MBean>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf5663550,port="JMXServer",service="{http://server.gsoc.apache.org/}JMXServer",type=Bus.Service.Endpoint</canonicalName>

        
<domain>org.apache.cxf</domain>

        
<endpointName>Bus.Service.Endpoint</endpointName>

      </MBean>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf5663550,port="SoapPort",service="{http://org.apache.gsoc.server/Greeter_Soap}SOAPService",type=Bus.Service.Endpoint</canonicalName>

        
<domain>org.apache.cxf</domain>

        
<endpointName>Bus.Service.Endpoint</endpointName>

      </MBean>

   </MBeans>

</MBeanCollection>

 Request:


http://localhost:8080/soapdemo/jmx/list

Response: (List all mbeans)

<MBeanCollection>

   <MBeans>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf28250063,type=Bus</canonicalName>

        
<domain>org.apache.cxf</domain>

      </MBean>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf28250063,port="CustomerServiceImpl",service="{http://server.gsoc.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>

        
<domain>org.apache.cxf</domain>

      </MBean>

      <MBean>

        
<canonicalName>JMImplementation:type=MBeanServerDelegate</canonicalName>

        
<domain>JMImplementation</domain>

      </MBean>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf28250063,port="SoapPort",service="{http://org.apache.gsoc.server/Greeter_Soap}SOAPService",type=Bus.Service.Endpoint</canonicalName>

        
<domain>org.apache.cxf</domain>

      </MBean>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf28250063,port="JMXServer",service="{http://server.gsoc.apache.org/}JMXServer",type=Bus.Service.Endpoint</canonicalName>

        
<domain>org.apache.cxf</domain>

      </MBean>

      <MBean>

        
<canonicalName>org.apache.cxf:bus.id=cxf28250063,port="UserServiceImpl",service="{http://server.gsoc.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>

        
<domain>org.apache.cxf</domain>

      </MBean>

   </MBeans>

</MBeanCollection>



Cxf3388 background article
>From this url: http://blogs.oracle.com/jmxnetbeans/entry/restful_access_to_jmx_instrumentation1
The author was having the following:

Request:
GET
http://curcuma:9999/rest/jmx/java.lang:type=Memory/HeapMemoryUsage?capture=mysnapshot1



Response:


<ul>
<li>http://curcuma:9999/rest/snapshots/mysnapshot1/jmx/java.lang:type=Memory/NonHeapMemoryUsage/commited</li>
<li>http://curcuma:9999/rest/snapshots/mysnapshot1/jmx/java.lang:type=Memory/NonHeapMemoryUsage/init</li>
<li>http://curcuma:9999/rest/snapshots/mysnapshot1/jmx/java.lang:type=Memory/NonHeapMemoryUsage/max</li>
<li>http://curcuma:9999/rest/snapshots/mysnapshot1/jmx/java.lang:type=Memory/NonHeapMemoryUsage/used</li>
</ul>Which I am now having requests like:

http://localhost:8080/soapdemo/jmx/objectname/org.apache.cxf:type=Bus.Service.Endpoint,*
and
http://localhost:8080/soapdemo/jmx/type/Bus.Service.Endpoint


Both of them are very similar to Cxf3388 background study reference blog/article.


Thank you.

Regards:
Shenglin Qiu




> From: dabaipang@hotmail.com
> To: sberyozkin@gmail.com
> CC: dev@cxf.apache.org
> Subject: RE: Expose MBeans in CXF
> Date: Sun, 15 May 2011 15:44:57 -0400
> 
> 
> Hi Sergey:
> 
> Thank you very much you replied me on weekends!
> I put the comments bellow:
> 
> 1. 
> http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org
> > > What is this query supposed to mean ? Get all Mbeans representing
> > > endpoints whose implementations are in
> > > "impl.service.ws.gsoc.cxf.apache.org" package ?
> 
> If I didn't explicitly define endpointName in service class, the endpointName will be like {http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl, and http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org can search whether there is a match like this String 'impl.service.ws.gsoc.cxf.apache.org' in the endpointName, I know it turns out useless if I didn't do the following right at first:
> 
> > > We need to be able to get the list of MBean *related to* a particular
> > > service name, such as
> > > {http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl.
> > >
> 
> Actually this is where I get stucked, I tried to put request like
> http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl
> But I get 400 error: request not found and here are part of your comments, 
> 
> > >>> Can you please describe what you've done ?
> > >>>
> > >>> > I am actually stopped at this GET request:
> > >>> > I tried:
> > >>> >
> >
>  >>> > 
> http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
> > >>> > And obviously it doesn't work because of the slash in url is not
> > >>> > accepted. (I still didn't find a reasonable answer from searching google,
> > >>> > shocking)
> > >>> >
> > >>> Shenglin, you are obviously very well prepared technically but you
> > >>> need to change the approach and do it asap. Why do you expect Google
> > >>> to tell you why the above URI does not work ?
> > >>>
> > >>> That URI seems too long anyway
> > >>>
> > >>>
> > >>> http://localhost:8080/demoserver/jmx?service={http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
> > >>>
> > >>> Is the max really and in this particular case I'm presuming this query
> > >>> is about getting the list of MBeans reps for a particular managed
> > >>> service. Perhaps in the future we can allocate dynamic subresources
> > >>> instead for handling endpoint specific MBeans to make URIs shorter for
> > >>> this particular case.
> > >>>
> I am still working on it, I think this is the core part of this mission, and from your replies, I can see you want this query to be done correctly as it is in the red line.
> 
> 
> 2.
> > >> <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl"</endpointName>
> > >>       </CxfMBean>
> > >>    </CxfMBeans>
> > >> </CxfMBeanCollection>
> > >>
> > >>
> > >
> > > Please remove "Cxf" prefixes and we also don't need to expose
> > > JaxRsJMXServiceImpl
> 
> Yes, I am removing/modifying it very fast.
> 
> 
> 3. 
> > >>     <!-- This jmxServer should be exposed to jax-rs which should be
> > >> separated from other service endpoints -->
> > >>     <bean id="jmxServer"
> > >> class="org.apache.cxf.gsoc.management.web.JMXServer">
> > >>         <property name="managedJaxRsEndpoints">
> > >>             <list>
> > >>                 <ref bean="userServiceRs"/>
> > >>                 <ref bean="customerServiceRs"/>
> > >>             </list>
> > >>         </property>
> > >>         <property name="managedJaxWsEndpoints">
> > >>             <list>
> > >>                 <ref bean="personService"/>
> > >>             </list>
> > >>         </property>
> > >>         <property name="managedEndpoints">
> > >>             <list>
> > >>
> > >> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl</value>
> > >>
> > >> <value>{http://web.management.gsoc.cxf.apache.org/}JMXServer</value>
> > >>
> > >> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl</value>
> > >>
> > >> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl</value>
> > >>             </list>
> > >>         </property>
> > >>
> > >
> > > You said you've managed to avoid injecting references to individual
> > > managed endpoints, I thought we agree that injecting
> > > InstrumentationManager would be sufficient.
> 
> Yes, actually this part is not necessary:
> > >>         <property name="managedJaxRsEndpoints">
> 
> > >>             <list>
> 
> > >>                 <ref bean="userServiceRs"/>
> 
> > >>                 <ref bean="customerServiceRs"/>
> 
> > >>             </list>
> 
> > >>         </property>
> 
> > >>         <property name="managedJaxWsEndpoints">
> 
> > >>             <list>
> 
> > >>                 <ref bean="personService"/>
> 
> > >>             </list>
> 
> > >>         </property>
> I will remove it very fast, the reason I put here is you have mentioned do things like
> > <bean class="org.apache.cxf.management.web.JMXServer">
> > ? ?<property name="managedEndpoints">
> > ? ? ? ? <list>
> > ? ? ? ? ? ?<value>{http://users.com/rs}UserService</value>
> > ? ? ? ? ? ?<value>{http://users.com/ws}UserService</value>
> > ? ? ? ? </list>
> > ? ?</property>
> > ? ?<property name="manager" ref="instrumentationManager"/>
> > </bean>
> But right now, it looks injecting <property name="manager" ref="instrumentationManager"/> is good enough through my experiment.
> 
> Sorry for putting too much unnecessary stuff which I brought up in the code, I was putting every possible solution/my thoughts up, and my idea is that you could cut anything which you don't need. It literally confused you, my apology.
> 
> The Good thing is, from the dicussion, I need to figure out http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl definitely.
> Although I even didn't thought it's could be an issue, but I know I can't easily go through this mission without any hardcore stuff.
> 
> The ICLA is ready I will email you and secretary in another thread.
> 
> Thank you very much.
> 
> 
> Regards:
> Shenglin Qiu
> 
> 
> 
> > Date: Sun, 15 May 2011 17:46:29 +0100
> > Subject: Re: Expose MBeans in CXF
> > From: sberyozkin@gmail.com
> > To: dabaipang@hotmail.com
> > CC: dev@cxf.apache.org
> > 
> > On Sun, May 15, 2011 at 5:46 PM, Sergey Beryozkin <sb...@gmail.com> wrote:
> > > Hi
> > >
> > > It looks not too bad,  some comments inline...
> > >
> > > On Fri, May 13, 2011 at 5:34 PM, Shenglin Qiu <da...@hotmail.com> wrote:
> > >>
> > >> Hi Sergey:
> > >>
> > >> Here are what I had and although the output maybe simple, I checked outputs
> > >> and they look alright, need your opinions:)
> > >> 1.
> > >> Request URL: this is from searching part of endpoint
> > >> service="{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl"
> > >> http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org
> > >>
> > >
> > > What is this query supposed to mean ? Get all Mbeans representing
> > > endpoints whose implementations are in
> > > "impl.service.ws.gsoc.cxf.apache.org" package ?
> > >
> > >> Response:
> > >> <CxfMBeanCollection>
> > >>    <CxfMBeans>
> > >>       <CxfMBean>
> > >>
> > >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="CustomerServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> > >>          <domain>org.apache.cxf</domain>
> > >>
> > >> <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl"</endpointName>
> > >>       </CxfMBean>
> > >>       <CxfMBean>
> > >>
> > >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="JaxRsJMXServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> > >>          <domain>org.apache.cxf</domain>
> > >>
> > >> <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl"</endpointName>
> > >>       </CxfMBean>
> > >>       <CxfMBean>
> > >>
> > >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="UserServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> > >>          <domain>org.apache.cxf</domain>
> > >>
> > >> <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl"</endpointName>
> > >>       </CxfMBean>
> > >>    </CxfMBeans>
> > >> </CxfMBeanCollection>
> > >>
> > >>
> > >
> > > Please remove "Cxf" prefixes and we also don't need to expose
> > > JaxRsJMXServiceImpl
> > >
> > >>
> > >> 2.
> > >> Request: search port="UserServiceImpl"
> > >> http://localhost:8080/demoserver/jaxserver/jmxserver/port/"UserServiceImpl"
> > >>
> > >> Response:
> > >> <CxfMBean>
> > >>
> > >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="UserServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> > >>    <domain>org.apache.cxf</domain>
> > >>    <endpointName>"UserServiceImpl"</endpointName>
> > >> </CxfMBean>
> > >>
> > >
> > > We need to be able to get the list of MBean *related to* a particular
> > > service name, such as
> > > {http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl.
> > >
> > >>
> > >> 3.
> > >> Request: search by ObjectName("*******")
> > >>
> > >> http://localhost:8080/demoserver/jaxrs3/jmx/component/org.apache.cxf:type=Bus.Service.Endpoint,*
> > >>
> > >> Response:
> > >> <CxfMBeanCollection>
> > >>    <CxfMBeans>
> > >>       <CxfMBean>
> > >>
> > >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="JaxRsJMXServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> > >>          <domain>org.apache.cxf</domain>
> > >>       </CxfMBean>
> > >>       <CxfMBean>
> > >>
> > >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="JMXServer",service="{http://web.management.gsoc.cxf.apache.org/}JMXServer",type=Bus.Service.Endpoint</canonicalName>
> > >>          <domain>org.apache.cxf</domain>
> > >>       </CxfMBean>
> > >>       <CxfMBean>
> > >>
> > >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="CustomerServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> > >>          <domain>org.apache.cxf</domain>
> > >>       </CxfMBean>
> > >>       <CxfMBean>
> > >>
> > >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="UserServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> > >>          <domain>org.apache.cxf</domain>
> > >>       </CxfMBean>
> > >>    </CxfMBeans>
> > >> </CxfMBeanCollection>
> > >>
> > >
> > > OK
> > >>
> > >>
> > >> My current inbound config ():
> > >> <!-- JAX-WS Service Endpoint -->
> > >>     <jaxws:endpoint id="personService" implementor="#personServ"
> > >> address="/PersonService">
> > >>         <jaxws:inInterceptors>
> > >>             <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"
> > >> />
> > >>             <bean
> > >> class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
> > >>                 <constructor-arg>
> > >>                     <map>
> > >>                         <entry key="action" value="UsernameToken" />
> > >>                         <entry key="passwordType" value="PasswordText" />
> > >>                         <entry key="passwordCallbackClass"
> > >> value="org.apache.cxf.gsoc.ws.auth.ServerPasswordCallback" />
> > >>                     </map>
> > >>                 </constructor-arg>
> > >>             </bean>
> > >>         </jaxws:inInterceptors>
> > >>     </jaxws:endpoint>
> > >>
> > >>     <bean id="instrumentationManager"
> > >> class="org.apache.cxf.management.jmx.InstrumentationManagerImpl">
> > >>         <property name="bus" ref="cxf" />
> > >>         <property name="enabled" value="true" />
> > >>         <property name="JMXServiceURL"
> > >> value="service:jmx:rmi:///jndi/rmi://localhost:9914/jmxrmi" />
> > >>     </bean>
> > >>
> > >>     <!-- Wiring the counter repository -->
> > >>     <bean id="counterRepository"
> > >> class="org.apache.cxf.management.counters.CounterRepository">
> > >>         <property name="bus" ref="cxf" />
> > >>     </bean>
> > >>
> > >>     <!-- JAX-RS Server 1 -->
> > >>     <jaxrs:server id="userServiceRs" address="/jaxrs1">
> > >>         <jaxrs:serviceBeans>
> > >>             <ref bean="userService" />
> > >>         </jaxrs:serviceBeans>
> > >>     </jaxrs:server>
> > >>
> > >>     <!-- JAX-RS Server 2 -->
> > >>     <jaxrs:server id="customerServiceRs" address="/jaxrs2">
> > >>         <jaxrs:serviceBeans>
> > >>             <ref bean="customerService" />
> > >>         </jaxrs:serviceBeans>
> > >>     </jaxrs:server>
> > >>
> > >>     <!-- JAX-RS Server 3: This is the old jmx inbound, haven't deleted, but
> > >> will do -->
> > >>     <jaxrs:server id="jmxServiceRs" address="/jaxrs3">
> > >>         <jaxrs:serviceBeans>
> > >>             <ref bean="jmxService" />
> > >>         </jaxrs:serviceBeans>
> > >>     </jaxrs:server>
> > >>
> > >>     <!-- CXF3388: Expose JMXServer: Current testing inbound.-->
> > >>     <jaxrs:server id="jmxServerRs" address="/jaxserver">
> > >>         <jaxrs:serviceBeans>
> > >>             <ref bean="jmxServer" />
> > >>         </jaxrs:serviceBeans>
> > >>     </jaxrs:server>
> > >>
> > >>     <!-- This jmxServer should be exposed to jax-rs which should be
> > >> separated from other service endpoints -->
> > >>     <bean id="jmxServer"
> > >> class="org.apache.cxf.gsoc.management.web.JMXServer">
> > >>         <property name="managedJaxRsEndpoints">
> > >>             <list>
> > >>                 <ref bean="userServiceRs"/>
> > >>                 <ref bean="customerServiceRs"/>
> > >>             </list>
> > >>         </property>
> > >>         <property name="managedJaxWsEndpoints">
> > >>             <list>
> > >>                 <ref bean="personService"/>
> > >>             </list>
> > >>         </property>
> > >>         <property name="managedEndpoints">
> > >>             <list>
> > >>
> > >> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl</value>
> > >>
> > >> <value>{http://web.management.gsoc.cxf.apache.org/}JMXServer</value>
> > >>
> > >> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl</value>
> > >>
> > >> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl</value>
> > >>             </list>
> > >>         </property>
> > >>
> > >
> > > You said you've managed to avoid injecting references to individual
> > > managed endpoints, I thought we agree that injecting
> > > InstrumentationManager would be sufficient.
> > >
> > >>         <property name="instrumentationManager"
> > >> ref="instrumentationManager"/>
> > >>     </bean>
> > >>
> > >>     <bean id="userService"
> > >> class="org.apache.cxf.gsoc.ws.service.impl.UserServiceImpl" />
> > >>     <bean id="customerService"
> > >> class="org.apache.cxf.gsoc.ws.service.impl.CustomerServiceImpl" />
> > >>     <bean id="jmxService"
> > >> class="org.apache.cxf.gsoc.ws.service.impl.JaxRsJMXServiceImpl" />
> > >>
> > >> I am planning to use this weekend, clean this config and code up, and make
> > >> Rest request url shorter as you mentioned. I need your suggestions and
> > >> ideas. and I think I am ready for a big surgery on the demoserver.
> > >
> > > What I'd like to clarify here is that I'm afraid I can't spend a lot
> > > of time on this project and tell you what to do step by step.
> > > I'm happy to help and mentor and I'm trying to provide some feedback
> > > and express some opinion on how things should be implemented.
> > >
> > > But it is your project. Please try to drive it yourself. Review the
> > > JMX/REST related documentation linked from the JIRA, and have some
> > > opinion on how to make sure CXF MBeans can be searched using a number
> > > of queries, so that users could easily get to a collection of Mbeans
> > > or an individual MBean as needed. This is part of the task, make it
> > > easy to get to MBean representations.
> > >
> > > I guess important individual MBeans (those representing
> > > Services/endpoints) should be individually addressed so that we can
> > > say start & stop the service etc. Your server should be able to handle
> > > queries to get the collections of Mbeans but it should probably
> > > provide a subresource locator so that individual MBeans can be asked
> > > to execute certain operations or update the properties.
> > >
> > > JMXServer should keep up to date with the number of available CXF
> > > MBeans - I was suggesting to use CXF-level listeners/registry, but
> > > perhaps a better solution is to register a JMX listener ot query MBean
> > > server for all MBeans in the "org.apache.cxf" domain. That is not
> > > critical now, that can be optimized, but the server should be aware of
> > > all MBeans one way or another.
> > >
> > >
> > > I think you have maximum 2 weeks to make all work well - please keep
> > > focused, provide your opinion on how to proceed, and implement it.
> > > I'll be happy to provide the feedback on the dev list or #cxf.
> > > Then, once you are done, we should consider if we can extend
> > > LogBrowser with the management statisicts or continue improving what
> > > you've already done by then...
> > >
> > > Thanks, Sergey
> > >
> > >> Code is still in https://dabaipang@github.com/dabaipang/demoserver.git
> > >> Also, I will go to supermarket and find a scanner for the NDS
> > >>
> > >> Thank you very much!
> > >>
> > >>
> > >> Regards:
> > >> Shenglin Qiu
> > >>
> > >>
> > >>
> > >>> Date: Fri, 13 May 2011 11:11:51 +0100
> > >>> Subject: Re: Expose MBeans in CXF
> > >>> From: sberyozkin@gmail.com
> > >>> To: dev@cxf.apache.org
> > >>>
> > >>> Hi
> > >>>
> > >>> On Fri, May 13, 2011 at 1:19 AM, Shenglin Qiu <da...@hotmail.com>
> > >>> wrote:
> > >>> >
> > >>> > Hi Sergey:
> > >>> >
> > >>> > Here is the todo list which you have assigned:
> > >>> >
> > >>> > 1. Have one JAX-WS and JAX-RS endpoints
> > >>> > 2. Have your JMXServer as a separate endpoint
> > >>> > 3. Injecting a bus reference and registering a listener
> > >>> >
> > >>> > Your Tips:
> > >>> > 1.
> > >>> > In
> > >>> >  the method where bus is injected, get ServerLifeCycleManager.class
> > >>> > extension from the bus and register your own ServerLifeCycleListener
> > >>> > impl
> > >>> > , it has methods such as startServer and stopServer, in
> > >>> > startServer(Server server) you can do
> > >>> > server.getEndpoint().getService().getQName(),
> > >>> > and keep these QNames
> > >>> > in the local list and have a method say getManagedEndpoints() which will
> > >>> >  return the list of those QNames that will be a good start
> > >>> >
> > >>> > 2.
> > >>> >> <bean class="org.apache.cxf.management.web.JMXServer">
> > >>> >> ? ?<property name="managedEndpoints">
> > >>> >> ? ? ? ? <list>
> > >>> >> ? ? ? ? ? ?<value>{http://users.com/rs}UserService</value>
> > >>> >> ? ? ? ? ? ?<value>{http://users.com/ws}UserService</value>
> > >>> >> ? ? ? ? </list>
> > >>> >> ? ?</property>
> > >>> >> ? ?<property name="manager" ref="instrumentationManager"/>
> > >>> >> </bean>
> > >>> > but ?<property name="managedEndpoints"> can be dropped, you can get this
> > >>> > list from the bus
> > >>> >
> > >>> >
> > >>> > Currently, I have finished on Step 1 and 2, and you have told me that
> > >>> > put step 3 on hold, and make sure JMXServer as a separated enpoint is
> > >>> > correct
> > >>>
> > >>> OK. I don't understand what you've done so far, what decisions have
> > >>> been made to do with making sure that
> > >>> - list of managed endpoints is returned
> > >>> - all MBean representations for all the endpoints are returned,
> > >>> - MBeans related to an individual endpoint are returned
> > >>>
> > >>> Can you please describe what you've done ?
> > >>>
> > >>> > I am actually stopped at this GET request:
> > >>> > I tried:
> > >>> >
> > >>> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
> > >>> > And obviously it doesn't work because of the slash in url is not
> > >>> > accepted. (I still didn't find a reasonable answer from searching google,
> > >>> > shocking)
> > >>> >
> > >>> Shenglin, you are obviously very well prepared technically but you
> > >>> need to change the approach and do it asap. Why do you expect Google
> > >>> to tell you why the above URI does not work ?
> > >>>
> > >>> That URI seems too long anyway
> > >>>
> > >>>
> > >>> http://localhost:8080/demoserver/jmx?service={http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
> > >>>
> > >>> Is the max really and in this particular case I'm presuming this query
> > >>> is about getting the list of MBeans reps for a particular managed
> > >>> service. Perhaps in the future we can allocate dynamic subresources
> > >>> instead for handling endpoint specific MBeans to make URIs shorter for
> > >>> this particular case.
> > >>>
> > >>>
> > >>> >
> > >>> > Then I reserve slash to back slash and got 500 errors:
> > >>> >
> > >>> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http:\\impl.service.ws.gsoc.cxf.apache.org\}CustomerServiceImpl
> > >>> >   => There is a 500 error from CXF
> > >>> > here is the exception stacktrace:
> > >>> >
> > >>> > 2011-05-12
> > >>> > 20:00:48.657:WARN::/demoserver/jaxserver/jmxserver/service/%7Bhttp:%5
> > >>> > C%5Cimpl.service.ws.gsoc.cxf.apache.org%5C%7DCustomerServiceImpl
> > >>> > java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: Unexpected
> > >>> > interna
> > >>> > l error near index 1<|\<| ^
> > >>> >        at
> > >>> > org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMess
> > >>> > age(AbstractFaultChainInitiatorObserver.java:102)
> > >>> >        at
> > >>> > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
> > >>> > orChain.java:303)
> > >>> >        at
> > >>> > org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIniti
> > >>> > ationObserver.java:113)
> > >>> >        at
> > >>> > org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDes
> > >>> > tination.java:97)
> > >>> >        at
> > >>> > org.apache.cxf.transport.servlet.ServletController.invokeDestination(
> > >>> > ServletController.java:458)
> > >>> >        at
> > >>> > org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
> > >>> > roller.java:146)
> > >>> >        at
> > >>> > org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCX
> > >>> > FServlet.java:148)
> > >>> >        at
> > >>> > org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Ab
> > >>> > stractHTTPServlet.java:179)
> > >>> >        at
> > >>> > org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHT
> > >>> > TPServlet.java:108)
> > >>> >        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
> > >>> >        at
> > >>> > org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(Abstract
> > >>> > HTTPServlet.java:159)
> > >>> >        at
> > >>> > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511
> > >>> > )
> > >>> >        at
> > >>> > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3
> > >>> > 90)
> > >>> >        at
> > >>> > org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.jav
> > >>> > a:216)
> > >>> >        at
> > >>> > org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:1
> > >>> > 82)
> > >>> >        at
> > >>> > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:7
> > >>> > 65)
> > >>> >        at
> > >>> > org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
> > >>> >
> > >>> >        at
> > >>> > org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHand
> > >>> > lerCollection.java:230)
> > >>> >        at
> > >>> > org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.
> > >>> > java:114)
> > >>> >        at
> > >>> > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1
> > >>> > 52)
> > >>> >        at org.mortbay.jetty.Server.handle(Server.java:326)
> > >>> >        at
> > >>> > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:54
> > >>> > 2)
> > >>> >        at
> > >>> > org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpCo
> > >>> > nnection.java:926)
> > >>> >        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
> > >>> >        at
> > >>> > org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
> > >>> >        at
> > >>> > org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
> > >>> >        at
> > >>> > org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.ja
> > >>> > va:410)
> > >>> >        at
> > >>> > org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.j
> > >>> > ava:582)
> > >>> >
> > >>> >
> > >>> > Any suggestions?
> > >>>
> > >>> Please understand how CXF JAX-RS handles requests, don't try changing
> > >>> "/" to "\\" and hope it will work
> > >>>
> > >>> >
> > >>> > Currently I can do the following:
> > >>> >
> > >>> > http://localhost:8080/demoserver/jaxrs3/jmx/component/org.apache.cxf:type=Bus.Service.Endpoint,*
> > >>> >       => get Mbean by ObjectName query
> > >>>
> > >>> What is "/jaxrs3" ? Are you really sure your JMXServer endpoint is
> > >>> separate ?
> > >>>
> > >>> > http://localhost:8080/demoserver/jaxserver/jmxserver/list
> > >>> >                                                       => get all Mbeans by
> > >>> > ObjectName('*:type=*,*')  which query is *:type=*,*
> > >>>
> > >>> should be just
> > >>>
> > >>> http://localhost:8080/demoserver/jmx/list
> > >>>
> > >>> >
> > >>> > http://localhost:8080/demoserver/jaxserver/jmxserver/type/Bus.Service.Endpoint
> > >>> >                                     => get Mbean by type
> > >>> >
> > >>> > http://localhost:8080/demoserver/jaxserver/jmxserver/port/%22UserServiceImpl%22
> > >>> >                               => get Mbean by service, %22 is an issue which
> > >>> > I can't get rid of it, still working on it.
> > >>> >
> > >>> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org
> > >>> >            => get Mbean by part of service such as
> > >>> > {http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl ->
> > >>> >
> > >>> >
> > >>> >         impl.service.ws.gsoc.cxf.apache.org
> > >>> >
> > >>> /demoserver/jaxserver/jmxserver/type/
> > >>> or
> > >>> /demoserver/jaxserver/jmxserver/port/
> > >>>
> > >>> is just too long
> > >>>
> > >>> /demoserver/jmx?mbean=somembeanname
> > >>>
> > >>> would probably do; well perhaps, introducing some "types" into URIs
> > >>> like /type/, /port/, etc, may also may make sense, but lets make sure
> > >>> we have a simple and straightforward approach for getting the list of
> > >>> all sorts of MBean representation
> > >>>
> > >>>
> > >>> Thanks, Sergey
> > >>> >
> > >>> > Thank you.
> > >>> >
> > >>> > Regards:
> > >>> > Shenglin Qiu
> > >>> >
> > >>
> > >
> > 
> > 
> > 
> > -- 
> > Sergey Beryozkin
> > 
> > Application Integration Division of Talend
> > http://sberyozkin.blogspot.com
>  		 	   		  
 		 	   		  

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi Sergey:

Thank you very much you replied me on weekends!
I put the comments bellow:

1. 
http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org
> > What is this query supposed to mean ? Get all Mbeans representing
> > endpoints whose implementations are in
> > "impl.service.ws.gsoc.cxf.apache.org" package ?

If I didn't explicitly define endpointName in service class, the endpointName will be like {http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl, and http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org can search whether there is a match like this String 'impl.service.ws.gsoc.cxf.apache.org' in the endpointName, I know it turns out useless if I didn't do the following right at first:

> > We need to be able to get the list of MBean *related to* a particular
> > service name, such as
> > {http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl.
> >

Actually this is where I get stucked, I tried to put request like
http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl
But I get 400 error: request not found and here are part of your comments, 

> >>> Can you please describe what you've done ?
> >>>
> >>> > I am actually stopped at this GET request:
> >>> > I tried:
> >>> >
>
 >>> > 
http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
> >>> > And obviously it doesn't work because of the slash in url is not
> >>> > accepted. (I still didn't find a reasonable answer from searching google,
> >>> > shocking)
> >>> >
> >>> Shenglin, you are obviously very well prepared technically but you
> >>> need to change the approach and do it asap. Why do you expect Google
> >>> to tell you why the above URI does not work ?
> >>>
> >>> That URI seems too long anyway
> >>>
> >>>
> >>> http://localhost:8080/demoserver/jmx?service={http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
> >>>
> >>> Is the max really and in this particular case I'm presuming this query
> >>> is about getting the list of MBeans reps for a particular managed
> >>> service. Perhaps in the future we can allocate dynamic subresources
> >>> instead for handling endpoint specific MBeans to make URIs shorter for
> >>> this particular case.
> >>>
I am still working on it, I think this is the core part of this mission, and from your replies, I can see you want this query to be done correctly as it is in the red line.


2.
> >> <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl"</endpointName>
> >>       </CxfMBean>
> >>    </CxfMBeans>
> >> </CxfMBeanCollection>
> >>
> >>
> >
> > Please remove "Cxf" prefixes and we also don't need to expose
> > JaxRsJMXServiceImpl

Yes, I am removing/modifying it very fast.


3. 
> >>     <!-- This jmxServer should be exposed to jax-rs which should be
> >> separated from other service endpoints -->
> >>     <bean id="jmxServer"
> >> class="org.apache.cxf.gsoc.management.web.JMXServer">
> >>         <property name="managedJaxRsEndpoints">
> >>             <list>
> >>                 <ref bean="userServiceRs"/>
> >>                 <ref bean="customerServiceRs"/>
> >>             </list>
> >>         </property>
> >>         <property name="managedJaxWsEndpoints">
> >>             <list>
> >>                 <ref bean="personService"/>
> >>             </list>
> >>         </property>
> >>         <property name="managedEndpoints">
> >>             <list>
> >>
> >> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl</value>
> >>
> >> <value>{http://web.management.gsoc.cxf.apache.org/}JMXServer</value>
> >>
> >> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl</value>
> >>
> >> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl</value>
> >>             </list>
> >>         </property>
> >>
> >
> > You said you've managed to avoid injecting references to individual
> > managed endpoints, I thought we agree that injecting
> > InstrumentationManager would be sufficient.

Yes, actually this part is not necessary:
> >>         <property name="managedJaxRsEndpoints">

> >>             <list>

> >>                 <ref bean="userServiceRs"/>

> >>                 <ref bean="customerServiceRs"/>

> >>             </list>

> >>         </property>

> >>         <property name="managedJaxWsEndpoints">

> >>             <list>

> >>                 <ref bean="personService"/>

> >>             </list>

> >>         </property>
I will remove it very fast, the reason I put here is you have mentioned do things like
> <bean class="org.apache.cxf.management.web.JMXServer">
> ? ?<property name="managedEndpoints">
> ? ? ? ? <list>
> ? ? ? ? ? ?<value>{http://users.com/rs}UserService</value>
> ? ? ? ? ? ?<value>{http://users.com/ws}UserService</value>
> ? ? ? ? </list>
> ? ?</property>
> ? ?<property name="manager" ref="instrumentationManager"/>
> </bean>
But right now, it looks injecting <property name="manager" ref="instrumentationManager"/> is good enough through my experiment.

Sorry for putting too much unnecessary stuff which I brought up in the code, I was putting every possible solution/my thoughts up, and my idea is that you could cut anything which you don't need. It literally confused you, my apology.

The Good thing is, from the dicussion, I need to figure out http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl definitely.
Although I even didn't thought it's could be an issue, but I know I can't easily go through this mission without any hardcore stuff.

The ICLA is ready I will email you and secretary in another thread.

Thank you very much.


Regards:
Shenglin Qiu



> Date: Sun, 15 May 2011 17:46:29 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dabaipang@hotmail.com
> CC: dev@cxf.apache.org
> 
> On Sun, May 15, 2011 at 5:46 PM, Sergey Beryozkin <sb...@gmail.com> wrote:
> > Hi
> >
> > It looks not too bad,  some comments inline...
> >
> > On Fri, May 13, 2011 at 5:34 PM, Shenglin Qiu <da...@hotmail.com> wrote:
> >>
> >> Hi Sergey:
> >>
> >> Here are what I had and although the output maybe simple, I checked outputs
> >> and they look alright, need your opinions:)
> >> 1.
> >> Request URL: this is from searching part of endpoint
> >> service="{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl"
> >> http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org
> >>
> >
> > What is this query supposed to mean ? Get all Mbeans representing
> > endpoints whose implementations are in
> > "impl.service.ws.gsoc.cxf.apache.org" package ?
> >
> >> Response:
> >> <CxfMBeanCollection>
> >>    <CxfMBeans>
> >>       <CxfMBean>
> >>
> >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="CustomerServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> >>          <domain>org.apache.cxf</domain>
> >>
> >> <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl"</endpointName>
> >>       </CxfMBean>
> >>       <CxfMBean>
> >>
> >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="JaxRsJMXServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> >>          <domain>org.apache.cxf</domain>
> >>
> >> <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl"</endpointName>
> >>       </CxfMBean>
> >>       <CxfMBean>
> >>
> >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="UserServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> >>          <domain>org.apache.cxf</domain>
> >>
> >> <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl"</endpointName>
> >>       </CxfMBean>
> >>    </CxfMBeans>
> >> </CxfMBeanCollection>
> >>
> >>
> >
> > Please remove "Cxf" prefixes and we also don't need to expose
> > JaxRsJMXServiceImpl
> >
> >>
> >> 2.
> >> Request: search port="UserServiceImpl"
> >> http://localhost:8080/demoserver/jaxserver/jmxserver/port/"UserServiceImpl"
> >>
> >> Response:
> >> <CxfMBean>
> >>
> >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="UserServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> >>    <domain>org.apache.cxf</domain>
> >>    <endpointName>"UserServiceImpl"</endpointName>
> >> </CxfMBean>
> >>
> >
> > We need to be able to get the list of MBean *related to* a particular
> > service name, such as
> > {http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl.
> >
> >>
> >> 3.
> >> Request: search by ObjectName("*******")
> >>
> >> http://localhost:8080/demoserver/jaxrs3/jmx/component/org.apache.cxf:type=Bus.Service.Endpoint,*
> >>
> >> Response:
> >> <CxfMBeanCollection>
> >>    <CxfMBeans>
> >>       <CxfMBean>
> >>
> >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="JaxRsJMXServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> >>          <domain>org.apache.cxf</domain>
> >>       </CxfMBean>
> >>       <CxfMBean>
> >>
> >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="JMXServer",service="{http://web.management.gsoc.cxf.apache.org/}JMXServer",type=Bus.Service.Endpoint</canonicalName>
> >>          <domain>org.apache.cxf</domain>
> >>       </CxfMBean>
> >>       <CxfMBean>
> >>
> >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="CustomerServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> >>          <domain>org.apache.cxf</domain>
> >>       </CxfMBean>
> >>       <CxfMBean>
> >>
> >> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="UserServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
> >>          <domain>org.apache.cxf</domain>
> >>       </CxfMBean>
> >>    </CxfMBeans>
> >> </CxfMBeanCollection>
> >>
> >
> > OK
> >>
> >>
> >> My current inbound config ():
> >> <!-- JAX-WS Service Endpoint -->
> >>     <jaxws:endpoint id="personService" implementor="#personServ"
> >> address="/PersonService">
> >>         <jaxws:inInterceptors>
> >>             <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"
> >> />
> >>             <bean
> >> class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
> >>                 <constructor-arg>
> >>                     <map>
> >>                         <entry key="action" value="UsernameToken" />
> >>                         <entry key="passwordType" value="PasswordText" />
> >>                         <entry key="passwordCallbackClass"
> >> value="org.apache.cxf.gsoc.ws.auth.ServerPasswordCallback" />
> >>                     </map>
> >>                 </constructor-arg>
> >>             </bean>
> >>         </jaxws:inInterceptors>
> >>     </jaxws:endpoint>
> >>
> >>     <bean id="instrumentationManager"
> >> class="org.apache.cxf.management.jmx.InstrumentationManagerImpl">
> >>         <property name="bus" ref="cxf" />
> >>         <property name="enabled" value="true" />
> >>         <property name="JMXServiceURL"
> >> value="service:jmx:rmi:///jndi/rmi://localhost:9914/jmxrmi" />
> >>     </bean>
> >>
> >>     <!-- Wiring the counter repository -->
> >>     <bean id="counterRepository"
> >> class="org.apache.cxf.management.counters.CounterRepository">
> >>         <property name="bus" ref="cxf" />
> >>     </bean>
> >>
> >>     <!-- JAX-RS Server 1 -->
> >>     <jaxrs:server id="userServiceRs" address="/jaxrs1">
> >>         <jaxrs:serviceBeans>
> >>             <ref bean="userService" />
> >>         </jaxrs:serviceBeans>
> >>     </jaxrs:server>
> >>
> >>     <!-- JAX-RS Server 2 -->
> >>     <jaxrs:server id="customerServiceRs" address="/jaxrs2">
> >>         <jaxrs:serviceBeans>
> >>             <ref bean="customerService" />
> >>         </jaxrs:serviceBeans>
> >>     </jaxrs:server>
> >>
> >>     <!-- JAX-RS Server 3: This is the old jmx inbound, haven't deleted, but
> >> will do -->
> >>     <jaxrs:server id="jmxServiceRs" address="/jaxrs3">
> >>         <jaxrs:serviceBeans>
> >>             <ref bean="jmxService" />
> >>         </jaxrs:serviceBeans>
> >>     </jaxrs:server>
> >>
> >>     <!-- CXF3388: Expose JMXServer: Current testing inbound.-->
> >>     <jaxrs:server id="jmxServerRs" address="/jaxserver">
> >>         <jaxrs:serviceBeans>
> >>             <ref bean="jmxServer" />
> >>         </jaxrs:serviceBeans>
> >>     </jaxrs:server>
> >>
> >>     <!-- This jmxServer should be exposed to jax-rs which should be
> >> separated from other service endpoints -->
> >>     <bean id="jmxServer"
> >> class="org.apache.cxf.gsoc.management.web.JMXServer">
> >>         <property name="managedJaxRsEndpoints">
> >>             <list>
> >>                 <ref bean="userServiceRs"/>
> >>                 <ref bean="customerServiceRs"/>
> >>             </list>
> >>         </property>
> >>         <property name="managedJaxWsEndpoints">
> >>             <list>
> >>                 <ref bean="personService"/>
> >>             </list>
> >>         </property>
> >>         <property name="managedEndpoints">
> >>             <list>
> >>
> >> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl</value>
> >>
> >> <value>{http://web.management.gsoc.cxf.apache.org/}JMXServer</value>
> >>
> >> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl</value>
> >>
> >> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl</value>
> >>             </list>
> >>         </property>
> >>
> >
> > You said you've managed to avoid injecting references to individual
> > managed endpoints, I thought we agree that injecting
> > InstrumentationManager would be sufficient.
> >
> >>         <property name="instrumentationManager"
> >> ref="instrumentationManager"/>
> >>     </bean>
> >>
> >>     <bean id="userService"
> >> class="org.apache.cxf.gsoc.ws.service.impl.UserServiceImpl" />
> >>     <bean id="customerService"
> >> class="org.apache.cxf.gsoc.ws.service.impl.CustomerServiceImpl" />
> >>     <bean id="jmxService"
> >> class="org.apache.cxf.gsoc.ws.service.impl.JaxRsJMXServiceImpl" />
> >>
> >> I am planning to use this weekend, clean this config and code up, and make
> >> Rest request url shorter as you mentioned. I need your suggestions and
> >> ideas. and I think I am ready for a big surgery on the demoserver.
> >
> > What I'd like to clarify here is that I'm afraid I can't spend a lot
> > of time on this project and tell you what to do step by step.
> > I'm happy to help and mentor and I'm trying to provide some feedback
> > and express some opinion on how things should be implemented.
> >
> > But it is your project. Please try to drive it yourself. Review the
> > JMX/REST related documentation linked from the JIRA, and have some
> > opinion on how to make sure CXF MBeans can be searched using a number
> > of queries, so that users could easily get to a collection of Mbeans
> > or an individual MBean as needed. This is part of the task, make it
> > easy to get to MBean representations.
> >
> > I guess important individual MBeans (those representing
> > Services/endpoints) should be individually addressed so that we can
> > say start & stop the service etc. Your server should be able to handle
> > queries to get the collections of Mbeans but it should probably
> > provide a subresource locator so that individual MBeans can be asked
> > to execute certain operations or update the properties.
> >
> > JMXServer should keep up to date with the number of available CXF
> > MBeans - I was suggesting to use CXF-level listeners/registry, but
> > perhaps a better solution is to register a JMX listener ot query MBean
> > server for all MBeans in the "org.apache.cxf" domain. That is not
> > critical now, that can be optimized, but the server should be aware of
> > all MBeans one way or another.
> >
> >
> > I think you have maximum 2 weeks to make all work well - please keep
> > focused, provide your opinion on how to proceed, and implement it.
> > I'll be happy to provide the feedback on the dev list or #cxf.
> > Then, once you are done, we should consider if we can extend
> > LogBrowser with the management statisicts or continue improving what
> > you've already done by then...
> >
> > Thanks, Sergey
> >
> >> Code is still in https://dabaipang@github.com/dabaipang/demoserver.git
> >> Also, I will go to supermarket and find a scanner for the NDS
> >>
> >> Thank you very much!
> >>
> >>
> >> Regards:
> >> Shenglin Qiu
> >>
> >>
> >>
> >>> Date: Fri, 13 May 2011 11:11:51 +0100
> >>> Subject: Re: Expose MBeans in CXF
> >>> From: sberyozkin@gmail.com
> >>> To: dev@cxf.apache.org
> >>>
> >>> Hi
> >>>
> >>> On Fri, May 13, 2011 at 1:19 AM, Shenglin Qiu <da...@hotmail.com>
> >>> wrote:
> >>> >
> >>> > Hi Sergey:
> >>> >
> >>> > Here is the todo list which you have assigned:
> >>> >
> >>> > 1. Have one JAX-WS and JAX-RS endpoints
> >>> > 2. Have your JMXServer as a separate endpoint
> >>> > 3. Injecting a bus reference and registering a listener
> >>> >
> >>> > Your Tips:
> >>> > 1.
> >>> > In
> >>> >  the method where bus is injected, get ServerLifeCycleManager.class
> >>> > extension from the bus and register your own ServerLifeCycleListener
> >>> > impl
> >>> > , it has methods such as startServer and stopServer, in
> >>> > startServer(Server server) you can do
> >>> > server.getEndpoint().getService().getQName(),
> >>> > and keep these QNames
> >>> > in the local list and have a method say getManagedEndpoints() which will
> >>> >  return the list of those QNames that will be a good start
> >>> >
> >>> > 2.
> >>> >> <bean class="org.apache.cxf.management.web.JMXServer">
> >>> >> ? ?<property name="managedEndpoints">
> >>> >> ? ? ? ? <list>
> >>> >> ? ? ? ? ? ?<value>{http://users.com/rs}UserService</value>
> >>> >> ? ? ? ? ? ?<value>{http://users.com/ws}UserService</value>
> >>> >> ? ? ? ? </list>
> >>> >> ? ?</property>
> >>> >> ? ?<property name="manager" ref="instrumentationManager"/>
> >>> >> </bean>
> >>> > but ?<property name="managedEndpoints"> can be dropped, you can get this
> >>> > list from the bus
> >>> >
> >>> >
> >>> > Currently, I have finished on Step 1 and 2, and you have told me that
> >>> > put step 3 on hold, and make sure JMXServer as a separated enpoint is
> >>> > correct
> >>>
> >>> OK. I don't understand what you've done so far, what decisions have
> >>> been made to do with making sure that
> >>> - list of managed endpoints is returned
> >>> - all MBean representations for all the endpoints are returned,
> >>> - MBeans related to an individual endpoint are returned
> >>>
> >>> Can you please describe what you've done ?
> >>>
> >>> > I am actually stopped at this GET request:
> >>> > I tried:
> >>> >
> >>> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
> >>> > And obviously it doesn't work because of the slash in url is not
> >>> > accepted. (I still didn't find a reasonable answer from searching google,
> >>> > shocking)
> >>> >
> >>> Shenglin, you are obviously very well prepared technically but you
> >>> need to change the approach and do it asap. Why do you expect Google
> >>> to tell you why the above URI does not work ?
> >>>
> >>> That URI seems too long anyway
> >>>
> >>>
> >>> http://localhost:8080/demoserver/jmx?service={http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
> >>>
> >>> Is the max really and in this particular case I'm presuming this query
> >>> is about getting the list of MBeans reps for a particular managed
> >>> service. Perhaps in the future we can allocate dynamic subresources
> >>> instead for handling endpoint specific MBeans to make URIs shorter for
> >>> this particular case.
> >>>
> >>>
> >>> >
> >>> > Then I reserve slash to back slash and got 500 errors:
> >>> >
> >>> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http:\\impl.service.ws.gsoc.cxf.apache.org\}CustomerServiceImpl
> >>> >   => There is a 500 error from CXF
> >>> > here is the exception stacktrace:
> >>> >
> >>> > 2011-05-12
> >>> > 20:00:48.657:WARN::/demoserver/jaxserver/jmxserver/service/%7Bhttp:%5
> >>> > C%5Cimpl.service.ws.gsoc.cxf.apache.org%5C%7DCustomerServiceImpl
> >>> > java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: Unexpected
> >>> > interna
> >>> > l error near index 1<|\<| ^
> >>> >        at
> >>> > org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMess
> >>> > age(AbstractFaultChainInitiatorObserver.java:102)
> >>> >        at
> >>> > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
> >>> > orChain.java:303)
> >>> >        at
> >>> > org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIniti
> >>> > ationObserver.java:113)
> >>> >        at
> >>> > org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDes
> >>> > tination.java:97)
> >>> >        at
> >>> > org.apache.cxf.transport.servlet.ServletController.invokeDestination(
> >>> > ServletController.java:458)
> >>> >        at
> >>> > org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
> >>> > roller.java:146)
> >>> >        at
> >>> > org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCX
> >>> > FServlet.java:148)
> >>> >        at
> >>> > org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Ab
> >>> > stractHTTPServlet.java:179)
> >>> >        at
> >>> > org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHT
> >>> > TPServlet.java:108)
> >>> >        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
> >>> >        at
> >>> > org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(Abstract
> >>> > HTTPServlet.java:159)
> >>> >        at
> >>> > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511
> >>> > )
> >>> >        at
> >>> > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3
> >>> > 90)
> >>> >        at
> >>> > org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.jav
> >>> > a:216)
> >>> >        at
> >>> > org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:1
> >>> > 82)
> >>> >        at
> >>> > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:7
> >>> > 65)
> >>> >        at
> >>> > org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
> >>> >
> >>> >        at
> >>> > org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHand
> >>> > lerCollection.java:230)
> >>> >        at
> >>> > org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.
> >>> > java:114)
> >>> >        at
> >>> > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1
> >>> > 52)
> >>> >        at org.mortbay.jetty.Server.handle(Server.java:326)
> >>> >        at
> >>> > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:54
> >>> > 2)
> >>> >        at
> >>> > org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpCo
> >>> > nnection.java:926)
> >>> >        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
> >>> >        at
> >>> > org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
> >>> >        at
> >>> > org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
> >>> >        at
> >>> > org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.ja
> >>> > va:410)
> >>> >        at
> >>> > org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.j
> >>> > ava:582)
> >>> >
> >>> >
> >>> > Any suggestions?
> >>>
> >>> Please understand how CXF JAX-RS handles requests, don't try changing
> >>> "/" to "\\" and hope it will work
> >>>
> >>> >
> >>> > Currently I can do the following:
> >>> >
> >>> > http://localhost:8080/demoserver/jaxrs3/jmx/component/org.apache.cxf:type=Bus.Service.Endpoint,*
> >>> >       => get Mbean by ObjectName query
> >>>
> >>> What is "/jaxrs3" ? Are you really sure your JMXServer endpoint is
> >>> separate ?
> >>>
> >>> > http://localhost:8080/demoserver/jaxserver/jmxserver/list
> >>> >                                                       => get all Mbeans by
> >>> > ObjectName('*:type=*,*')  which query is *:type=*,*
> >>>
> >>> should be just
> >>>
> >>> http://localhost:8080/demoserver/jmx/list
> >>>
> >>> >
> >>> > http://localhost:8080/demoserver/jaxserver/jmxserver/type/Bus.Service.Endpoint
> >>> >                                     => get Mbean by type
> >>> >
> >>> > http://localhost:8080/demoserver/jaxserver/jmxserver/port/%22UserServiceImpl%22
> >>> >                               => get Mbean by service, %22 is an issue which
> >>> > I can't get rid of it, still working on it.
> >>> >
> >>> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org
> >>> >            => get Mbean by part of service such as
> >>> > {http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl ->
> >>> >
> >>> >
> >>> >         impl.service.ws.gsoc.cxf.apache.org
> >>> >
> >>> /demoserver/jaxserver/jmxserver/type/
> >>> or
> >>> /demoserver/jaxserver/jmxserver/port/
> >>>
> >>> is just too long
> >>>
> >>> /demoserver/jmx?mbean=somembeanname
> >>>
> >>> would probably do; well perhaps, introducing some "types" into URIs
> >>> like /type/, /port/, etc, may also may make sense, but lets make sure
> >>> we have a simple and straightforward approach for getting the list of
> >>> all sorts of MBean representation
> >>>
> >>>
> >>> Thanks, Sergey
> >>> >
> >>> > Thank you.
> >>> >
> >>> > Regards:
> >>> > Shenglin Qiu
> >>> >
> >>
> >
> 
> 
> 
> -- 
> Sergey Beryozkin
> 
> Application Integration Division of Talend
> http://sberyozkin.blogspot.com
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
On Sun, May 15, 2011 at 5:46 PM, Sergey Beryozkin <sb...@gmail.com> wrote:
> Hi
>
> It looks not too bad,  some comments inline...
>
> On Fri, May 13, 2011 at 5:34 PM, Shenglin Qiu <da...@hotmail.com> wrote:
>>
>> Hi Sergey:
>>
>> Here are what I had and although the output maybe simple, I checked outputs
>> and they look alright, need your opinions:)
>> 1.
>> Request URL: this is from searching part of endpoint
>> service="{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl"
>> http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org
>>
>
> What is this query supposed to mean ? Get all Mbeans representing
> endpoints whose implementations are in
> "impl.service.ws.gsoc.cxf.apache.org" package ?
>
>> Response:
>> <CxfMBeanCollection>
>>    <CxfMBeans>
>>       <CxfMBean>
>>
>> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="CustomerServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
>>          <domain>org.apache.cxf</domain>
>>
>> <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl"</endpointName>
>>       </CxfMBean>
>>       <CxfMBean>
>>
>> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="JaxRsJMXServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl",type=Bus.Service.Endpoint</canonicalName>
>>          <domain>org.apache.cxf</domain>
>>
>> <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl"</endpointName>
>>       </CxfMBean>
>>       <CxfMBean>
>>
>> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="UserServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
>>          <domain>org.apache.cxf</domain>
>>
>> <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl"</endpointName>
>>       </CxfMBean>
>>    </CxfMBeans>
>> </CxfMBeanCollection>
>>
>>
>
> Please remove "Cxf" prefixes and we also don't need to expose
> JaxRsJMXServiceImpl
>
>>
>> 2.
>> Request: search port="UserServiceImpl"
>> http://localhost:8080/demoserver/jaxserver/jmxserver/port/"UserServiceImpl"
>>
>> Response:
>> <CxfMBean>
>>
>> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="UserServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
>>    <domain>org.apache.cxf</domain>
>>    <endpointName>"UserServiceImpl"</endpointName>
>> </CxfMBean>
>>
>
> We need to be able to get the list of MBean *related to* a particular
> service name, such as
> {http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl.
>
>>
>> 3.
>> Request: search by ObjectName("*******")
>>
>> http://localhost:8080/demoserver/jaxrs3/jmx/component/org.apache.cxf:type=Bus.Service.Endpoint,*
>>
>> Response:
>> <CxfMBeanCollection>
>>    <CxfMBeans>
>>       <CxfMBean>
>>
>> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="JaxRsJMXServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl",type=Bus.Service.Endpoint</canonicalName>
>>          <domain>org.apache.cxf</domain>
>>       </CxfMBean>
>>       <CxfMBean>
>>
>> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="JMXServer",service="{http://web.management.gsoc.cxf.apache.org/}JMXServer",type=Bus.Service.Endpoint</canonicalName>
>>          <domain>org.apache.cxf</domain>
>>       </CxfMBean>
>>       <CxfMBean>
>>
>> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="CustomerServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
>>          <domain>org.apache.cxf</domain>
>>       </CxfMBean>
>>       <CxfMBean>
>>
>> <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="UserServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
>>          <domain>org.apache.cxf</domain>
>>       </CxfMBean>
>>    </CxfMBeans>
>> </CxfMBeanCollection>
>>
>
> OK
>>
>>
>> My current inbound config ():
>> <!-- JAX-WS Service Endpoint -->
>>     <jaxws:endpoint id="personService" implementor="#personServ"
>> address="/PersonService">
>>         <jaxws:inInterceptors>
>>             <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"
>> />
>>             <bean
>> class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
>>                 <constructor-arg>
>>                     <map>
>>                         <entry key="action" value="UsernameToken" />
>>                         <entry key="passwordType" value="PasswordText" />
>>                         <entry key="passwordCallbackClass"
>> value="org.apache.cxf.gsoc.ws.auth.ServerPasswordCallback" />
>>                     </map>
>>                 </constructor-arg>
>>             </bean>
>>         </jaxws:inInterceptors>
>>     </jaxws:endpoint>
>>
>>     <bean id="instrumentationManager"
>> class="org.apache.cxf.management.jmx.InstrumentationManagerImpl">
>>         <property name="bus" ref="cxf" />
>>         <property name="enabled" value="true" />
>>         <property name="JMXServiceURL"
>> value="service:jmx:rmi:///jndi/rmi://localhost:9914/jmxrmi" />
>>     </bean>
>>
>>     <!-- Wiring the counter repository -->
>>     <bean id="counterRepository"
>> class="org.apache.cxf.management.counters.CounterRepository">
>>         <property name="bus" ref="cxf" />
>>     </bean>
>>
>>     <!-- JAX-RS Server 1 -->
>>     <jaxrs:server id="userServiceRs" address="/jaxrs1">
>>         <jaxrs:serviceBeans>
>>             <ref bean="userService" />
>>         </jaxrs:serviceBeans>
>>     </jaxrs:server>
>>
>>     <!-- JAX-RS Server 2 -->
>>     <jaxrs:server id="customerServiceRs" address="/jaxrs2">
>>         <jaxrs:serviceBeans>
>>             <ref bean="customerService" />
>>         </jaxrs:serviceBeans>
>>     </jaxrs:server>
>>
>>     <!-- JAX-RS Server 3: This is the old jmx inbound, haven't deleted, but
>> will do -->
>>     <jaxrs:server id="jmxServiceRs" address="/jaxrs3">
>>         <jaxrs:serviceBeans>
>>             <ref bean="jmxService" />
>>         </jaxrs:serviceBeans>
>>     </jaxrs:server>
>>
>>     <!-- CXF3388: Expose JMXServer: Current testing inbound.-->
>>     <jaxrs:server id="jmxServerRs" address="/jaxserver">
>>         <jaxrs:serviceBeans>
>>             <ref bean="jmxServer" />
>>         </jaxrs:serviceBeans>
>>     </jaxrs:server>
>>
>>     <!-- This jmxServer should be exposed to jax-rs which should be
>> separated from other service endpoints -->
>>     <bean id="jmxServer"
>> class="org.apache.cxf.gsoc.management.web.JMXServer">
>>         <property name="managedJaxRsEndpoints">
>>             <list>
>>                 <ref bean="userServiceRs"/>
>>                 <ref bean="customerServiceRs"/>
>>             </list>
>>         </property>
>>         <property name="managedJaxWsEndpoints">
>>             <list>
>>                 <ref bean="personService"/>
>>             </list>
>>         </property>
>>         <property name="managedEndpoints">
>>             <list>
>>
>> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl</value>
>>
>> <value>{http://web.management.gsoc.cxf.apache.org/}JMXServer</value>
>>
>> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl</value>
>>
>> <value>{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl</value>
>>             </list>
>>         </property>
>>
>
> You said you've managed to avoid injecting references to individual
> managed endpoints, I thought we agree that injecting
> InstrumentationManager would be sufficient.
>
>>         <property name="instrumentationManager"
>> ref="instrumentationManager"/>
>>     </bean>
>>
>>     <bean id="userService"
>> class="org.apache.cxf.gsoc.ws.service.impl.UserServiceImpl" />
>>     <bean id="customerService"
>> class="org.apache.cxf.gsoc.ws.service.impl.CustomerServiceImpl" />
>>     <bean id="jmxService"
>> class="org.apache.cxf.gsoc.ws.service.impl.JaxRsJMXServiceImpl" />
>>
>> I am planning to use this weekend, clean this config and code up, and make
>> Rest request url shorter as you mentioned. I need your suggestions and
>> ideas. and I think I am ready for a big surgery on the demoserver.
>
> What I'd like to clarify here is that I'm afraid I can't spend a lot
> of time on this project and tell you what to do step by step.
> I'm happy to help and mentor and I'm trying to provide some feedback
> and express some opinion on how things should be implemented.
>
> But it is your project. Please try to drive it yourself. Review the
> JMX/REST related documentation linked from the JIRA, and have some
> opinion on how to make sure CXF MBeans can be searched using a number
> of queries, so that users could easily get to a collection of Mbeans
> or an individual MBean as needed. This is part of the task, make it
> easy to get to MBean representations.
>
> I guess important individual MBeans (those representing
> Services/endpoints) should be individually addressed so that we can
> say start & stop the service etc. Your server should be able to handle
> queries to get the collections of Mbeans but it should probably
> provide a subresource locator so that individual MBeans can be asked
> to execute certain operations or update the properties.
>
> JMXServer should keep up to date with the number of available CXF
> MBeans - I was suggesting to use CXF-level listeners/registry, but
> perhaps a better solution is to register a JMX listener ot query MBean
> server for all MBeans in the "org.apache.cxf" domain. That is not
> critical now, that can be optimized, but the server should be aware of
> all MBeans one way or another.
>
>
> I think you have maximum 2 weeks to make all work well - please keep
> focused, provide your opinion on how to proceed, and implement it.
> I'll be happy to provide the feedback on the dev list or #cxf.
> Then, once you are done, we should consider if we can extend
> LogBrowser with the management statisicts or continue improving what
> you've already done by then...
>
> Thanks, Sergey
>
>> Code is still in https://dabaipang@github.com/dabaipang/demoserver.git
>> Also, I will go to supermarket and find a scanner for the NDS
>>
>> Thank you very much!
>>
>>
>> Regards:
>> Shenglin Qiu
>>
>>
>>
>>> Date: Fri, 13 May 2011 11:11:51 +0100
>>> Subject: Re: Expose MBeans in CXF
>>> From: sberyozkin@gmail.com
>>> To: dev@cxf.apache.org
>>>
>>> Hi
>>>
>>> On Fri, May 13, 2011 at 1:19 AM, Shenglin Qiu <da...@hotmail.com>
>>> wrote:
>>> >
>>> > Hi Sergey:
>>> >
>>> > Here is the todo list which you have assigned:
>>> >
>>> > 1. Have one JAX-WS and JAX-RS endpoints
>>> > 2. Have your JMXServer as a separate endpoint
>>> > 3. Injecting a bus reference and registering a listener
>>> >
>>> > Your Tips:
>>> > 1.
>>> > In
>>> >  the method where bus is injected, get ServerLifeCycleManager.class
>>> > extension from the bus and register your own ServerLifeCycleListener
>>> > impl
>>> > , it has methods such as startServer and stopServer, in
>>> > startServer(Server server) you can do
>>> > server.getEndpoint().getService().getQName(),
>>> > and keep these QNames
>>> > in the local list and have a method say getManagedEndpoints() which will
>>> >  return the list of those QNames that will be a good start
>>> >
>>> > 2.
>>> >> <bean class="org.apache.cxf.management.web.JMXServer">
>>> >> ? ?<property name="managedEndpoints">
>>> >> ? ? ? ? <list>
>>> >> ? ? ? ? ? ?<value>{http://users.com/rs}UserService</value>
>>> >> ? ? ? ? ? ?<value>{http://users.com/ws}UserService</value>
>>> >> ? ? ? ? </list>
>>> >> ? ?</property>
>>> >> ? ?<property name="manager" ref="instrumentationManager"/>
>>> >> </bean>
>>> > but ?<property name="managedEndpoints"> can be dropped, you can get this
>>> > list from the bus
>>> >
>>> >
>>> > Currently, I have finished on Step 1 and 2, and you have told me that
>>> > put step 3 on hold, and make sure JMXServer as a separated enpoint is
>>> > correct
>>>
>>> OK. I don't understand what you've done so far, what decisions have
>>> been made to do with making sure that
>>> - list of managed endpoints is returned
>>> - all MBean representations for all the endpoints are returned,
>>> - MBeans related to an individual endpoint are returned
>>>
>>> Can you please describe what you've done ?
>>>
>>> > I am actually stopped at this GET request:
>>> > I tried:
>>> >
>>> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
>>> > And obviously it doesn't work because of the slash in url is not
>>> > accepted. (I still didn't find a reasonable answer from searching google,
>>> > shocking)
>>> >
>>> Shenglin, you are obviously very well prepared technically but you
>>> need to change the approach and do it asap. Why do you expect Google
>>> to tell you why the above URI does not work ?
>>>
>>> That URI seems too long anyway
>>>
>>>
>>> http://localhost:8080/demoserver/jmx?service={http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
>>>
>>> Is the max really and in this particular case I'm presuming this query
>>> is about getting the list of MBeans reps for a particular managed
>>> service. Perhaps in the future we can allocate dynamic subresources
>>> instead for handling endpoint specific MBeans to make URIs shorter for
>>> this particular case.
>>>
>>>
>>> >
>>> > Then I reserve slash to back slash and got 500 errors:
>>> >
>>> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http:\\impl.service.ws.gsoc.cxf.apache.org\}CustomerServiceImpl
>>> >   => There is a 500 error from CXF
>>> > here is the exception stacktrace:
>>> >
>>> > 2011-05-12
>>> > 20:00:48.657:WARN::/demoserver/jaxserver/jmxserver/service/%7Bhttp:%5
>>> > C%5Cimpl.service.ws.gsoc.cxf.apache.org%5C%7DCustomerServiceImpl
>>> > java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: Unexpected
>>> > interna
>>> > l error near index 1<|\<| ^
>>> >        at
>>> > org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMess
>>> > age(AbstractFaultChainInitiatorObserver.java:102)
>>> >        at
>>> > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
>>> > orChain.java:303)
>>> >        at
>>> > org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIniti
>>> > ationObserver.java:113)
>>> >        at
>>> > org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDes
>>> > tination.java:97)
>>> >        at
>>> > org.apache.cxf.transport.servlet.ServletController.invokeDestination(
>>> > ServletController.java:458)
>>> >        at
>>> > org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
>>> > roller.java:146)
>>> >        at
>>> > org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCX
>>> > FServlet.java:148)
>>> >        at
>>> > org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Ab
>>> > stractHTTPServlet.java:179)
>>> >        at
>>> > org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHT
>>> > TPServlet.java:108)
>>> >        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>>> >        at
>>> > org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(Abstract
>>> > HTTPServlet.java:159)
>>> >        at
>>> > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511
>>> > )
>>> >        at
>>> > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3
>>> > 90)
>>> >        at
>>> > org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.jav
>>> > a:216)
>>> >        at
>>> > org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:1
>>> > 82)
>>> >        at
>>> > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:7
>>> > 65)
>>> >        at
>>> > org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
>>> >
>>> >        at
>>> > org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHand
>>> > lerCollection.java:230)
>>> >        at
>>> > org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.
>>> > java:114)
>>> >        at
>>> > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1
>>> > 52)
>>> >        at org.mortbay.jetty.Server.handle(Server.java:326)
>>> >        at
>>> > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:54
>>> > 2)
>>> >        at
>>> > org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpCo
>>> > nnection.java:926)
>>> >        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
>>> >        at
>>> > org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>> >        at
>>> > org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>> >        at
>>> > org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.ja
>>> > va:410)
>>> >        at
>>> > org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.j
>>> > ava:582)
>>> >
>>> >
>>> > Any suggestions?
>>>
>>> Please understand how CXF JAX-RS handles requests, don't try changing
>>> "/" to "\\" and hope it will work
>>>
>>> >
>>> > Currently I can do the following:
>>> >
>>> > http://localhost:8080/demoserver/jaxrs3/jmx/component/org.apache.cxf:type=Bus.Service.Endpoint,*
>>> >       => get Mbean by ObjectName query
>>>
>>> What is "/jaxrs3" ? Are you really sure your JMXServer endpoint is
>>> separate ?
>>>
>>> > http://localhost:8080/demoserver/jaxserver/jmxserver/list
>>> >                                                       => get all Mbeans by
>>> > ObjectName('*:type=*,*')  which query is *:type=*,*
>>>
>>> should be just
>>>
>>> http://localhost:8080/demoserver/jmx/list
>>>
>>> >
>>> > http://localhost:8080/demoserver/jaxserver/jmxserver/type/Bus.Service.Endpoint
>>> >                                     => get Mbean by type
>>> >
>>> > http://localhost:8080/demoserver/jaxserver/jmxserver/port/%22UserServiceImpl%22
>>> >                               => get Mbean by service, %22 is an issue which
>>> > I can't get rid of it, still working on it.
>>> >
>>> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org
>>> >            => get Mbean by part of service such as
>>> > {http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl ->
>>> >
>>> >
>>> >         impl.service.ws.gsoc.cxf.apache.org
>>> >
>>> /demoserver/jaxserver/jmxserver/type/
>>> or
>>> /demoserver/jaxserver/jmxserver/port/
>>>
>>> is just too long
>>>
>>> /demoserver/jmx?mbean=somembeanname
>>>
>>> would probably do; well perhaps, introducing some "types" into URIs
>>> like /type/, /port/, etc, may also may make sense, but lets make sure
>>> we have a simple and straightforward approach for getting the list of
>>> all sorts of MBean representation
>>>
>>>
>>> Thanks, Sergey
>>> >
>>> > Thank you.
>>> >
>>> > Regards:
>>> > Shenglin Qiu
>>> >
>>
>



-- 
Sergey Beryozkin

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

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.

Hi Sergey:

Here are what I had and although the output maybe simple, I checked outputs and they look alright, need your opinions:)
1.
Request URL: this is from searching part of endpoint service="{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl"
http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org

Response:
<CxfMBeanCollection>
   <CxfMBeans>
      <CxfMBean>
         <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="CustomerServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
         <domain>org.apache.cxf</domain>
         <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl"</endpointName>
      </CxfMBean>
      <CxfMBean>
         <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="JaxRsJMXServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl",type=Bus.Service.Endpoint</canonicalName>
         <domain>org.apache.cxf</domain>
         <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl"</endpointName>
      </CxfMBean>
      <CxfMBean>
         <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="UserServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
         <domain>org.apache.cxf</domain>
         <endpointName>"{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl"</endpointName>
      </CxfMBean>
   </CxfMBeans>
</CxfMBeanCollection>



2. 
Request: search port="UserServiceImpl"
http://localhost:8080/demoserver/jaxserver/jmxserver/port/"UserServiceImpl"

Response:
<CxfMBean>
   <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="UserServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
   <domain>org.apache.cxf</domain>
   <endpointName>"UserServiceImpl"</endpointName>
</CxfMBean>


3.
Request: search by ObjectName("*******")

http://localhost:8080/demoserver/jaxrs3/jmx/component/org.apache.cxf:type=Bus.Service.Endpoint,*

Response:
<CxfMBeanCollection>
   <CxfMBeans>
      <CxfMBean>
         <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="JaxRsJMXServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl",type=Bus.Service.Endpoint</canonicalName>
         <domain>org.apache.cxf</domain>
      </CxfMBean>
      <CxfMBean>
         <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="JMXServer",service="{http://web.management.gsoc.cxf.apache.org/}JMXServer",type=Bus.Service.Endpoint</canonicalName>
         <domain>org.apache.cxf</domain>
      </CxfMBean>
      <CxfMBean>
         <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="CustomerServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl",type=Bus.Service.Endpoint</canonicalName>
         <domain>org.apache.cxf</domain>
      </CxfMBean>
      <CxfMBean>
         <canonicalName>org.apache.cxf:bus.id=cxf568097598,port="UserServiceImpl",service="{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl",type=Bus.Service.Endpoint</canonicalName>
         <domain>org.apache.cxf</domain>
      </CxfMBean>
   </CxfMBeans>
</CxfMBeanCollection>



My current inbound config ():
<!-- JAX-WS Service Endpoint -->    
    <jaxws:endpoint id="personService" implementor="#personServ" address="/PersonService">
        <jaxws:inInterceptors>
            <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor" />
            <bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
                <constructor-arg>
                    <map>
                        <entry key="action" value="UsernameToken" />
                        <entry key="passwordType" value="PasswordText" />
                        <entry key="passwordCallbackClass" value="org.apache.cxf.gsoc.ws.auth.ServerPasswordCallback" />
                    </map>
                </constructor-arg>
            </bean>
        </jaxws:inInterceptors>
    </jaxws:endpoint>
    
    <bean id="instrumentationManager" class="org.apache.cxf.management.jmx.InstrumentationManagerImpl">
        <property name="bus" ref="cxf" />
        <property name="enabled" value="true" />
        <property name="JMXServiceURL" value="service:jmx:rmi:///jndi/rmi://localhost:9914/jmxrmi" />
    </bean>
    
    <!-- Wiring the counter repository --> 
    <bean id="counterRepository" class="org.apache.cxf.management.counters.CounterRepository">
        <property name="bus" ref="cxf" />        
    </bean>

    <!-- JAX-RS Server 1 -->
    <jaxrs:server id="userServiceRs" address="/jaxrs1">
        <jaxrs:serviceBeans>
            <ref bean="userService" />
        </jaxrs:serviceBeans>
    </jaxrs:server>

    <!-- JAX-RS Server 2 -->
    <jaxrs:server id="customerServiceRs" address="/jaxrs2">
        <jaxrs:serviceBeans>
            <ref bean="customerService" />
        </jaxrs:serviceBeans>
    </jaxrs:server>
    
    <!-- JAX-RS Server 3: This is the old jmx inbound, haven't deleted, but will do -->
    <jaxrs:server id="jmxServiceRs" address="/jaxrs3">
        <jaxrs:serviceBeans>
            <ref bean="jmxService" />
        </jaxrs:serviceBeans>
    </jaxrs:server>
    
    <!-- CXF3388: Expose JMXServer: Current testing inbound.-->
    <jaxrs:server id="jmxServerRs" address="/jaxserver">
        <jaxrs:serviceBeans>
            <ref bean="jmxServer" />
        </jaxrs:serviceBeans>
    </jaxrs:server>
    
    <!-- This jmxServer should be exposed to jax-rs which should be separated from other service endpoints -->
    <bean id="jmxServer" class="org.apache.cxf.gsoc.management.web.JMXServer">
        <property name="managedJaxRsEndpoints">
            <list>
                <ref bean="userServiceRs"/>
                <ref bean="customerServiceRs"/>
            </list>
        </property>
        <property name="managedJaxWsEndpoints">
            <list>
                <ref bean="personService"/>
            </list>
        </property>
        <property name="managedEndpoints">
            <list>
                <value>{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl</value>
                <value>{http://web.management.gsoc.cxf.apache.org/}JMXServer</value>
                <value>{http://impl.service.ws.gsoc.cxf.apache.org/}UserServiceImpl</value>
                <value>{http://impl.service.ws.gsoc.cxf.apache.org/}JaxRsJMXServiceImpl</value>
            </list>
        </property>
        
        <property name="instrumentationManager" ref="instrumentationManager"/>
    </bean>
    
    <bean id="userService" class="org.apache.cxf.gsoc.ws.service.impl.UserServiceImpl" />
    <bean id="customerService" class="org.apache.cxf.gsoc.ws.service.impl.CustomerServiceImpl" />
    <bean id="jmxService" class="org.apache.cxf.gsoc.ws.service.impl.JaxRsJMXServiceImpl" />

I am planning to use this weekend, clean this config and code up, and make Rest request url shorter as you mentioned. I need your suggestions and ideas. and I think I am ready for a big surgery on the demoserver.
Code is still in https://dabaipang@github.com/dabaipang/demoserver.git
Also, I will go to supermarket and find a scanner for the NDS

Thank you very much!


Regards:
Shenglin Qiu



> Date: Fri, 13 May 2011 11:11:51 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dev@cxf.apache.org
> 
> Hi
> 
> On Fri, May 13, 2011 at 1:19 AM, Shenglin Qiu <da...@hotmail.com> wrote:
> >
> > Hi Sergey:
> >
> > Here is the todo list which you have assigned:
> >
> > 1. Have one JAX-WS and JAX-RS endpoints
> > 2. Have your JMXServer as a separate endpoint
> > 3. Injecting a bus reference and registering a listener
> >
> > Your Tips:
> > 1.
> > In
> >  the method where bus is injected, get ServerLifeCycleManager.class
> > extension from the bus and register your own ServerLifeCycleListener
> > impl
> > , it has methods such as startServer and stopServer, in
> > startServer(Server server) you can do
> > server.getEndpoint().getService().getQName(),
> > and keep these QNames
> > in the local list and have a method say getManagedEndpoints() which will
> >  return the list of those QNames that will be a good start
> >
> > 2.
> >> <bean class="org.apache.cxf.management.web.JMXServer">
> >> ? ?<property name="managedEndpoints">
> >> ? ? ? ? <list>
> >> ? ? ? ? ? ?<value>{http://users.com/rs}UserService</value>
> >> ? ? ? ? ? ?<value>{http://users.com/ws}UserService</value>
> >> ? ? ? ? </list>
> >> ? ?</property>
> >> ? ?<property name="manager" ref="instrumentationManager"/>
> >> </bean>
> > but ?<property name="managedEndpoints"> can be dropped, you can get this list from the bus
> >
> >
> > Currently, I have finished on Step 1 and 2, and you have told me that put step 3 on hold, and make sure JMXServer as a separated enpoint is correct
> 
> OK. I don't understand what you've done so far, what decisions have
> been made to do with making sure that
> - list of managed endpoints is returned
> - all MBean representations for all the endpoints are returned,
> - MBeans related to an individual endpoint are returned
> 
> Can you please describe what you've done ?
> 
> > I am actually stopped at this GET request:
> > I tried:
> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
> > And obviously it doesn't work because of the slash in url is not accepted. (I still didn't find a reasonable answer from searching google, shocking)
> >
> Shenglin, you are obviously very well prepared technically but you
> need to change the approach and do it asap. Why do you expect Google
> to tell you why the above URI does not work ?
> 
> That URI seems too long anyway
> 
> http://localhost:8080/demoserver/jmx?service={http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
> 
> Is the max really and in this particular case I'm presuming this query
> is about  getting the list of MBeans reps for a particular managed
> service. Perhaps in the future we can allocate dynamic subresources
> instead for handling endpoint specific MBeans to make URIs shorter for
> this particular case.
> 
> 
> >
> > Then I reserve slash to back slash and got 500 errors:
> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http:\\impl.service.ws.gsoc.cxf.apache.org\}CustomerServiceImpl   => There is a 500 error from CXF
> > here is the exception stacktrace:
> >
> > 2011-05-12 20:00:48.657:WARN::/demoserver/jaxserver/jmxserver/service/%7Bhttp:%5
> > C%5Cimpl.service.ws.gsoc.cxf.apache.org%5C%7DCustomerServiceImpl
> > java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: Unexpected interna
> > l error near index 1<|\<| ^
> >        at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMess
> > age(AbstractFaultChainInitiatorObserver.java:102)
> >        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
> > orChain.java:303)
> >        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIniti
> > ationObserver.java:113)
> >        at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDes
> > tination.java:97)
> >        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(
> > ServletController.java:458)
> >        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
> > roller.java:146)
> >        at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCX
> > FServlet.java:148)
> >        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Ab
> > stractHTTPServlet.java:179)
> >        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHT
> > TPServlet.java:108)
> >        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
> >        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(Abstract
> > HTTPServlet.java:159)
> >        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511
> > )
> >        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3
> > 90)
> >        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.jav
> > a:216)
> >        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:1
> > 82)
> >        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:7
> > 65)
> >        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
> >
> >        at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHand
> > lerCollection.java:230)
> >        at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.
> > java:114)
> >        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1
> > 52)
> >        at org.mortbay.jetty.Server.handle(Server.java:326)
> >        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:54
> > 2)
> >        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpCo
> > nnection.java:926)
> >        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
> >        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
> >        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
> >        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.ja
> > va:410)
> >        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.j
> > ava:582)
> >
> >
> > Any suggestions?
> 
> Please understand how CXF JAX-RS handles requests, don't try changing
> "/" to "\\" and hope it will work
> 
> >
> > Currently I can do the following:
> > http://localhost:8080/demoserver/jaxrs3/jmx/component/org.apache.cxf:type=Bus.Service.Endpoint,*       => get Mbean by ObjectName query
> 
> What is "/jaxrs3" ? Are you really sure your JMXServer endpoint is separate ?
> 
> > http://localhost:8080/demoserver/jaxserver/jmxserver/list                                                                     => get all Mbeans by ObjectName('*:type=*,*')  which query is *:type=*,*
> 
> should be just
> 
> http://localhost:8080/demoserver/jmx/list
> 
> > http://localhost:8080/demoserver/jaxserver/jmxserver/type/Bus.Service.Endpoint                                     => get Mbean by type
> > http://localhost:8080/demoserver/jaxserver/jmxserver/port/%22UserServiceImpl%22                               => get Mbean by service, %22 is an issue which I can't get rid of it, still working on it.
> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org            => get Mbean by part of service such as {http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl ->
> >                                                                                                                                                             impl.service.ws.gsoc.cxf.apache.org
> >
> /demoserver/jaxserver/jmxserver/type/
> or
> /demoserver/jaxserver/jmxserver/port/
> 
> is just too long
> 
> /demoserver/jmx?mbean=somembeanname
> 
> would probably do; well perhaps, introducing some "types" into URIs
> like /type/, /port/, etc, may also may make sense, but lets make sure
> we have a simple and straightforward approach for getting the list of
> all sorts of MBean representation
> 
> 
> Thanks, Sergey
> >
> > Thank you.
> >
> > Regards:
> > Shenglin Qiu
> >
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

On Fri, May 13, 2011 at 1:19 AM, Shenglin Qiu <da...@hotmail.com> wrote:
>
> Hi Sergey:
>
> Here is the todo list which you have assigned:
>
> 1. Have one JAX-WS and JAX-RS endpoints
> 2. Have your JMXServer as a separate endpoint
> 3. Injecting a bus reference and registering a listener
>
> Your Tips:
> 1.
> In
>  the method where bus is injected, get ServerLifeCycleManager.class
> extension from the bus and register your own ServerLifeCycleListener
> impl
> , it has methods such as startServer and stopServer, in
> startServer(Server server) you can do
> server.getEndpoint().getService().getQName(),
> and keep these QNames
> in the local list and have a method say getManagedEndpoints() which will
>  return the list of those QNames that will be a good start
>
> 2.
>> <bean class="org.apache.cxf.management.web.JMXServer">
>> ? ?<property name="managedEndpoints">
>> ? ? ? ? <list>
>> ? ? ? ? ? ?<value>{http://users.com/rs}UserService</value>
>> ? ? ? ? ? ?<value>{http://users.com/ws}UserService</value>
>> ? ? ? ? </list>
>> ? ?</property>
>> ? ?<property name="manager" ref="instrumentationManager"/>
>> </bean>
> but ?<property name="managedEndpoints"> can be dropped, you can get this list from the bus
>
>
> Currently, I have finished on Step 1 and 2, and you have told me that put step 3 on hold, and make sure JMXServer as a separated enpoint is correct

OK. I don't understand what you've done so far, what decisions have
been made to do with making sure that
- list of managed endpoints is returned
- all MBean representations for all the endpoints are returned,
- MBeans related to an individual endpoint are returned

Can you please describe what you've done ?

> I am actually stopped at this GET request:
> I tried:
> http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
> And obviously it doesn't work because of the slash in url is not accepted. (I still didn't find a reasonable answer from searching google, shocking)
>
Shenglin, you are obviously very well prepared technically but you
need to change the approach and do it asap. Why do you expect Google
to tell you why the above URI does not work ?

That URI seems too long anyway

http://localhost:8080/demoserver/jmx?service={http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl

Is the max really and in this particular case I'm presuming this query
is about  getting the list of MBeans reps for a particular managed
service. Perhaps in the future we can allocate dynamic subresources
instead for handling endpoint specific MBeans to make URIs shorter for
this particular case.


>
> Then I reserve slash to back slash and got 500 errors:
> http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http:\\impl.service.ws.gsoc.cxf.apache.org\}CustomerServiceImpl   => There is a 500 error from CXF
> here is the exception stacktrace:
>
> 2011-05-12 20:00:48.657:WARN::/demoserver/jaxserver/jmxserver/service/%7Bhttp:%5
> C%5Cimpl.service.ws.gsoc.cxf.apache.org%5C%7DCustomerServiceImpl
> java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: Unexpected interna
> l error near index 1<|\<| ^
>        at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMess
> age(AbstractFaultChainInitiatorObserver.java:102)
>        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
> orChain.java:303)
>        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIniti
> ationObserver.java:113)
>        at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDes
> tination.java:97)
>        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(
> ServletController.java:458)
>        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
> roller.java:146)
>        at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCX
> FServlet.java:148)
>        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Ab
> stractHTTPServlet.java:179)
>        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHT
> TPServlet.java:108)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(Abstract
> HTTPServlet.java:159)
>        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511
> )
>        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3
> 90)
>        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.jav
> a:216)
>        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:1
> 82)
>        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:7
> 65)
>        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
>
>        at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHand
> lerCollection.java:230)
>        at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.
> java:114)
>        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1
> 52)
>        at org.mortbay.jetty.Server.handle(Server.java:326)
>        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:54
> 2)
>        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpCo
> nnection.java:926)
>        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
>        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.ja
> va:410)
>        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.j
> ava:582)
>
>
> Any suggestions?

Please understand how CXF JAX-RS handles requests, don't try changing
"/" to "\\" and hope it will work

>
> Currently I can do the following:
> http://localhost:8080/demoserver/jaxrs3/jmx/component/org.apache.cxf:type=Bus.Service.Endpoint,*       => get Mbean by ObjectName query

What is "/jaxrs3" ? Are you really sure your JMXServer endpoint is separate ?

> http://localhost:8080/demoserver/jaxserver/jmxserver/list                                                                     => get all Mbeans by ObjectName('*:type=*,*')  which query is *:type=*,*

should be just

http://localhost:8080/demoserver/jmx/list

> http://localhost:8080/demoserver/jaxserver/jmxserver/type/Bus.Service.Endpoint                                     => get Mbean by type
> http://localhost:8080/demoserver/jaxserver/jmxserver/port/%22UserServiceImpl%22                               => get Mbean by service, %22 is an issue which I can't get rid of it, still working on it.
> http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org            => get Mbean by part of service such as {http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl ->
>                                                                                                                                                             impl.service.ws.gsoc.cxf.apache.org
>
/demoserver/jaxserver/jmxserver/type/
or
/demoserver/jaxserver/jmxserver/port/

is just too long

/demoserver/jmx?mbean=somembeanname

would probably do; well perhaps, introducing some "types" into URIs
like /type/, /port/, etc, may also may make sense, but lets make sure
we have a simple and straightforward approach for getting the list of
all sorts of MBean representation


Thanks, Sergey
>
> Thank you.
>
> Regards:
> Shenglin Qiu
>

RE: Expose MBeans in CXF

Posted by Shenglin Qiu <da...@hotmail.com>.
Hi Sergey:

Here is the todo list which you have assigned:

1. Have one JAX-WS and JAX-RS endpoints
2. Have your JMXServer as a separate endpoint
3. Injecting a bus reference and registering a listener

Your Tips:
1. 
In
 the method where bus is injected, get ServerLifeCycleManager.class 
extension from the bus and register your own ServerLifeCycleListener 
impl
, it has methods such as startServer and stopServer, in 
startServer(Server server) you can do 
server.getEndpoint().getService().getQName(), 
and keep these QNames 
in the local list and have a method say getManagedEndpoints() which will
 return the list of those QNames that will be a good start

2.
> <bean class="org.apache.cxf.management.web.JMXServer">
> ? ?<property name="managedEndpoints">
> ? ? ? ? <list>
> ? ? ? ? ? ?<value>{http://users.com/rs}UserService</value>
> ? ? ? ? ? ?<value>{http://users.com/ws}UserService</value>
> ? ? ? ? </list>
> ? ?</property>
> ? ?<property name="manager" ref="instrumentationManager"/>
> </bean>
but ?<property name="managedEndpoints"> can be dropped, you can get this list from the bus


Currently, I have finished on Step 1 and 2, and you have told me that put step 3 on hold, and make sure JMXServer as a separated enpoint is correct
I am actually stopped at this GET request:
I tried:
http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl
And obviously it doesn't work because of the slash in url is not accepted. (I still didn't find a reasonable answer from searching google, shocking)


Then I reserve slash to back slash and got 500 errors:
http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http:\\impl.service.ws.gsoc.cxf.apache.org\}CustomerServiceImpl   => There is a 500 error from CXF
here is the exception stacktrace:

2011-05-12 20:00:48.657:WARN::/demoserver/jaxserver/jmxserver/service/%7Bhttp:%5
C%5Cimpl.service.ws.gsoc.cxf.apache.org%5C%7DCustomerServiceImpl
java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: Unexpected interna
l error near index 1<|\<| ^
        at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMess
age(AbstractFaultChainInitiatorObserver.java:102)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
orChain.java:303)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIniti
ationObserver.java:113)
        at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDes
tination.java:97)
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(
ServletController.java:458)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
roller.java:146)
        at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCX
FServlet.java:148)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Ab
stractHTTPServlet.java:179)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHT
TPServlet.java:108)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(Abstract
HTTPServlet.java:159)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511
)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3
90)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.jav
a:216)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:1
82)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:7
65)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)

        at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHand
lerCollection.java:230)
        at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.
java:114)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1
52)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:54
2)
        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpCo
nnection.java:926)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.ja
va:410)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.j
ava:582)


Any suggestions?

Currently I can do the following:
http://localhost:8080/demoserver/jaxrs3/jmx/component/org.apache.cxf:type=Bus.Service.Endpoint,*       => get Mbean by ObjectName query
http://localhost:8080/demoserver/jaxserver/jmxserver/list                                                                     => get all Mbeans by ObjectName('*:type=*,*')  which query is *:type=*,*
http://localhost:8080/demoserver/jaxserver/jmxserver/type/Bus.Service.Endpoint                                     => get Mbean by type
http://localhost:8080/demoserver/jaxserver/jmxserver/port/%22UserServiceImpl%22                               => get Mbean by service, %22 is an issue which I can't get rid of it, still working on it.
http://localhost:8080/demoserver/jaxserver/jmxserver/service/impl.service.ws.gsoc.cxf.apache.org            => get Mbean by part of service such as {http://impl.service.ws.gsoc.cxf.apache.org/}CustomerServiceImpl ->                          
                                                                                                                                                             impl.service.ws.gsoc.cxf.apache.org


Thank you.

Regards:
Shenglin Qiu



> Date: Thu, 12 May 2011 14:23:36 +0100
> Subject: Re: Expose MBeans in CXF
> From: sberyozkin@gmail.com
> To: dev@cxf.apache.org
> 
> Hi Shenglin
> 
> Thanks for the update. Can you please copy the summary from the
> previous email, where one possible approach going forward was
> discussed and describe what you've done so far in context of that
> summary ?
> Looks like you are progressing well, however I'm not exactly sure what
> exactly you are trying to do.
> 
> More comments inline
> 
> On Thu, May 12, 2011 at 1:53 PM, Shenglin Qiu <da...@hotmail.com> wrote:
> >
> > Hi Sergey:
> >
> > I have tested my current code and these are working fine:
> > http://localhost:8080/demoserver/jaxserver/jmxserver/port/%22UserServiceImpl%22
> > http://localhost:8080/demoserver/jaxserver/jmxserver/type/Bus.Service.Endpoint
> >
> > I will work on this " sign which is %22 in the URL and try to remove it.
> 
> Please update us first on what you've done so far, why you are passing
> "UserServiceImpl" as the final segment is unclear at the moment
> 
> >
> > This is not working
> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://web.management.gsoc.cxf.apache.org/}DJMXServer
> > which is :
> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/%7Bhttp://web.management.gsoc.cxf.apache.org/%7DJMXServer
> >
> > It simply return 404 error. I guess it's the restriction from CXF Rest inbound,
> 
> Well, I believe CXF 2.4.0 and CXF 2.3.5 have no problems at all with
> handling all sort of encoded URIs, earlier versions had some issues
> when matrix params were used or some specific characters were encoded.
> So try the latest versions.
> However, what I'd really encourage you to do is to make sure you
> understand why the above is not working, by debugging the JAX-RS
> runtime code and see what might be going wrong
> 
> > then I tried:
> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/service?{http://web.management.gsoc.cxf.apache.org/}DJMXServer
> > http://localhost:8080/demoserver/jaxserver/jmxserver/service/service={http://web.management.gsoc.cxf.apache.org/}DJMXServer
> > They didn't work neither. Because when = in request, it's still 404, and when ? in request, I only get 'service' as the @PathParam in the input, the rest of the part is lost.
> 
> '?' identifies the start of the query component,  so that is not
> captured, and please check why '=' is not working. Perhaps something
> to do with @Path values ?
> 
> >
> > So is there any way I can pass string like 'http://******' as a part of request in cxf?
> >
> Yes, pass it as a query parameter value, ex ?component=http://bar or
> as the value of the path segment
> 
> > BTW, I will have the NDA ready this week.
> >
> it's ICLA
> 
> http://www.apache.org/licenses/icla.txt
> 
> Please try to update the dev list at least twice per week and login to
> #cxf if you have questions. We should be finalizing by now the
> retrieval of MBean representations and start planning what to do next
> 
> Thanks, Sergey
> 
> > Thank you.
> >
> > Regards
> > Shenglin Qiu
> >
> >
> 
> 
> 
> -- 
> Sergey Beryozkin
> 
> Application Integration Division of Talend
> http://sberyozkin.blogspot.com
 		 	   		  

Re: Expose MBeans in CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Shenglin

Thanks for the update. Can you please copy the summary from the
previous email, where one possible approach going forward was
discussed and describe what you've done so far in context of that
summary ?
Looks like you are progressing well, however I'm not exactly sure what
exactly you are trying to do.

More comments inline

On Thu, May 12, 2011 at 1:53 PM, Shenglin Qiu <da...@hotmail.com> wrote:
>
> Hi Sergey:
>
> I have tested my current code and these are working fine:
> http://localhost:8080/demoserver/jaxserver/jmxserver/port/%22UserServiceImpl%22
> http://localhost:8080/demoserver/jaxserver/jmxserver/type/Bus.Service.Endpoint
>
> I will work on this " sign which is %22 in the URL and try to remove it.

Please update us first on what you've done so far, why you are passing
"UserServiceImpl" as the final segment is unclear at the moment

>
> This is not working
> http://localhost:8080/demoserver/jaxserver/jmxserver/service/{http://web.management.gsoc.cxf.apache.org/}DJMXServer
> which is :
> http://localhost:8080/demoserver/jaxserver/jmxserver/service/%7Bhttp://web.management.gsoc.cxf.apache.org/%7DJMXServer
>
> It simply return 404 error. I guess it's the restriction from CXF Rest inbound,

Well, I believe CXF 2.4.0 and CXF 2.3.5 have no problems at all with
handling all sort of encoded URIs, earlier versions had some issues
when matrix params were used or some specific characters were encoded.
So try the latest versions.
However, what I'd really encourage you to do is to make sure you
understand why the above is not working, by debugging the JAX-RS
runtime code and see what might be going wrong

> then I tried:
> http://localhost:8080/demoserver/jaxserver/jmxserver/service/service?{http://web.management.gsoc.cxf.apache.org/}DJMXServer
> http://localhost:8080/demoserver/jaxserver/jmxserver/service/service={http://web.management.gsoc.cxf.apache.org/}DJMXServer
> They didn't work neither. Because when = in request, it's still 404, and when ? in request, I only get 'service' as the @PathParam in the input, the rest of the part is lost.

'?' identifies the start of the query component,  so that is not
captured, and please check why '=' is not working. Perhaps something
to do with @Path values ?

>
> So is there any way I can pass string like 'http://******' as a part of request in cxf?
>
Yes, pass it as a query parameter value, ex ?component=http://bar or
as the value of the path segment

> BTW, I will have the NDA ready this week.
>
it's ICLA

http://www.apache.org/licenses/icla.txt

Please try to update the dev list at least twice per week and login to
#cxf if you have questions. We should be finalizing by now the
retrieval of MBean representations and start planning what to do next

Thanks, Sergey

> Thank you.
>
> Regards
> Shenglin Qiu
>
>



-- 
Sergey Beryozkin

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