Package com.sun.jdmk.comm

Examples of com.sun.jdmk.comm.HtmlAdaptorServer

where: The HTML protocol adaptor provides the following main HTML pages for managing MBeans in an agent:

When the HTML protocol adaptor is started it creates a TCP/IP socket and listens for client connections.

The default port number of the socket is 8082. This default value can be changed by specifying a port number:

The default object name is define by {@link com.sun.jdmk.ServiceName#DOMAIN com.sun.jdmk.ServiceName.DOMAIN} and {@link com.sun.jdmk.ServiceName#HTML_ADAPTOR_SERVER com.sun.jdmk.ServiceName.HTML_ADAPTOR_SERVER}.

If a client tries to connect, the HtmlAdaptorServer creates a thread which receives and processes all subsequent requests from this client. The number of clients is limited by the maxActiveClientCount property. The default value of the maxActiveClientCount is 10.

When an HtmlAdaptorServer is stopped, all current HTTP connections are interrupted (some requests may be terminated abruptly), and the TCP/IP socket is closed.

The HtmlAdaptorServer can perform user authentication. The add/remove user authentication info methods can be used to manage users and their corresponding authentication information. The HTML server uses the 'Basic Authentication Scheme' (as defined in RFC 1945, section 11.1) to authenticate clients connecting to the server.

Limitations of the HTML protocol adaptor:


            String loginName = glob.getProperty().get("xmlBlaster/jmx/HtmlAdaptor/loginName", (String)null);
            String password = glob.getProperty().get("xmlBlaster/jmx/HtmlAdaptor/password", "secret");

            if (loginName != null) {
               AuthInfo authInfos[] = { new AuthInfo(loginName, password) };
               this.html = new HtmlAdaptorServer(port, authInfos);
            }
            else {
               this.html = new HtmlAdaptorServer(port);
            }

            ObjectName html_name = new ObjectName("Adaptor:name=html,port="+port);

            ObjectInstance objectInstance = this.mbeanServer.registerMBean(this.html, html_name);
View Full Code Here


  @Test
  public void testMessage() throws Exception {
   
     
    // start mbeanserver with HTML Adaptor
    HtmlAdaptorServer adapter = new HtmlAdaptorServer();
    ObjectName adapterName = new ObjectName("SimpleAgent:name=htmladapter,port=9933");
    adapter.setPort(9933);
    ManagementFactory.getPlatformMBeanServer().registerMBean(adapter, adapterName);
    adapter.start();

   
      // create and start the http server
    HttpServer server = new HttpServer(new HttpRequestHandler());
    server.start();

        ConnectionUtils.registerMBean(server);   


       
        // client query
    HttpClient httpClient = new HttpClient();

    IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + 9933 + "/"));
    Assert.assertEquals(200, response.getStatus());
    Assert.assertTrue(response.getBlockingBody().toString().indexOf("HttpRequestHandler") != -1);


    httpClient.close();
    server.close();   
    adapter.stop();
  }
View Full Code Here

  @Test
  public void testMessage() throws Exception {
   
     
    // start mbeanserver with HTML Adaptor
    HtmlAdaptorServer adapter = new HtmlAdaptorServer();
    ObjectName adapterName = new ObjectName("SimpleAgent:name=htmladapter,port=9933");
    adapter.setPort(9933);
    ManagementFactory.getPlatformMBeanServer().registerMBean(adapter, adapterName);
    adapter.start();

   
      // create and start the http server
    HttpServer server = new HttpServer(new HttpRequestHandler());
    server.start();

        ConnectionUtils.registerMBean(server);   


       
        // client query
    HttpClient httpClient = new HttpClient();

    IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + 9933 + "/"));
    Assert.assertEquals(200, response.getStatus());
    Assert.assertTrue(response.getBlockingBody().toString().indexOf("HttpRequestHandler") != -1);


    httpClient.close();
    server.close();   
    adapter.stop();
  }
View Full Code Here

  @Test
  public void testMessage() throws Exception {
   
     
    // start mbeanserver with HTML Adaptor
    HtmlAdaptorServer adapter = new HtmlAdaptorServer();
    ObjectName adapterName = new ObjectName("SimpleAgent:name=htmladapter,port=9933");
    adapter.setPort(9933);
    ManagementFactory.getPlatformMBeanServer().registerMBean(adapter, adapterName);
    adapter.start();

   
      // create and start the http server
    HttpServer server = new HttpServer(new HttpRequestHandler());
    server.start();

        ConnectionUtils.registerMBean(server);   


       
        // client query
    HttpClient httpClient = new HttpClient();

    IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + 9933 + "/"));
    Assert.assertEquals(200, response.getStatus());
    Assert.assertTrue(response.getBody().toString().indexOf("HttpRequestHandler") != -1);


    httpClient.close();
    server.close();   
    adapter.stop();
  }
View Full Code Here

      InstanceAlreadyExistsException, MBeanRegistrationException,
      NotCompliantMBeanException {
    if (port == 0) {
      port = 9092;
    }
    HtmlAdaptorServer adapter = new HtmlAdaptorServer();
    ObjectName adaptorName = new ObjectName(
        "dragonfly:name=htmladaptor,port=" + port);
    adapter.setPort(port);
    getMBeanServer().registerMBean(adapter, adaptorName);
    adapter.start();
  }
View Full Code Here

    return mbs != null;
  }

  public void openServer(IConfig config) {
    if (!isOpen() || server != null) return;
    server = new HtmlAdaptorServer(config.getInt("port", 1098));
   
    for (IConfig cuser : config.getConfigBundle("user")) {
      server.addUserAuthenticationInfo(new AuthInfo(cuser.getExtracted("name"), MPassword.decode(cuser.getExtracted("password")) ));
    }
   
View Full Code Here

    }
   
   
    public void start() {
        this.server = MBeanServerFactory.createMBeanServer("xcp");
        this.html = new HtmlAdaptorServer(this.port);
        this.html.addUserAuthenticationInfo(new AuthInfo(this.user, this.password));
       
        try {
            //register the html-adaptor
            ObjectName on = new ObjectName("Adaptor:name=html,port=8888");
View Full Code Here

  public
  void start() {

    MBeanServer server = MBeanServerFactory.createMBeanServer();
    HtmlAdaptorServer html = new HtmlAdaptorServer();

    try {
      log.info("Registering HtmlAdaptorServer instance.");
      server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082"));
      log.info("Registering HierarchyDynamicMBean instance.");
      HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
      server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default"));

    } catch(Exception e) {
      log.error("Problem while regitering MBeans instances.", e);
      return;
    }
    html.start();
  }
View Full Code Here

 
  public
  void start() {
       
    MBeanServer server = MBeanServerFactory.createMBeanServer();   
    HtmlAdaptorServer html = new HtmlAdaptorServer();

    try {
      log.info("Registering HtmlAdaptorServer instance.");
      server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082"));
      log.info("Registering HierarchyDynamicMBean instance.");
      HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
      server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default"));
     
    } catch(Exception e) {
      log.error("Problem while regitering MBeans instances.", e);
      return;
    }
    html.start();   
  }  
View Full Code Here

  public
  void start() {

    MBeanServer server = MBeanServerFactory.createMBeanServer();
    HtmlAdaptorServer html = new HtmlAdaptorServer();

    try {
      log.info("Registering HtmlAdaptorServer instance.");
      server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082"));
      log.info("Registering HierarchyDynamicMBean instance.");
      HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
      server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default"));

    } catch(Exception e) {
      log.error("Problem while regitering MBeans instances.", e);
      return;
    }
    html.start();
  }
View Full Code Here

TOP

Related Classes of com.sun.jdmk.comm.HtmlAdaptorServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.