java类javax.xml.parsers.FactoryConfigurationError的实例源码

S3BucketLoggingStatus.java 文件源码 项目:jets3t-aws-roles 阅读 19 收藏 0 点赞 0 评论 0
public XMLBuilder toXMLBuilder() throws ParserConfigurationException,
    FactoryConfigurationError, TransformerException
{
    XMLBuilder builder = XMLBuilder.create("BucketLoggingStatus")
        .attr("xmlns", Constants.XML_NAMESPACE);

    if (isLoggingEnabled()) {
        XMLBuilder enabledBuilder = builder.elem("LoggingEnabled")
            .elem("TargetBucket").text(getTargetBucketName()).up()
            .elem("TargetPrefix").text(getLogfilePrefix()).up();
        if (targetGrantsList.size() > 0) {
            Iterator<GrantAndPermission> targetGrantsIter = targetGrantsList.iterator();
            XMLBuilder grantsBuilder = enabledBuilder.elem("TargetGrants");
            while (targetGrantsIter.hasNext()) {
                GrantAndPermission gap = targetGrantsIter.next();
                grantsBuilder.elem("Grant")
                    .importXMLBuilder(gap.getGrantee().toXMLBuilder())
                    .elem("Permission").text(gap.getPermission().toString());
            }
        }
    }
    return builder;
}
DensitySpecificManifestProcessor.java 文件源码 项目:bazel 阅读 16 收藏 0 点赞 0 评论 0
private static DocumentBuilder getSecureDocumentBuilder() throws ParserConfigurationException {
  DocumentBuilderFactory factory =
      DocumentBuilderFactory.newInstance(
          "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl", null);
  factory.setValidating(false);
  factory.setXIncludeAware(false);
  for (Map.Entry<String, Boolean> featureAndValue : SECURE_XML_FEATURES.entrySet()) {
    try {
      factory.setFeature(featureAndValue.getKey(), featureAndValue.getValue());
    } catch (ParserConfigurationException e) {
      throw new FactoryConfigurationError(
          e,
          "Xerces DocumentBuilderFactory doesn't support the required security features: "
              + e.getMessage());
    }
  }
  return factory.newDocumentBuilder();
}
TableAdmin.java 文件源码 项目:incubator-blur 阅读 19 收藏 0 点赞 0 评论 0
private void reloadConfig() throws MalformedURLException, FactoryConfigurationError, BException {
  String blurHome = System.getenv("BLUR_HOME");
  if (blurHome != null) {
    File blurHomeFile = new File(blurHome);
    if (blurHomeFile.exists()) {
      File log4jFile = new File(new File(blurHomeFile, "conf"), "log4j.xml");
      if (log4jFile.exists()) {
        LOG.info("Reseting log4j config from [{0}]", log4jFile);
        LogManager.resetConfiguration();
        DOMConfigurator.configure(log4jFile.toURI().toURL());
        return;
      }
    }
  }
  URL url = TableAdmin.class.getResource("/log4j.xml");
  if (url != null) {
    LOG.info("Reseting log4j config from classpath resource [{0}]", url);
    LogManager.resetConfiguration();
    DOMConfigurator.configure(url);
    return;
  }
  throw new BException("Could not locate log4j file to reload, doing nothing.");
}
FontConfigReaderTest.java 文件源码 项目:birt 阅读 21 收藏 0 点赞 0 评论 0
public void testFontMapWhenAllFontsDefined( ) throws IOException,
        FactoryConfigurationError, ParserConfigurationException,
        SAXException
{
    fontMappingManager = getFontMappingManager( "fontsConfig1.xml" );

    // alias defined, composite font defined, block defined, and character
    // is defined by the block font.
    assertTrue( isMappedTo( '1', "alias1", "Courier" ) );
    // alias defined, composite font not defined, and character
    // is defined by the logical font.
    assertTrue( isMappedTo( '1', "alias2", "Helvetica" ) );

    // alias not defined, composite font defined, and character
    // is defined by the block font.
    assertTrue( isMappedTo( '1', "Symbol", "Courier" ) );
    // alias not defined, composite font not defined, and character
    // is defined by the logical font.
    assertTrue( isMappedTo( '1', "Helvetica", "Helvetica" ) );

    // alias: defined; composite-font: defined; block: defined;
    assertTrue( isMappedTo( (char) 0xe81, "Symbol", "Courier" ) );
    // alias: defined; composite-font: defined; block: not defined;
    // all-fonts:not define the block
    assertTrue( isMappedTo( (char) 0xff01, "Symbol", "Times Roman" ) );
}
FontConfigReaderTest.java 文件源码 项目:birt 阅读 21 收藏 0 点赞 0 评论 0
public void testFontConfigParser( ) throws IOException,
        FactoryConfigurationError, ParserConfigurationException,
        SAXException
{
    fontMappingManager = getFontMappingManager( "fontsConfigParser.xml" );
    Map fontAliases = fontMappingManager.getFontAliases( );
    assertEquals( 1, fontAliases.size( ) );
    assertEquals( "Times-Roman", fontAliases.get( "test alias" ) );

    Map compositeFonts = fontMappingManager.getCompositeFonts( );
    assertEquals( 1, compositeFonts.size( ) );
    CompositeFont testFont = (CompositeFont) compositeFonts
            .get( "test font" );
    assertEquals( "Symbol", testFont.getUsedFont( (char) 0 ) );
    assertEquals( "Symbol", testFont.getUsedFont( (char) 0x7F ) );
    assertEquals( "Helvetica", testFont.getDefaultFont( ) );
}
TqlSession.java 文件源码 项目:mulgara 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Loads the embedded logging configuration (from the JAR file).
 */
private void loadLoggingConfig() {
  // get a URL from the classloader for the logging configuration
  URL log4jConfigUrl = ClassLoader.getSystemResource(LOG4J_CONFIG_PATH);

  // if we didn't get a URL, tell the user that something went wrong
  if (log4jConfigUrl == null) {
    System.err.println("Unable to find logging configuration file in JAR " +
        "with " + LOG4J_CONFIG_PATH + ", reverting to default configuration.");
    BasicConfigurator.configure();
  } else {
    try {
      // configure the logging service
      DOMConfigurator.configure(log4jConfigUrl);
      log.info("Using logging configuration from " + log4jConfigUrl);
    } catch (FactoryConfigurationError e) {
      System.err.println("Unable to configure logging service");
    }
  }
}
BaseXMLBuilder.java 文件源码 项目:java-xmlbuilder 阅读 42 收藏 0 点赞 0 评论 0
/**
 * Construct an XML Document with a default namespace with the given
 * root element.
 *
 * @param name
 * the name of the document's root element.
 * @param namespaceURI
 * default namespace URI for document, ignored if null or empty.
 * @param enableExternalEntities
 * enable external entities; beware of XML External Entity (XXE) injection.
 * @param isNamespaceAware
 * enable or disable namespace awareness in the underlying
 * {@link DocumentBuilderFactory}
 * @return
 * an XML Document.
 *
 * @throws FactoryConfigurationError
 * @throws ParserConfigurationException
 */
protected static Document createDocumentImpl(
    String name, String namespaceURI, boolean enableExternalEntities,
    boolean isNamespaceAware)
    throws ParserConfigurationException, FactoryConfigurationError
{
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(isNamespaceAware);
    enableOrDisableExternalEntityParsing(factory, enableExternalEntities);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.newDocument();
    Element rootElement = null;
    if (namespaceURI != null && namespaceURI.length() > 0) {
        rootElement = document.createElementNS(namespaceURI, name);
    } else {
        rootElement = document.createElement(name);
    }
    document.appendChild(rootElement);
    return document;
}
XmlSettingsTests.java 文件源码 项目:spring-rich-client 阅读 18 收藏 0 点赞 0 评论 0
public void testSave() throws ParserConfigurationException, FactoryConfigurationError, IOException {
    Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    Element parentElement = doc.createElement("settings");
    parentElement.setAttribute("name", "parent-settings");
    doc.appendChild(parentElement);
    Element childElement = doc.createElement("settings");
    childElement.setAttribute("name", "child-settings");
    parentElement.appendChild(childElement);

    TestableXmlSettingsReaderWriter readerWriter = new TestableXmlSettingsReaderWriter();
    RootXmlSettings parentSettings = new RootXmlSettings(doc, readerWriter);
    Settings childSettings = parentSettings.getSettings("child-settings");
    childSettings.save();

    assertEquals(parentSettings, readerWriter.lastWritten);
}
XmlSettingsTests.java 文件源码 项目:spring-rich-client 阅读 18 收藏 0 点赞 0 评论 0
public void testChildSettings() throws ParserConfigurationException, FactoryConfigurationError, SAXException, IOException {
    StringBuffer sb = new StringBuffer();
    sb.append("<?xml version=\"1.0\"?>");
    sb.append("<settings name=\"test-settings\">");
    sb.append("  <entry key=\"key-1\" value=\"value-1\" />");
    sb.append("  <entry key=\"key-2\" value=\"false\" />");
    sb.append("  <entry key=\"key-3\" value=\"1.5\" />");
    sb.append("  <settings name=\"child-settings\">");
    sb.append("    <entry key=\"child-key\" value=\"value\" />");
    sb.append("  </settings>");
    sb.append("</settings>");

    XmlSettings settings = new XmlSettings(createElement(sb.toString()));

    assertEquals(Arrays.asList(new String[] {"child-settings"}), Arrays.asList(settings.getChildSettings()));
}
DomDocumentBuilderFactory.java 文件源码 项目:classpath 阅读 25 收藏 0 点赞 0 评论 0
public DomDocumentBuilderFactory()
{
  try
    {
      DOMImplementationRegistry reg =
        DOMImplementationRegistry.newInstance();
      impl = reg.getDOMImplementation("LS 3.0");
      if (impl == null)
        {
          throw new FactoryConfigurationError("no LS implementations found");
        }
      ls = (DOMImplementationLS) impl;
    }
  catch (Exception e)
    {
      throw new FactoryConfigurationError(e);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号