Skip to content

Latest commit

 

History

History
112 lines (84 loc) · 5.26 KB

File metadata and controls

112 lines (84 loc) · 5.26 KB

helloworld-mbean: Helloworld Using MBean and CDI component

The helloworld-mbean quickstart demonstrates the use of CDI and MBean in {productName} and includes JConsole instructions and Arquillian tests.

What is it?

The helloworld-mbean quickstart demonstrates the use of CDI and MBean in {productNameFull}. The project also includes a set of Arquillian tests for MBeans.

The example is composed of the following MBeans.

MBean Description

AnnotatedComponentHelloWorld

This MBean is a managed bean with @MXBean annotation.

MXComponentHelloWorld

This MBean is a managed bean with MXBean interface.

MXPojoHelloWorld

This MBean is a POJO using MXBean interface and declared in the jboss-service.xml file.

SarMXPojoHelloWorld

This MBean is a pojo using MXBean interface and declared in the jboss-service.xml file using SAR packaging.

This also deploys the {artifactId}-service/target/{artifactId}-service.sar to the running instance of the server.

Access and Test the MBeans

This quickstart differs from the other quickstarts in that it uses JConsole to access and test the quickstart rather than access an URL in the browser. If you do access http://localhost:8080/{artifactId}-webapp/, you will see a screen shot image of the JConsole application,

The following sections describe how to use JConsole to inspect and test the MBeans.

Start JConsole

  1. To connect to the {productName} server using JConsole, open a terminal and type the following command, replacing JDK_HOME with the path to your JDK installation :

    JDK_HOME/bin/jconsole
    Note
    For Windows, type JDK_HOME\bin\jconsole.exe.
  2. Select the local org.jboss.modules.Main process and click Connect.

    MBeans in JConsole Connection

  3. A dialog displays with the warning: Secure connection failed. Retry insecurely?

  4. Click Insecure to continue.

Test the MBeans in JConsole

You can use JConsole to inspect and use the MBeans : MBeans in JConsole

  1. Click on the MBeans tab.

  2. Expand quickstarts in the left column of the console.

  3. Under quickstarts, you see the 4 MBeans: AnnotatedComponentHelloWorld, MXComponentHelloWorld, MXPojoHelloWorld, and SarMXPojoHelloWorld

  4. Expand each MBean and choose: OperationssayHello.

  5. Type your name in the (p0 String ) input text box and click the sayHello button.

    • For the AnnotatedComponentHelloWorld and MXComponentHelloWorld examples, you will see a popup Window displaying Hello <your name>!.

    • For the MXPojoHelloWorld and SarMXPojoHelloWorld examples, you will see a popup Window displaying Welcome <your name>!.

This quickstart consists of multiple projects and requires installation of the JBoss Tools Maven Packaging Configurator, so it deploys and runs differently in {JBDSProductName} than the other quickstarts.

  1. Install the JBoss Tools Maven Packaging Configurator

    • If the Red Hat Central page is not showing, open it by choosing HelpRed Hat Central.

    • Click the Software/Update tab at the bottom of the Red Hat Central.

    • Scroll down to the Maven section, select the JBoss Tools Maven Packaging Configurator and click Install/Update.

  2. Right click on the parent {artifactId} parent project and choose MavenUpdate Project…​. Select all projects and click OK.

  3. Right-click on the {artifactId}-service project and choose Run AsRun on Server.

  4. Right-click on the {artifactId}-webapp project and choose Run AsRun on Server.

  5. Start JConsole and Test the MBeans in JConsole as described above.

  6. To undeploy the web application, right-click on the {artifactId}-wepapp project and choose Run AsMaven build. Enter wildfly:undeploy for the Goals and click Run.

  7. To undeploy the web service, right-click on the {artifactId}-service project and choose Run AsMaven build. Enter wildfly:undeploy for the Goals and click Run.