【JBoss】1. 微容器、JMX

JBoss微容器

JBoss之前的版本是围绕JMX内核构建,应用服务器提供的服务 都被写成JMX内核的MBean。

优点:是关系松散的体系结构,增删服务很容易


JBoss4.0.3之后,开始向微容器体系结构转变,应用服务器提供的服务使用简单的POJO

优点:不需要支持JMX,所以相对轻量级

——但是,目前并非所有服务都已移植到微容器中,JMX内核仍然是定义和创建微容器的一个主要POJO(例如JMS、JNDI服务仍依赖于JMX)。

【JBoss】1. 微容器、JMX_第1张图片

微容器配置

JBoss微容器是类似于Spring的依赖注入框架。

可以通过conf目录下的bean配置文件来配置微容器,【例】server/*/conf/bootstrap/profile.xml

<!-- The ProfileService -->
<bean name="ProfileService" 
      class="org.jboss.system.server.profileservice.repository.AbstractProfileService">
      <constructor>
         <parameter><inject bean="jboss.kernel:service=KernelController" /></parameter>
      </constructor>
      <property name="deployer"><inject bean="ProfileServiceDeployer" /></property>
      <property name="defaultProfile"><inject bean="DefaultProfileKey" /></property>
</bean>
<inject>注入一个bean作为初始属性值,或作为构造函数的一个参数


JMX配置

服务部署器基于jboss-service.xml的内容实例化MBean,按照名称注册MBean

【例】server/*/conf/jboss-service.xml

   <mbean code="org.jboss.logging.Log4jService" 
          name="jboss.system:type=Log4jService,service=Logging" 
          xmbean-dd="resource:xmdesc/Log4jService-xmbean.xml">
      <attribute name="ConfigurationURL">resource:jboss-log4j.xml</attribute>
      <!-- Set the org.apache.log4j.helpers.LogLog.setQuiteMode. As of log4j1.2.8
      this needs to be set to avoid a possible deadlock on exception at the
      appender level. See bug#696819.
      -->
      <attribute name="Log4jQuietMode">true</attribute>
      <!-- How frequently in seconds the ConfigurationURL is checked for changes -->
      <attribute name="RefreshPeriod">60</attribute>
      
      <!-- The value to assign to system property jboss.server.log.threshold
           if it is not already set. This system property in turn controls
           the logging threshold for the server.log file.
           If the system property is already set when this service is created,
           this value is ignored. -->
      <attribute name="DefaultJBossServerLogThreshold">INFO</attribute>
   </mbean>

MBean名称的格式:

jboss.system: ——域

type=Log4jService,——键属性

service=Logging——键属性


进入JMX-console后,点击左侧jboss.system域 ->service=Logging,type=Log4jService

【JBoss】1. 微容器、JMX_第2张图片

【JBoss】1. 微容器、JMX_第3张图片












你可能感兴趣的:(jboss)