Exemple #1
0
 /**
  * Create a new {@link DatatypeFactory}
  *
  * @return
  * @throws DatatypeConfigurationException
  */
 public static DatatypeFactory newDatatypeFactory() throws DatatypeConfigurationException {
   boolean tccl_jaxp =
       SystemPropertiesUtil.getSystemProperty(GeneralConstants.TCCL_JAXP, "false")
           .equalsIgnoreCase("true");
   ClassLoader prevTCCL = SecurityActions.getTCCL();
   try {
     if (tccl_jaxp) {
       SecurityActions.setTCCL(XMLTimeUtil.class.getClassLoader());
     }
     return DatatypeFactory.newInstance();
   } finally {
     if (tccl_jaxp) {
       SecurityActions.setTCCL(prevTCCL);
     }
   }
 }
  /**
   * Creates a namespace aware {@link DocumentBuilderFactory}. The returned instance is cached and
   * shared between different threads.
   *
   * @return
   */
  private static DocumentBuilderFactory getDocumentBuilderFactory() {
    boolean tccl_jaxp =
        SystemPropertiesUtil.getSystemProperty(GeneralConstants.TCCL_JAXP, "false")
            .equalsIgnoreCase("true");
    ClassLoader prevTCCL = SecurityActions.getTCCL();
    if (documentBuilderFactory == null) {
      try {
        if (tccl_jaxp) {
          SecurityActions.setTCCL(DocumentUtil.class.getClassLoader());
        }
        documentBuilderFactory = DocumentBuilderFactory.newInstance();
        documentBuilderFactory.setNamespaceAware(true);
        documentBuilderFactory.setXIncludeAware(true);
      } finally {
        if (tccl_jaxp) {
          SecurityActions.setTCCL(prevTCCL);
        }
      }
    }

    return documentBuilderFactory;
  }