Browse Source

Polishing

pull/32864/head
Juergen Hoeller 2 years ago
parent
commit
65e1337d35
  1. 7
      spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java
  2. 20
      spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java

7
spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java

@ -20,11 +20,14 @@ import org.junit.jupiter.api.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringConfiguredWithAutoProxyingTests { /**
* @author Ramnivas Laddad
* @author Juergen Hoeller
*/
class SpringConfiguredWithAutoProxyingTests {
@Test @Test
void springConfiguredAndAutoProxyUsedTogether() { void springConfiguredAndAutoProxyUsedTogether() {
// instantiation is sufficient to trigger failure if this is going to fail...
new ClassPathXmlApplicationContext("org/springframework/beans/factory/aspectj/springConfigured.xml"); new ClassPathXmlApplicationContext("org/springframework/beans/factory/aspectj/springConfigured.xml");
} }

20
spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -154,7 +154,7 @@ final class PersistenceUnitReader {
/** /**
* Validate the given stream and return a valid DOM document for parsing. * Validate the given stream and return a valid DOM document for parsing.
*/ */
protected Document buildDocument(ErrorHandler handler, InputStream stream) Document buildDocument(ErrorHandler handler, InputStream stream)
throws ParserConfigurationException, SAXException, IOException { throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
@ -168,9 +168,7 @@ final class PersistenceUnitReader {
/** /**
* Parse the validated document and add entries to the given unit info list. * Parse the validated document and add entries to the given unit info list.
*/ */
protected List<SpringPersistenceUnitInfo> parseDocument( void parseDocument(Resource resource, Document document, List<SpringPersistenceUnitInfo> infos) throws IOException {
Resource resource, Document document, List<SpringPersistenceUnitInfo> infos) throws IOException {
Element persistence = document.getDocumentElement(); Element persistence = document.getDocumentElement();
String version = persistence.getAttribute(PERSISTENCE_VERSION); String version = persistence.getAttribute(PERSISTENCE_VERSION);
URL rootUrl = determinePersistenceUnitRootUrl(resource); URL rootUrl = determinePersistenceUnitRootUrl(resource);
@ -179,14 +177,12 @@ final class PersistenceUnitReader {
for (Element unit : units) { for (Element unit : units) {
infos.add(parsePersistenceUnitInfo(unit, version, rootUrl)); infos.add(parsePersistenceUnitInfo(unit, version, rootUrl));
} }
return infos;
} }
/** /**
* Parse the unit info DOM element. * Parse the unit info DOM element.
*/ */
protected SpringPersistenceUnitInfo parsePersistenceUnitInfo( SpringPersistenceUnitInfo parsePersistenceUnitInfo(
Element persistenceUnit, String version, @Nullable URL rootUrl) throws IOException { Element persistenceUnit, String version, @Nullable URL rootUrl) throws IOException {
SpringPersistenceUnitInfo unitInfo = new SpringPersistenceUnitInfo(); SpringPersistenceUnitInfo unitInfo = new SpringPersistenceUnitInfo();
@ -253,7 +249,7 @@ final class PersistenceUnitReader {
/** /**
* Parse the {@code property} XML elements. * Parse the {@code property} XML elements.
*/ */
protected void parseProperties(Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) { void parseProperties(Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) {
Element propRoot = DomUtils.getChildElementByTagName(persistenceUnit, PROPERTIES); Element propRoot = DomUtils.getChildElementByTagName(persistenceUnit, PROPERTIES);
if (propRoot == null) { if (propRoot == null) {
return; return;
@ -269,7 +265,7 @@ final class PersistenceUnitReader {
/** /**
* Parse the {@code class} XML elements. * Parse the {@code class} XML elements.
*/ */
protected void parseManagedClasses(Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) { void parseManagedClasses(Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) {
List<Element> classes = DomUtils.getChildElementsByTagName(persistenceUnit, MANAGED_CLASS_NAME); List<Element> classes = DomUtils.getChildElementsByTagName(persistenceUnit, MANAGED_CLASS_NAME);
for (Element element : classes) { for (Element element : classes) {
String value = DomUtils.getTextValue(element).trim(); String value = DomUtils.getTextValue(element).trim();
@ -282,7 +278,7 @@ final class PersistenceUnitReader {
/** /**
* Parse the {@code mapping-file} XML elements. * Parse the {@code mapping-file} XML elements.
*/ */
protected void parseMappingFiles(Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) { void parseMappingFiles(Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) {
List<Element> files = DomUtils.getChildElementsByTagName(persistenceUnit, MAPPING_FILE_NAME); List<Element> files = DomUtils.getChildElementsByTagName(persistenceUnit, MAPPING_FILE_NAME);
for (Element element : files) { for (Element element : files) {
String value = DomUtils.getTextValue(element).trim(); String value = DomUtils.getTextValue(element).trim();
@ -295,7 +291,7 @@ final class PersistenceUnitReader {
/** /**
* Parse the {@code jar-file} XML elements. * Parse the {@code jar-file} XML elements.
*/ */
protected void parseJarFiles(Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) throws IOException { void parseJarFiles(Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) throws IOException {
List<Element> jars = DomUtils.getChildElementsByTagName(persistenceUnit, JAR_FILE_URL); List<Element> jars = DomUtils.getChildElementsByTagName(persistenceUnit, JAR_FILE_URL);
for (Element element : jars) { for (Element element : jars) {
String value = DomUtils.getTextValue(element).trim(); String value = DomUtils.getTextValue(element).trim();

Loading…
Cancel
Save