天天看點

JBoss MC

jbossMC kernel

一、事件機制

  Subject: org.jboss.kernel.spi.event.KernelEventEmitter

        org.jboss.kernel.spi.event.KernelEventListener

        org.jboss.kernel.spi.event.KernelEventFilter

        org.jboss.kernel.spi.event.KernelEventManager

  通過上面各類實作事件的産生、監聽、過濾和協調管理

 命名機制

   為了将POJO變成使用者可用的Service,需要一種命名機制,使用者以名稱方式獲得POJO。

二、kernel系統組成

所有組成對象都是KernelObject,每個KernelObject都繼承KernelEventEmitter;

具體包括:

1)KernelBus - 通向registry的線路,使得可以調用registry中命名了的元件

2)KernelConfig - 提供kernel配置選項,獲得class info,建立KernalBus、KernelConfigurator、KernelController、KernelEventManager、KernelInitializer

、KernelRegistry、KernelMetaDataRepository以及DependencyBuilder

3)KernelConfigurator - 輔助controller建立和配置bean的工具類

4)KernelController - 核心元件,保證beans的配置和生命周期以正确的順序被處理,包括依賴關系與類加載等内容

5)KernelEventManager - 事件協調者

6)KernelMetaDataRepository - beans的中繼資料倉庫

7)Registry - 負責track命名beans,保證通過bus調用beans,根據依賴關系進行使用

Kernel- kernel服務的入口點,考慮了access 權限與config權限,對通路與配置進行安全檢查。同時kernel中包含上面7個KernelObject

三、kernel 自舉(bootstrap)

1)通過單例的KernelFactory獲得Kernel執行個體

   1.1)獲得config(從property,或者Systemproperty)

   1.2)new一個既沒有config,亦沒有initialized的Kernel

   1.3)setConfig

   1.4)setInitlizer

  1.5)傳回Kernel

MC的環境涉及- aop, metadata中繼資料, class loading類加載, deployments部署, state management狀态管理, lifecycle/dependcies生命周期/依賴關系管理, configuration配置, and management元件管理

四、反射模型reflection model

  在java.lang.reflect之上的抽象

  4.1 cache 不适用cache,反射可能成為性能瓶頸

  4.2 abstraction

  4.3 hide implementation 使用aop操作bytecode,隐藏不感興趣的實作

五、jboss測試

六、部署

  BasicXMLDeployer - 解析xml檔案(jboss-beans.xml),配置注冊beans;解析獲得的資訊儲存在KernelDeployment之中,具體每個bean資訊存在于BeanMetaData之中。

 .xml--parse-->BeanMetaData; 多個BeanMetaData構成kernelDeployment;

 由KernelController對每一個BeanMetaData處理,根據BeanMetaData等資訊構造KernelControllerContezt,并存放在deployment的map中,最後controller.install(context)

 1)VFS

 2)識别部署結構

   這一步找到dd,bytecode,偵測“嵌套部署”。使用VFS表示部署,需要首先建立VFSDeployment。

     VirtualFile root = VFS.getRoot(deploymentURL);    

     VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();

    Deployment deployment = deploymentFactory.createVFSDeployment(root);

  部署架構使用StructureDeployer部署器,決定部署結構。

  部署結構包括xml檔案結構、JAR結構(jar,sar,war,ear,rar);嵌套部署

 3)建立部署上下文(Deployment Context)

    确定deployment結構後,下一步是建立部署上下文,每一個deployment,不論是top-level還是嵌套的,都要對應一個部署上下文。

    記錄:

       。the location of any deployment descriptors - the metadata path

    。the location of any classes - the classpath

    。the relative path to the top-level deployment - the relative path

       。the deployment name

     。the order it should be deployed in relative to other deployments - the relative order

    。a list of deployment types that it represents (including nested deployments) - the types

    。the state of the deployment - whether it is deployed or not

    。the deployment class loader

    。the deployment resource loader

    。dependencies on other deployments or runtime components

    。references to any components that it deploys - POJOs, MBeans etc...

    。references to any nested (child) deployments or the parent deployment

  3.1運作時部署元件(POJO、OSGi,JMX)

  3.2部署依賴

上一篇: OC線程note