gpt4 book ai didi

org.apache.geronimo.kernel.util.XmlUtil类的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 22:06:40 25 4
gpt4 key购买 nike

本文整理了Java中org.apache.geronimo.kernel.util.XmlUtil类的一些代码示例,展示了XmlUtil类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlUtil类的具体详情如下:
包路径:org.apache.geronimo.kernel.util.XmlUtil
类名称:XmlUtil

XmlUtil介绍

暂无

代码示例

代码示例来源:origin: org.apache.geronimo.framework/geronimo-deployment

public ParserFactoryImpl(EntityResolver entityResolver) {
  this.entityResolver = entityResolver;
  factory = XmlUtil.newDocumentBuilderFactory();
  //sets "http://xml.org/sax/features/namespaces"
  factory.setNamespaceAware(true);
  //sets "http://xml.org/sax/features/validation"
  factory.setValidating(true);
  factory.setAttribute(
      "http://java.sun.com/xml/jaxp/properties/schemaLanguage",
      "http://www.w3.org/2001/XMLSchema");
  factory.setAttribute("http://apache.org/xml/features/validation/schema",
      Boolean.TRUE);
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel

public static SAXParserFactory newSAXParserFactory() {
  return newSAXParserFactory(getClassLoader());
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel

public static TransformerFactory newTransformerFactory() {
  return newTransformerFactory(getClassLoader());
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel

public static DocumentBuilderFactory newDocumentBuilderFactory() {
  return newDocumentBuilderFactory(getClassLoader());
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-deploy-jsr88

private static String extractModuleIdFromPlan(Reader plan) throws IOException {
  SAXParserFactory factory = XmlUtil.newSAXParserFactory();
  factory.setNamespaceAware(true);
  factory.setValidating(false);
  try {
    SAXParser parser = factory.newSAXParser();
    ConfigIdHandler handler = new ConfigIdHandler();
    parser.parse(new InputSource(plan), handler);
    if(handler.formatIs10) {
      log.warn("Geronimo deployment plan uses Geronimo 1.0 syntax.  Please update to Geronimo 1.1 syntax when possible.");
    }
    return handler.configId;
  } catch (ParserConfigurationException e) {
    throw (IOException)new IOException("Unable to read plan: "+e.getMessage()).initCause(e);
  } catch (SAXException e) {
    throw (IOException)new IOException("Unable to read plan: "+e.getMessage()).initCause(e);
  } finally {
    plan.close();
  }
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel

public static TransformerFactory newTransformerFactory(ClassLoader classLoader) {
  String transformerName = getSystemProperty(TRANSFORMER_FACTORY);
  if (transformerName != null && transformerName.length() != 0) {
    try {
      Class transformerClass = ClassLoading.loadClass(transformerName, classLoader);
      TransformerFactory transformerFactory = (TransformerFactory) transformerClass.newInstance();
      return transformerFactory;
    } catch (Exception e) {
      throw new TransformerFactoryConfigurationError(e, "Unable to create TransformerFactory " +
          transformerName + ", which was specified in the " + TRANSFORMER_FACTORY + " system property");
    }
  }
  return TransformerFactory.newInstance();
}

代码示例来源:origin: org.apache.geronimo.framework/geronimo-plugin

/**
 * Puts the name and ID of a plugin into the argument map of plugins,
 * by reading the values out of the provided plugin descriptor stream.
 *
 * @param xml     The geronimo-plugin.xml for this plugin
 * @param plugins The result map to populate
 */
private void readNameAndID(InputStream xml, Map plugins) {
  try {
    SAXParserFactory factory = XmlUtil.newSAXParserFactory();
    SAXParser parser = factory.newSAXParser();
    PluginNameIDHandler handler = new PluginNameIDHandler();
    parser.parse(xml, handler);
    if (handler.isComplete()) {
      plugins.put(handler.getName(), Artifact.create(handler.getID()));
    }
  } catch (Exception e) {
    log.warn("Invalid XML", e);
  }
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel

public static SAXParserFactory newSAXParserFactory(ClassLoader classLoader) {
  String saxParserName = getSystemProperty(SAX_PARSER_FACTORY);
  if (saxParserName != null && saxParserName.length() != 0) {
    try {
      Class saxParserClass = ClassLoading.loadClass(saxParserName, classLoader);
      SAXParserFactory saxParserFactory = (SAXParserFactory) saxParserClass.newInstance();
      return saxParserFactory;
    } catch (Exception e) {
      throw new FactoryConfigurationError(e, "Unable to create SAXParserFactory " +
          saxParserName + ", which was specified in the " + SAX_PARSER_FACTORY + " system property");
    }
  }
  return SAXParserFactory.newInstance();
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel

private static Element storeGBeans(List gbeans) throws IOException {
    GBeanData[] gbeanDatas = (GBeanData[]) gbeans.toArray(new GBeanData[gbeans.size()]);

    DocumentBuilderFactory documentBuilderFactory = XmlUtil.newDocumentBuilderFactory();
    DocumentBuilder documentBuilder = null;
    try {
      documentBuilder = documentBuilderFactory.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
      throw (IOException)new IOException("Cannot instantiate " + Document.class.getName()).initCause(e);
    }
    Document document = documentBuilder.newDocument();
    DomWriter writer = new DomWriter(document);

    XStream xstream = XStreamUtil.createXStream();
    xstream.marshal(gbeanDatas, writer);

//        FileWriter w = new FileWriter("target/foo.xml");
//        xstream.toXML(gbeanDatas, w);
//        w.close();

    return document.getDocumentElement();
  }
}

代码示例来源:origin: org.apache.geronimo.framework/geronimo-plugin

/**
 * Puts the name and ID of a plugin into the argument map of plugins,
 * by reading the values out of the provided plugin descriptor file.
 *
 * @param xml     The geronimo-plugin.xml for this plugin
 * @param plugins The result map to populate
 */
private void readNameAndID(File xml, Map<String, Artifact> plugins) {
  try {
    SAXParserFactory factory = XmlUtil.newSAXParserFactory();
    SAXParser parser = factory.newSAXParser();
    PluginNameIDHandler handler = new PluginNameIDHandler();
    parser.parse(xml, handler);
    if (handler.isComplete()) {
      plugins.put(handler.getName(), Artifact.create(handler.getID()));
    }
  } catch (Exception e) {
    log.warn("Invalid XML at " + xml.getAbsolutePath(), e);
  }
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel

public static DocumentBuilderFactory newDocumentBuilderFactory(ClassLoader classLoader) {
  String documentBuilderName = getSystemProperty(DOCUMENT_BUILDER_FACTORY);
  if (documentBuilderName != null && documentBuilderName.length() != 0) {
    try {
      Class documentBuilderClass = ClassLoading.loadClass(documentBuilderName, classLoader);
      DocumentBuilderFactory documentBuilderFactory = (DocumentBuilderFactory) documentBuilderClass.newInstance();
      return documentBuilderFactory;
    } catch (Exception e) {
      throw new FactoryConfigurationError(e, "Unable to create DocumentBuilderFactory " +
          documentBuilderName + ", which was specified in the " + DOCUMENT_BUILDER_FACTORY + " system property");
    }
  }
  return DocumentBuilderFactory.newInstance();
}

代码示例来源:origin: org.apache.geronimo.framework/geronimo-plugin

private Document getMavenMetadata(URI base) throws IOException, FailedLoginException {
    Document doc = null;
    InputStream in = null;

    try {
      URL metaURL = base.resolve( "maven-metadata.xml").toURL();
      in = openStream(metaURL);
      if (in == null) { // check for local maven metadata
        metaURL = base.resolve("maven-metadata-local.xml").toURL();
        in = openStream(metaURL);
      }
      if (in != null) {
        DocumentBuilder builder = XmlUtil.newDocumentBuilderFactory().newDocumentBuilder();
        doc = builder.parse(in);
      }
    } catch (ParserConfigurationException e) {
      throw (IOException)new IOException().initCause(e);
    } catch (SAXException e) {
      throw (IOException)new IOException().initCause(e);
    } finally {
      if (in == null) {
//                log.info("No maven metadata available at " + base);
      } else {
        in.close();
      }
    }
    return doc;
  }

代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel

public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext unmarshallingContext) {
  DocumentBuilderFactory documentBuilderFactory = XmlUtil.newDocumentBuilderFactory();
  DocumentBuilder documentBuilder = null;
  try {
    documentBuilder = documentBuilderFactory.newDocumentBuilder();
  } catch (ParserConfigurationException e) {
    throw new ConversionException("Cannot instantiate " + Document.class.getName(), e);
  }
  Document document = documentBuilder.newDocument();
  DomWriter writer = new DomWriter(document);
  copy(reader, writer);
  if (Document.class.isAssignableFrom(unmarshallingContext.getRequiredType())) {
    return document;
  } else {
    return document.getDocumentElement();
  }
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-converter

public static DatabaseConversionStatus convert(Reader configXml) throws IOException {
  List status = new ArrayList();
  List noTx = new ArrayList();
  List local = new ArrayList();
  List xa = new ArrayList();
  DocumentBuilderFactory factory = XmlUtil.newDocumentBuilderFactory();
  factory.setValidating(false);
  try {
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(new InputSource(configXml));
    configXml.close();
    parseDocument(doc, status, local, xa);
  } catch (ParserConfigurationException e) {
    throw (IOException)new IOException().initCause(e);
  } catch (SAXException e) {
    throw (IOException)new IOException().initCause(e);
  }
  DatabaseConversionStatus result = new DatabaseConversionStatus();
  result.setMessages((String[]) status.toArray(new String[status.size()]));
  result.setNoTXPools((JDBCPool[]) noTx.toArray(new JDBCPool[noTx.size()]));
  result.setJdbcPools((JDBCPool[]) local.toArray(new JDBCPool[noTx.size()]));
  result.setXaPools((XADatabasePool[]) xa.toArray(new XADatabasePool[xa.size()]));
  return result;
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-converter

public static DatabaseConversionStatus convert(Reader dsXml) throws IOException {
  List status = new ArrayList();
  List noTx = new ArrayList();
  List local = new ArrayList();
  List xa = new ArrayList();
  DocumentBuilderFactory factory = XmlUtil.newDocumentBuilderFactory();
  factory.setValidating(false);
  try {
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(new InputSource(dsXml));
    dsXml.close();
    parseDocument(doc, status, noTx, local, xa);
  } catch (ParserConfigurationException e) {
    throw (IOException)new IOException().initCause(e);
  } catch (SAXException e) {
    throw (IOException)new IOException().initCause(e);
  }
  DatabaseConversionStatus result = new DatabaseConversionStatus();
  result.setMessages((String[]) status.toArray(new String[status.size()]));
  result.setNoTXPools((JDBCPool[]) noTx.toArray(new JDBCPool[noTx.size()]));
  result.setJdbcPools((JDBCPool[]) local.toArray(new JDBCPool[noTx.size()]));
  result.setXaPools((XADatabasePool[]) xa.toArray(new XADatabasePool[xa.size()]));
  return result;
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel

if (is != null) {
  InputSource in = new InputSource(is);
  DocumentBuilderFactory dfactory = XmlUtil.newDocumentBuilderFactory();
  dfactory.setNamespaceAware(true);
  try {

代码示例来源:origin: org.apache.geronimo.plugins/activemq-portlets

while((entry = in.getNextEntry()) != null) {
  if(entry.getName().equals("META-INF/ra.xml")) {
    DocumentBuilderFactory factory = XmlUtil.newDocumentBuilderFactory();
    factory.setValidating(false);
    DocumentBuilder builder = factory.newDocumentBuilder();

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com