@ Override public void doGet ( HttpServletRequest request , HttpServletResponse response ) { try { JsonGenerator jg = null ; String jsonpcb = null ; PrintWriter writer = null ; try { writer = response . getWriter ( ) ; // "callback" parameter implies JSONP outpout jsonpcb = request . getParameter ( CALLBACK_PARAM ) ; if ( jsonpcb != null ) { response . setContentType ( "application/javascript; charset=utf8" ) ; writer . write ( jsonpcb + "(" ) ; } else { response . setContentType ( "application/json; charset=utf8" ) ; } jg = jsonFactory . createGenerator ( writer ) ; jg . disable ( JsonGenerator . Feature . AUTO_CLOSE_TARGET ) ; jg . useDefaultPrettyPrinter ( ) ; jg . writeStartObject ( ) ; // query per mbean attribute String getmethod = request . getParameter ( "get" ) ; if ( getmethod != null ) { String [ ] splitStrings = getmethod . split ( "\\:\\:" ) ; if ( splitStrings . length != 2 ) { jg . writeStringField ( "result" , "ERROR" ) ; jg . writeStringField ( "message" , "query format is not as expected." ) ; jg . flush ( ) ; response . setStatus ( HttpServletResponse . SC_BAD_REQUEST ) ; return ; } listBeans ( jg , new ObjectName ( splitStrings [ 0 ] ) , splitStrings [ 1 ] , response ) ; return ; } // query per mbean String qry = request . getParameter ( "qry" ) ; if ( qry == null ) { qry = "*:*" ; } listBeans ( jg , new ObjectName ( qry ) , null , response ) ; } finally { if ( jg != null ) { jg . close ( ) ; } if ( jsonpcb != null ) { writer . write ( ");" ) ; } if ( writer != null ) { writer . close ( ) ; } } } catch ( IOException e ) { response . setStatus ( HttpServletResponse . SC_INTERNAL_SERVER_ERROR ) ; } catch ( MalformedObjectNameException e ) { response . setStatus ( HttpServletResponse . SC_BAD_REQUEST ) ; } }
Process a GET request for the specified resource .