Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Jolokia Java Client - ReadRequest optional #173
Jolokia version used: 1.2.3
I coud not find in the reference manual or java doc whether the java client supports optional reads. And by that I mean, a ReadRequest where the mbean may not exists. And if the mbean does not exists I just want a response back with an indicator that the mbean didnt exists.
Today I had to add a try .. catch hack, or I would need to do a list call first to see if the mbean is there, and then etc. But I would love if there was a read optional. Then I can use that as well in a List call so I can do a bulk operation.
For an example see the source code of Apache Camel where we have a jolokia command module
I have these 3 mbeans I need to get information from
And then this 4th mbean is optional, so I need to do a separate call to handle if it does not exists
I think it can be easily added client-wise for bulk requests. The plain JSON response already contains all responses, with 404 errors for MBeans which where not found. So all what have to be done is to filter or transform the list accordingly.
To make it more flexible, I consider an addition to the API
public <R extends J4pResponse<T>,T extends J4pRequest> List<R> execute(List<T> pRequests,J4pResponseExtractor pExtractor)
What do you think ?
Just implemented that thinggy.
It can be used in two ways:
A sample usage looks like:
J4pClient j4p = J4pClient.url("...") .responseExtractor(ValidatingResponseExtractor.OPTIONAL) .build();
A missing MBean now simply leaves a
You can try the code from branch