当前位置: 首页>>代码示例>>Java>>正文


Java Binder.unmarshal方法代码示例

本文整理汇总了Java中javax.xml.bind.Binder.unmarshal方法的典型用法代码示例。如果您正苦于以下问题:Java Binder.unmarshal方法的具体用法?Java Binder.unmarshal怎么用?Java Binder.unmarshal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.bind.Binder的用法示例。


在下文中一共展示了Binder.unmarshal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCamelModelObjectFromXML

import javax.xml.bind.Binder; //导入方法依赖的package包/类
/**
 * Creates camel model object like CamelContextFactoryBean, RouteDefinition or RoutesDefinition
 * from XML file.
 * 
 * @param xmlPath path to the file
 * @return created camel model object
 * @throws Exception failed to unmarshall camel model object from XML file
 */
public static Object createCamelModelObjectFromXML(String xmlPath) throws Exception {
    InputStream input = Classes.getResourceAsStream(xmlPath);
    if (input == null) {
        throw CommonCamelMessages.MESSAGES.specifiedCamelContextFileIsNotFound(xmlPath);
    }
    
    InputSource source =  new InputSource(input);
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(source);
    Element element = document.getDocumentElement();
    Element camelModelElement = findCamelModelElement(element, xmlPath);
    if (camelModelElement == null) {
        throw CommonCamelMessages.MESSAGES.noCamelContextElementFound(xmlPath);
    }
    
    Binder<Node> binder = JAXB_CONTEXT.createBinder();
    Object obj = binder.unmarshal(camelModelElement);
    injectNamespaces(camelModelElement, binder);
    return obj;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:31,代码来源:CamelModelFactory.java

示例2: parseUsingJaxb

import javax.xml.bind.Binder; //导入方法依赖的package包/类
protected Object parseUsingJaxb(Element element, ParserContext parserContext, Binder<Node> binder) {
    try {
        return binder.unmarshal(element);
    } catch (JAXBException e) {
        throw new ComponentDefinitionException("Failed to parse JAXB element: " + e, e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:CamelNamespaceHandler.java

示例3: parseUsingJaxb

import javax.xml.bind.Binder; //导入方法依赖的package包/类
protected Object parseUsingJaxb(Element element, ParserContext parserContext, Binder<Node> binder) {
    try {
        return binder.unmarshal(element);
    } catch (JAXBException e) {
        throw new BeanDefinitionStoreException("Failed to parse JAXB element", e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:CamelNamespaceHandler.java

示例4: fromXMLString

import javax.xml.bind.Binder; //导入方法依赖的package包/类
public static WindowState fromXMLString(String s){
	try {
		JAXBContext context = JAXBContext.newInstance(WindowState.class);
		Binder<Node> binder = context.createBinder();
		
		Document doc = XMLUtils.parse(s);
		return (WindowState)binder.unmarshal(doc);
	} catch (Throwable e) {
		return null;
	}		
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:12,代码来源:WindowState.java


注:本文中的javax.xml.bind.Binder.unmarshal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。