Skip to content

Commit

Permalink
Merge pull request #235 from dmatej/xpathfactory
Browse files Browse the repository at this point in the history
  • Loading branch information
arjantijms committed Sep 26, 2022
2 parents 2ae45e8 + 2ccb17a commit d79b3b1
Show file tree
Hide file tree
Showing 8 changed files with 577 additions and 855 deletions.
192 changes: 91 additions & 101 deletions impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
<parent>
<groupId>org.eclipse.ee4j</groupId>
<artifactId>project</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
<relativePath/>
</parent>

<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Jakarta Standard Tag Library Implementation</name>
Expand Down Expand Up @@ -106,12 +106,20 @@
<dependency>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.2</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down Expand Up @@ -172,7 +180,7 @@
</execution>
</executions>
</plugin>

<!-- Restricts the Java version to 11 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -183,13 +191,6 @@
</configuration>
</plugin>

<!-- Execute unit tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M6</version>
</plugin>

<!-- Creates the OSGi MANIFEST.MF file -->
<plugin>
<groupId>org.apache.felix</groupId>
Expand Down Expand Up @@ -223,17 +224,15 @@
org.glassfish.jstl.integration
</Export-Package>
<Import-Package>
!org.apache.xpath,
!org.apache.xpath.objects,
!org.apache.xpath.jaxp,
!org.apache.bcel,
!org.apache.regexp,
!org.apache.xml,
!org.apache.xml.dtm,
!org.apache.xml.utils,
!org.apache.xalan,
!org.apache.xalan.res,
!org.apache.xpath,
!org.apache.xpath.jaxp,
!org.apache.xpath.objects,
!org.apache.xpath.res,
!org.apache.regexp,
!org.apache.bcel,
!java_cup.runtime,
!trax,
org.xml.sax.ext,
Expand All @@ -251,7 +250,7 @@
</execution>
</executions>
</plugin>

<!-- Adds the manifest file created by the org.apache.felix:maven-bundle-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -272,7 +271,7 @@
</archive>
</configuration>
</plugin>

<!-- Post process the jar we created by including XALAN and moving packages -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -333,28 +332,22 @@
</execution>
</executions>
</plugin>

<!-- Creates the source jar -->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<includePom>true</includePom>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<!--
Create Javadoc for IMPL jar
-->

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
Expand All @@ -375,7 +368,6 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.1</version>
<configuration>
Expand Down Expand Up @@ -414,76 +406,74 @@ Copyright &#169; 2019, ${current.year} Eclipse Foundation. All rights reserved.
</plugin>
</plugins>
</build>

<profiles>
<!--
Generation of TLDDocs typically fails with the following when excuted directly from the impl module:

[WARNING]
Could not transfer metadata org.glassfish.web:tagsdoc:1.0-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/):

transfer failed for http://0.0.0.0/org/glassfish/web/tagsdoc/1.0-SNAPSHOT/maven-metadata.xml

[WARNING]
org.glassfish.web:tagsdoc:1.0-SNAPSHOT/maven-metadata.xmlfailed to transfer from http://0.0.0.0/ during a previous attempt.
This failure was cached in the local repository and resolution will not be reattempted until the update interval of
maven-default-http-blocker has elapsed or updates are forced.


Original error:

Could not transfer metadata org.glassfish.web:tagsdoc:1.0-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/):

transfer failed for http://0.0.0.0/org/glassfish/web/tagsdoc/1.0-SNAPSHOT/maven-metadata.xml


-->
<profile>
<id>tlddocs</id>
<build>
<plugins>
<!-- Generate the TLD docs -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>generateTldDoc</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>false</includeProjectDependencies>
<mainClass>com.sun.tlddoc.TLDDoc</mainClass>
<arguments>
<argument>-doctitle</argument>
<argument>Jakarta Tags doc</argument>
<argument>-windowtitle</argument>
<argument>Jakarta Tags Doc</argument>
<argument>-d</argument>
<argument>${project.build.directory}/tlddoc</argument>
<argument>${project.basedir}/src/main/resources/META-INF/sql.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/x.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/fmt.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/c.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/fn.tld</argument>
</arguments>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>tagsdoc</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<profiles>
<!--
Generation of TLDDocs typically fails with the following when excuted directly from the impl module:

[WARNING]
Could not transfer metadata org.glassfish.web:tagsdoc:1.0-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/):

transfer failed for http://0.0.0.0/org/glassfish/web/tagsdoc/1.0-SNAPSHOT/maven-metadata.xml

[WARNING]
org.glassfish.web:tagsdoc:1.0-SNAPSHOT/maven-metadata.xmlfailed to transfer from http://0.0.0.0/ during a previous attempt.
This failure was cached in the local repository and resolution will not be reattempted until the update interval of
maven-default-http-blocker has elapsed or updates are forced.


Original error:

Could not transfer metadata org.glassfish.web:tagsdoc:1.0-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/):

transfer failed for http://0.0.0.0/org/glassfish/web/tagsdoc/1.0-SNAPSHOT/maven-metadata.xml
-->
<profile>
<id>tlddocs</id>
<build>
<plugins>
<!-- Generate the TLD docs -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>generateTldDoc</id>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>false</includeProjectDependencies>
<mainClass>com.sun.tlddoc.TLDDoc</mainClass>
<arguments>
<argument>-doctitle</argument>
<argument>Jakarta Tags doc</argument>
<argument>-windowtitle</argument>
<argument>Jakarta Tags Doc</argument>
<argument>-d</argument>
<argument>${project.build.directory}/tlddoc</argument>
<argument>${project.basedir}/src/main/resources/META-INF/sql.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/x.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/fmt.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/c.tld</argument>
<argument>${project.basedir}/src/main/resources/META-INF/fn.tld</argument>
</arguments>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>tagsdoc</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.apache.taglibs.standard.tag.common.xml;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

/**
* Provides preconfigured {@link DocumentBuilder} instances.
*
* @author David Matejcek
*/
public class DocumentBuilderProvider {

private static final DocumentBuilderFactory DBF;
private static final DocumentBuilderFactory DBF_SECURE;
static {
DBF = DocumentBuilderFactory.newInstance();
DBF.setNamespaceAware(true);
DBF.setValidating(false);

DBF_SECURE = DocumentBuilderFactory.newInstance();
DBF_SECURE.setNamespaceAware(true);
DBF_SECURE.setValidating(false);
try {
DBF_SECURE.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
} catch (ParserConfigurationException e) {
throw new Error("Parser does not support secure processing");
}
}

/**
* Creates a namespace-aware {@link DocumentBuilder} with disabled validation.
* <p>
* Note that {@link DocumentBuilder} instances are not thread-safe and their implementation can
* be chosen as described in {@link DocumentBuilderFactory} documentation.
*
* @return new {@link DocumentBuilder} instance.
*/
public static DocumentBuilder createDocumentBuilder() {
try {
return DBF.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new Error("Could not initialize the DocumentBuilder!", e);
}
}


/**
* Creates a namespace-aware {@link DocumentBuilder} with disabled validation and enabled
* {@link XMLConstants#FEATURE_SECURE_PROCESSING}.
* <p>
* Note that {@link DocumentBuilder} instances are not thread-safe and their implementation can
* be chosen as described in {@link DocumentBuilderFactory} documentation.
*
* @return new {@link DocumentBuilder} instance.
*/
public static DocumentBuilder createSecureDocumentBuilder() {
try {
return DBF_SECURE.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new Error("Could not initialize the DocumentBuilder!", e);
}
}
}
Loading

0 comments on commit d79b3b1

Please sign in to comment.