polishing

This commit is contained in:
Juergen Hoeller 2009-11-12 02:27:31 +00:00
parent 1c839dbe9c
commit 155f6b1aa1
2 changed files with 12 additions and 14 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2009 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.
@ -28,10 +28,9 @@ package org.springframework.core;
* {@link org.springframework.context.ApplicationContext}. * {@link org.springframework.context.ApplicationContext}.
* *
* <p>Note: PriorityOrdered post-processor beans are initialized in * <p>Note: PriorityOrdered post-processor beans are initialized in
* a special phase, ahead of other post-postprocessor beans. This * a special phase, ahead of other post-processor beans. This subtly
* subtly affects their autowiring behavior: They will only be * affects their autowiring behavior: They will only be autowired against
* autowired against beans which do not require eager initialization * beans which do not require eager initialization for type matching.
* for type matching.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.5 * @since 2.5

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2009 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.
@ -21,7 +21,6 @@ import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import javax.persistence.spi.PersistenceUnitTransactionType; import javax.persistence.spi.PersistenceUnitTransactionType;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
@ -129,8 +128,8 @@ class PersistenceUnitReader {
List<SpringPersistenceUnitInfo> infos = new LinkedList<SpringPersistenceUnitInfo>(); List<SpringPersistenceUnitInfo> infos = new LinkedList<SpringPersistenceUnitInfo>();
String resourceLocation = null; String resourceLocation = null;
try { try {
for (int i = 0; i < persistenceXmlLocations.length; i++) { for (String location : persistenceXmlLocations) {
Resource[] resources = this.resourcePatternResolver.getResources(persistenceXmlLocations[i]); Resource[] resources = this.resourcePatternResolver.getResources(location);
for (Resource resource : resources) { for (Resource resource : resources) {
resourceLocation = resource.toString(); resourceLocation = resource.toString();
InputStream stream = resource.getInputStream(); InputStream stream = resource.getInputStream();
@ -192,8 +191,8 @@ class PersistenceUnitReader {
* @return an existing resource, or <code>null</code> if none found * @return an existing resource, or <code>null</code> if none found
*/ */
protected Resource findSchemaResource() { protected Resource findSchemaResource() {
for (int i = 0; i < SCHEMA_RESOURCE_LOCATIONS.length; i++) { for (String location : SCHEMA_RESOURCE_LOCATIONS) {
Resource schemaLocation = this.resourcePatternResolver.getResource(SCHEMA_RESOURCE_LOCATIONS[i]); Resource schemaLocation = this.resourcePatternResolver.getResource(location);
if (schemaLocation.exists()) { if (schemaLocation.exists()) {
return schemaLocation; return schemaLocation;
} }
@ -210,7 +209,7 @@ class PersistenceUnitReader {
Element persistence = document.getDocumentElement(); Element persistence = document.getDocumentElement();
URL unitRootURL = determinePersistenceUnitRootUrl(resource); URL unitRootURL = determinePersistenceUnitRootUrl(resource);
List<Element> units = (List<Element>) DomUtils.getChildElementsByTagName(persistence, PERSISTENCE_UNIT); List<Element> units = DomUtils.getChildElementsByTagName(persistence, PERSISTENCE_UNIT);
for (Element unit : units) { for (Element unit : units) {
SpringPersistenceUnitInfo info = parsePersistenceUnitInfo(unit); SpringPersistenceUnitInfo info = parsePersistenceUnitInfo(unit);
info.setPersistenceUnitRootUrl(unitRootURL); info.setPersistenceUnitRootUrl(unitRootURL);
@ -346,8 +345,8 @@ class PersistenceUnitReader {
String value = DomUtils.getTextValue(element).trim(); String value = DomUtils.getTextValue(element).trim();
if (StringUtils.hasText(value)) { if (StringUtils.hasText(value)) {
Resource[] resources = this.resourcePatternResolver.getResources(value); Resource[] resources = this.resourcePatternResolver.getResources(value);
for (int i = 0; i < resources.length; i++) { for (Resource resource : resources) {
unitInfo.addJarFileUrl(resources[i].getURL()); unitInfo.addJarFileUrl(resource.getURL());
} }
} }
} }