[[Jakarta_Enterprise_Beans_Deployment_Runtime_Resources]]
= Jakarta Enterprise Beans Deployment Runtime Resources

ifdef::env-github[]
:imagesdir: ../../
:tip-caption: :bulb:
:note-caption: :information_source:
:important-caption: :heavy_exclamation_mark:
:caution-caption: :fire:
:warning-caption: :warning:
endif::[]

Enterprise bean deployment exposes certain management runtime resources to help users inspect enterprise bean metadata
and monitor invocation statistics. Bean metadata is configured in the application via deployment descriptor and
annotations. Stateless, stateful, singleton session beans and message-driven beans support a common set of resources,
and also resources specific to the bean type. For example, these are some of the common enterprise bean resources:

* jndi-names
* component-class-name
* declared-roles
* transaction-type
* stateful-timeout
* activation-config

Users can view these enterprise bean resources via WildFly CLI or Administration Console. The following sections
provides sample CLI and Administration Console output for each enterprise bean type. For complete details, refer to
https://wildscribe.github.io/[WildFly Model Reference Documentation]

[[Stateless_Session_Bean_Runtime_Resources]]
== Stateless Session Bean Runtime Resources

To view the management runtime resources for a deployed stateless session bean in CLI, run the following CLI command:

[source]
/deployment=<DEPLOYMENT-NAME>/subsystem=ejb3/stateless-session-bean=<BEAN-NAME>:read-resource(include-runtime)

The following is a sample output for a stateless session bean named `ManagedStatelessBean` in deployment `ejb-management.jar`:

[source]
/deployment=ejb-management.jar/subsystem=ejb3/stateless-session-bean=ManagedStatelessBean:read-resource(include-runtime)
{
    "outcome" => "success",
    "result" => {
        "async-methods" => ["void async(int, int)"],
        "business-local" => ["sample.ManagedStatelessBean"],
        "business-remote" => ["sample.BusinessInterface"],
        "component-class-name" => "sample.ManagedStatelessBean",
        "declared-roles" => [
            "Role3",
            "Role2",
            "Role1"
        ],
        "execution-time" => 160L,
        "invocations" => 3L,
        "jndi-names" => [
            "java:global/ejb-management/ManagedStatelessBean!sample.BusinessInterface",
            "java:module/ManagedStatelessBean!sample.BusinessInterface",
            "java:app/ejb-management/ManagedStatelessBean!sample.BusinessInterface",
            "java:global/ejb-management/ManagedStatelessBean!sample.ManagedStatelessBean",
            "java:module/ManagedStatelessBean!sample.ManagedStatelessBean",
            "java:app/ejb-management/ManagedStatelessBean!sample.ManagedStatelessBean"
        ],
        "methods" => {"doIt" => {
            "execution-time" => 160L,
            "invocations" => 3L,
            "wait-time" => 10L
        }},
        "peak-concurrent-invocations" => 1L,
        "pool-available-count" => 64,
        "pool-create-count" => 1,
        "pool-current-size" => 1,
        "pool-max-size" => 64,
        "pool-name" => "slsb-strict-max-pool",
        "pool-remove-count" => 0,
        "run-as-role" => "Role3",
        "security-domain" => "other",
        "timeout-method" => "public void sample.ManagedStatelessBean.timeout(jakarta.ejb.Timer)",
        "timers" => [{
            "time-remaining" => 4735224L,
            "next-timeout" => 1577768415000L,
            "calendar-timer" => true,
            "persistent" => false,
            "info" => "timer1",
            "schedule" => {
                "year" => "*",
                "month" => "*",
                "day-of-month" => "*",
                "day-of-week" => "*",
                "hour" => "0",
                "minute" => "0",
                "second" => "15",
                "timezone" => undefined,
                "start" => undefined,
                "end" => undefined
            }
        }],
        "transaction-type" => "CONTAINER",
        "wait-time" => 10L,
        "service" => {"timer-service" => undefined}
    }
}

To view it in WildFly Administration Console, go to the `Management Model` section of the target deployment. For example,

image:images/ejb/stateless-management-resource.png[alt=ejb/stateless-management-resource.png]

[[Stateful_Session_Bean_Runtime_Resources]]
== Stateful Session Bean Runtime Resources

To view the management runtime resources for a deployed stateful session bean in CLI, run the following CLI command:

[source]
/deployment=<DEPLOYMENT-NAME>/subsystem=ejb3/stateful-session-bean=<BEAN-NAME>:read-resource(include-runtime)

The following is a sample output for a stateful session bean named `ManagedStatefulBean2` in deployment `ejb-management.jar`:

[source]
/deployment=ejb-management.jar/subsystem=ejb3/stateful-session-bean=ManagedStatefulBean2:read-resource(include-runtime)
{
    "outcome" => "success",
    "result" => {
        "after-begin-method" => "private void sample.ManagedStatefulBean2.afterBegin()",
        "after-completion-method" => "private void sample.ManagedStatefulBean2.afterCompletion()",
        "async-methods" => ["void async(int, int)"],
        "before-completion-method" => "private void sample.ManagedStatefulBean2.beforeCompletion()",
        "business-local" => ["sample.ManagedStatefulBean2"],
        "business-remote" => ["sample.BusinessInterface"],
        "cache-size" => 0,
        "component-class-name" => "sample.ManagedStatefulBean2",
        "declared-roles" => [
            "Role3",
            "Role2",
            "Role1"
        ],
        "execution-time" => 163L,
        "invocations" => 4L,
        "jndi-names" => [
            "java:app/ejb-management/ManagedStatefulBean2!sample.BusinessInterface",
            "java:global/ejb-management/ManagedStatefulBean2!sample.BusinessInterface",
            "java:module/ManagedStatefulBean2!sample.BusinessInterface",
            "java:app/ejb-management/ManagedStatefulBean2!sample.ManagedStatefulBean2",
            "java:global/ejb-management/ManagedStatefulBean2!sample.ManagedStatefulBean2",
            "java:module/ManagedStatefulBean2!sample.ManagedStatefulBean2"
        ],
        "methods" => {
            "doIt" => {
                "execution-time" => 163L,
                "invocations" => 3L,
                "wait-time" => 3L
            },
            "remove" => {
                "execution-time" => 0L,
                "invocations" => 1L,
                "wait-time" => 1L
            }
        },
        "passivated-count" => 0,
        "passivation-capable" => false,
        "peak-concurrent-invocations" => 1L,
        "remove-methods" => [
            {
                "bean-method" => "void remove()",
                "retain-if-exception" => false
            },
            {
                "bean-method" => "void removeTrue()",
                "retain-if-exception" => true
            },
            {
                "bean-method" => "void removeFalse()",
                "retain-if-exception" => false
            }
        ],
        "run-as-role" => "Role3",
        "security-domain" => "other",
        "stateful-timeout" => "2 HOURS",
        "total-size" => 0,
        "transaction-type" => "BEAN",
        "wait-time" => 4L,
        "service" => undefined
    }
}

To view it in WildFly Administration Console, go to the `Management Model` section of the target deployment. For example,

image:images/ejb/stateful-management-resource.png[alt=ejb/stateful-management-resource.png]

[[Singleton_Bean_Runtime_Resources]]
== Singleton Bean Runtime Resources

To view the management runtime resources for a deployed singleton bean in CLI, run the following CLI command:

[source]
/deployment=<DEPLOYMENT-NAME>/subsystem=ejb3/singleton-bean=<BEAN-NAME>:read-resource(include-runtime)

The following is a sample output for a singleton bean named `ManagedSingletonBean` in deployment `ejb-management.jar`:

[source]
/deployment=ejb-management.jar/subsystem=ejb3/singleton-bean=ManagedSingletonBean:read-resource(include-runtime)
{
    "outcome" => "success",
    "result" => {
        "async-methods" => ["void async(int, int)"],
        "business-local" => ["sample.ManagedSingletonBean"],
        "business-remote" => ["sample.BusinessInterface"],
        "component-class-name" => "sample.ManagedSingletonBean",
        "concurrency-management-type" => undefined,
        "declared-roles" => [
            "Role3",
            "Role2",
            "Role1"
        ],
        "depends-on" => undefined,
        "execution-time" => 156L,
        "init-on-startup" => false,
        "invocations" => 3L,
        "jndi-names" => [
            "java:module/ManagedSingletonBean!sample.ManagedSingletonBean",
            "java:global/ejb-management/ManagedSingletonBean!sample.ManagedSingletonBean",
            "java:app/ejb-management/ManagedSingletonBean!sample.ManagedSingletonBean",
            "java:app/ejb-management/ManagedSingletonBean!sample.BusinessInterface",
            "java:global/ejb-management/ManagedSingletonBean!sample.BusinessInterface",
            "java:module/ManagedSingletonBean!sample.BusinessInterface"
        ],
        "methods" => {"doIt" => {
            "execution-time" => 156L,
            "invocations" => 3L,
            "wait-time" => 0L
        }},
        "peak-concurrent-invocations" => 1L,
        "run-as-role" => "Role3",
        "security-domain" => "other",
        "timeout-method" => "public void sample.ManagedSingletonBean.timeout(jakarta.ejb.Timer)",
        "timers" => [{
            "time-remaining" => 4304279L,
            "next-timeout" => 1577768415000L,
            "calendar-timer" => true,
            "persistent" => false,
            "info" => "timer1",
            "schedule" => {
                "year" => "*",
                "month" => "*",
                "day-of-month" => "*",
                "day-of-week" => "*",
                "hour" => "0",
                "minute" => "0",
                "second" => "15",
                "timezone" => undefined,
                "start" => undefined,
                "end" => undefined
            }
        }],
        "transaction-type" => "CONTAINER",
        "wait-time" => 0L,
        "service" => {"timer-service" => undefined}
    }
}

To view it in WildFly Administration Console, go to the `Management Model` section of the target deployment. For example,

image:images/ejb/singleton-management-resource.png[alt=ejb/singleton-management-resource.png]

[[Message_Driven_Bean_Runtime_Resources]]
== Message-driven Bean Runtime Resources

To view the management runtime resources for a deployed message-driven bean in CLI, run the following CLI command:

[source]
/deployment=<DEPLOYMENT-NAME>/subsystem=ejb3/message-driven-bean=<BEAN-NAME>:read-resource(include-runtime)

The following is a sample output for a message-driven bean named `ManagedMDB` in deployment `ejb-management.jar`:

[source]
/deployment=ejb-management.jar/subsystem=ejb3/message-driven-bean=ManagedMDB:read-resource(include-runtime)
{
    "outcome" => "success",
    "result" => {
        "activation-config" => [
            ("destinationType" => "jakarta.jms.Queue"),
            ("destination" => "java:/queue/ManagedMDB-queue")
        ],
        "component-class-name" => "sample.ManagedMDB",
        "declared-roles" => [
            "Role3",
            "Role2",
            "Role1"
        ],
        "delivery-active" => true,
        "execution-time" => 0L,
        "invocations" => 0L,
        "message-destination-link" => undefined,
        "message-destination-type" => undefined,
        "messaging-type" => "jakarta.jms.MessageListener",
        "methods" => {},
        "peak-concurrent-invocations" => 0L,
        "pool-available-count" => 16,
        "pool-create-count" => 0,
        "pool-current-size" => 0,
        "pool-max-size" => 16,
        "pool-name" => "mdb-strict-max-pool",
        "pool-remove-count" => 0,
        "run-as-role" => "Role3",
        "security-domain" => "other",
        "timeout-method" => "public void sample.ManagedMDB.timeout(jakarta.ejb.Timer)",
        "timers" => [{
            "time-remaining" => 4213581L,
            "next-timeout" => 1577768415000L,
            "calendar-timer" => true,
            "persistent" => false,
            "info" => "timer1",
            "schedule" => {
                "year" => "*",
                "month" => "*",
                "day-of-month" => "*",
                "day-of-week" => "*",
                "hour" => "0",
                "minute" => "0",
                "second" => "15",
                "timezone" => undefined,
                "start" => undefined,
                "end" => undefined
            }
        }],
        "transaction-type" => "CONTAINER",
        "wait-time" => 0L,
        "service" => {"timer-service" => undefined}
    }
}

To view it in WildFly Administration Console, go to the `Management Model` section of the target deployment. For example,

image:images/ejb/mdb-management-resource.png[alt=ejb/mdb-management-resource.png]
