JBoss AS 6.1.0 Final bootstrap.xml的解析过程
2014-10-12 20:42
239 查看
JBoss 启动文件 jboss-6.1.0.Final/server/default/conf/bootstrap.xml 是加载服务内容的入口。
在 JBoss 初始化操作的最后一个步骤中 , AbstractJBossASServerBase setupBootstrapDescriptorsFromBootstrapUrl()方法中,完成了对 bootstrap.xml的解析。过程如下:
解析之后,将bootstrap.xml中的内容保存到 server.getConfiguration() 对象中。
bootstrap.xml文件内容
与bootstrap.xml对应的解析类为 BootstrapMetaData;
解析完成后,下一步对这几个部分进行分别解析和加载。
确切的说,bootstrap中包含的 8 个配置文件,就是 微容器 Microcontainer 。
JBoss 服务初始化完成之后,服务的配置信息如下:=======================Server Configuration:
JBOSS_HOME URL: file:/E:/jboss-6.1.0.Final/
Bootstrap: $JBOSS_HOME\server/default/conf/bootstrap.xml
Common Base: $JBOSS_HOME\common/
Common Library: $JBOSS_HOME\common/lib/
Server Name: default
Server Base: $JBOSS_HOME\server/
Server Library: $JBOSS_HOME\server/default/lib/
Server Config: $JBOSS_HOME\server/default/conf/
Server Home: $JBOSS_HOME\server/default/
Server Data: $JBOSS_HOME\server/default/data/
Server Log: $JBOSS_HOME\server/default/log/
Server Temp: $JBOSS_HOME\server/default/tmp/
在 JBoss 初始化操作的最后一个步骤中 , AbstractJBossASServerBase setupBootstrapDescriptorsFromBootstrapUrl()方法中,完成了对 bootstrap.xml的解析。过程如下:
protected void setupBootstrapDescriptorsFromBootstrapUrl() { final URL bootstrapUrl = this.getConfiguration().getBootstrapUrl(); // bootstrapUrl = E:/jboss-6.1.0.Final/server/default/conf/bootstrap.xml if (bootstrapUrl == null) { throw new IllegalStateException("Bootstrap URL should have been initialized"); } final BootstrapMetaData bmd = BootstrapParser.parse(bootstrapUrl); final List<String> urlStrings = bmd.getBootstrapURLs(); ... }
public class BootstrapParser{ public static BootstrapMetaData parse(URL url) { if (url == null) throw new IllegalArgumentException("Null url"); UnmarshallerFactory factory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = factory.newUnmarshaller(); try { BootstrapMetaData result = (BootstrapMetaData) unmarshaller.unmarshal(url.toString(), new BootstrapSchemaBinding()); if (result == null) throw new IllegalStateException("The bootsrap xml " + url + " is not well formed"); return result; } catch (Exception e) { throw new RuntimeException("Error unmarshalling " + url, e); } } }
public static BootstrapMetaData parse(URL url){ if (url == null) throw new IllegalArgumentException("Null url"); UnmarshallerFactory factory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = factory.newUnmarshaller(); try{ BootstrapMetaData result = (BootstrapMetaData) unmarshaller.unmarshal(url.toString(), new BootstrapSchemaBinding()); if (result == null) throw new IllegalStateException("The bootsrap xml " + url + " is not well formed"); return result; } catch (Exception e) { throw new RuntimeException("Error unmarshalling " + url, e); } }
class BootstrapSchemaBinding extends SchemaBinding{ public static final String NAMESPACE = "urn:jboss:bootstrap:1.0"; public BootstrapSchemaBinding(){ TypeBinding stringType = getType(SimpleTypeBindings.typeQName(String.class)); setNamespaces(Collections.singleton(NAMESPACE)); setIgnoreLowLine(true); setIgnoreUnresolvedFieldOrClass(false); setReplacePropertyRefs(true); setStrictSchema(true); TypeBinding bootstrapType = new TypeBinding(new QName(NAMESPACE, "bootstrapType")); bootstrapType.setSimple(false); AllBinding bootstrapModel = new AllBinding(this); ParticleBinding bootstrapParticle = new ParticleBinding(bootstrapModel, 1, 1, false); bootstrapType.setParticle(bootstrapParticle); ClassMetaData bootstrapClassMetaData = new ClassMetaData(); bootstrapClassMetaData.setImpl(BootstrapMetaData.class.getName()); bootstrapType.setClassMetaData(bootstrapClassMetaData); ElementBinding urlElement = new ElementBinding(this, new QName(NAMESPACE, "url"), stringType); ParticleBinding urlParticle = new ParticleBinding(urlElement, 0, 1, true); bootstrapModel.addParticle(urlParticle); bootstrapType.pushInterceptor(urlElement.getQName(), new DefaultElementInterceptor() { public void add(Object parent, Object child, QName name) { BootstrapMetaData bootstrap = (BootstrapMetaData) parent; String url = (String) child; List<String> bootstrapURLs = bootstrap.getBootstrapURLs(); if (bootstrapURLs == null) { bootstrapURLs = new ArrayList<String>(); bootstrap.setBootstrapURLs(bootstrapURLs); } bootstrapURLs.add(url); } }); addElement(new ElementBinding(this, new QName(NAMESPACE, "bootstrap"), bootstrapType)); } }
解析之后,将bootstrap.xml中的内容保存到 server.getConfiguration() 对象中。
bootstrap.xml文件内容
<?xml version="1.0" encoding="UTF-8"?> <!-- The list of URLs for mc beans to load during bootstrap. $Id: bootstrap.xml 106395 2010-07-02 02:16:59Z mmoyses $ --> <bootstrap xmlns="urn:jboss:bootstrap:1.0"> <url>bootstrap/classloader.xml</url> <url>bootstrap/stdio.xml</url> <url>bootstrap/kernel.xml</url> <url>bootstrap/aop.xml</url> <url>bootstrap/jmx.xml</url> <url>bootstrap/deployers.xml</url> <url>bootstrap/profile.xml</url> <url>bootstrap/security.xml</url> </bootstrap>
与bootstrap.xml对应的解析类为 BootstrapMetaData;
解析完成后,下一步对这几个部分进行分别解析和加载。
确切的说,bootstrap中包含的 8 个配置文件,就是 微容器 Microcontainer 。
JBoss 服务初始化完成之后,服务的配置信息如下:=======================Server Configuration:
JBOSS_HOME URL: file:/E:/jboss-6.1.0.Final/
Bootstrap: $JBOSS_HOME\server/default/conf/bootstrap.xml
Common Base: $JBOSS_HOME\common/
Common Library: $JBOSS_HOME\common/lib/
Server Name: default
Server Base: $JBOSS_HOME\server/
Server Library: $JBOSS_HOME\server/default/lib/
Server Config: $JBOSS_HOME\server/default/conf/
Server Home: $JBOSS_HOME\server/default/
Server Data: $JBOSS_HOME\server/default/data/
Server Log: $JBOSS_HOME\server/default/log/
Server Temp: $JBOSS_HOME\server/default/tmp/
相关文章推荐
- JBoss AS 6.1.0 Final 启动过程分析-Main
- JBoss AS 6.1.0 Final 启动参数的作用以及服务的选择
- JBoss AS 6.1.0 Final 启动的xml描述文件解析与对应的解析类
- JBoss AS 6.1.0 Final Kernel 的组成和创建过程类的关系图
- simpleXML怎样解析一个xml文件,并对xml进行增删改查 过程
- Android中measure过程、WRAP_CONTENT详解以及 xml布局文件解析流程浅析
- 【读码练习/JSON-java】(二)解析XML的过程
- Objective-C解析html(xml)全过程
- xml的SAX解析过程详解
- sax中DefaultHander解析xml过程和先后顺序
- Android解析XML(PULL方式)和JSON 工作原理和实现过程(详细代码)
- sax解析xml文件过程总结
- Spring 3.2 源码解析 -- XML bean 元素到 BeanDefinition 解析过程
- SQL数据库存储过程执行传入参数xml,并解析分析传入的xml数据
- Jdom解析xml过程详解
- xmlBeanDefinitionReader解析xml的过程
- oracle存储过程通过http接收xml文件并解析入库
- xml的Jdom解析过程详解
- XML解析(参看网上一个解析过程,并对其错误之处纠正)
- Android中measure过程、WRAP_CONTENT详解以及xml布局文件解析流程浅析(下)