parent
f5edd53d86
commit
46540de694
|
|
@ -717,7 +717,7 @@ annotations.
|
|||
If you are using AspectJ in your project, you need to make sure that the annotation
|
||||
processor only runs once. There are several ways to do this: with Maven, you can
|
||||
configure the `maven-apt-plugin` explicitly and add the dependency to the annotation
|
||||
processor only there. You could also let the AspectJ plugin runs all the processing
|
||||
processor only there. You could also let the AspectJ plugin run all the processing
|
||||
and disable annotation processing in the `maven-compiler-plugin` configuration:
|
||||
|
||||
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
|
||||
|
|
|
|||
|
|
@ -998,7 +998,7 @@ Spring Boot uses http://commons.apache.org/logging[Commons Logging] for all inte
|
|||
logging, but leaves the underlying log implementation open. Default configurations are
|
||||
provided for
|
||||
http://docs.oracle.com/javase/7/docs/api/java/util/logging/package-summary.html[Java Util Logging],
|
||||
http://logging.apache.org/log4j/2.x/[Log4J2] andhttp://logback.qos.ch/[Logback]. In each
|
||||
http://logging.apache.org/log4j/2.x/[Log4J2] and http://logback.qos.ch/[Logback]. In each
|
||||
case loggers are pre-configured to use console output with optional file output also
|
||||
available.
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ final class AsciiBytes {
|
|||
}
|
||||
|
||||
public static int hashCode(String string) {
|
||||
// We're compatible with String's hashcode
|
||||
// We're compatible with String's hashCode().
|
||||
return string.hashCode();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,21 +28,21 @@ import org.springframework.boot.loader.data.RandomAccessData.ResourceAccess;
|
|||
* Parses the central directory from a JAR file.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @see CentralDirectoryVistor
|
||||
* @see CentralDirectoryVisitor
|
||||
*/
|
||||
class CentralDirectoryParser {
|
||||
|
||||
private int CENTRAL_DIRECTORY_HEADER_BASE_SIZE = 46;
|
||||
|
||||
private final List<CentralDirectoryVistor> vistors = new ArrayList<CentralDirectoryVistor>();
|
||||
private final List<CentralDirectoryVisitor> visitors = new ArrayList<CentralDirectoryVisitor>();
|
||||
|
||||
public <T extends CentralDirectoryVistor> T addVistor(T vistor) {
|
||||
this.vistors.add(vistor);
|
||||
return vistor;
|
||||
public <T extends CentralDirectoryVisitor> T addVisitor(T visitor) {
|
||||
this.visitors.add(visitor);
|
||||
return visitor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the source data, triggering {@link CentralDirectoryVistor vistors}.
|
||||
* Parse the source data, triggering {@link CentralDirectoryVisitor visitors}.
|
||||
* @param data the source data
|
||||
* @param skipPrefixBytes if prefix bytes should be skipped
|
||||
* @return The actual archive data without any prefix bytes
|
||||
|
|
@ -87,20 +87,20 @@ class CentralDirectoryParser {
|
|||
|
||||
private void visitStart(CentralDirectoryEndRecord endRecord,
|
||||
RandomAccessData centralDirectoryData) {
|
||||
for (CentralDirectoryVistor vistor : this.vistors) {
|
||||
vistor.visitStart(endRecord, centralDirectoryData);
|
||||
for (CentralDirectoryVisitor visitor : this.visitors) {
|
||||
visitor.visitStart(endRecord, centralDirectoryData);
|
||||
}
|
||||
}
|
||||
|
||||
private void visitFileHeader(int dataOffset, CentralDirectoryFileHeader fileHeader) {
|
||||
for (CentralDirectoryVistor vistor : this.vistors) {
|
||||
vistor.visitFileHeader(fileHeader, dataOffset);
|
||||
for (CentralDirectoryVisitor visitor : this.visitors) {
|
||||
visitor.visitFileHeader(fileHeader, dataOffset);
|
||||
}
|
||||
}
|
||||
|
||||
private void visitEnd() {
|
||||
for (CentralDirectoryVistor vistor : this.vistors) {
|
||||
vistor.visitEnd();
|
||||
for (CentralDirectoryVisitor visitor : this.visitors) {
|
||||
visitor.visitEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ package org.springframework.boot.loader.jar;
|
|||
import org.springframework.boot.loader.data.RandomAccessData;
|
||||
|
||||
/**
|
||||
* Callback vistor triggered by {@link CentralDirectoryParser}.
|
||||
* Callback visitor triggered by {@link CentralDirectoryParser}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
interface CentralDirectoryVistor {
|
||||
interface CentralDirectoryVisitor {
|
||||
|
||||
void visitStart(CentralDirectoryEndRecord endRecord,
|
||||
RandomAccessData centralDirectoryData);
|
||||
|
|
@ -36,7 +36,7 @@ interface FileHeader {
|
|||
boolean hasName(String name, String suffix);
|
||||
|
||||
/**
|
||||
* Return the offset of the load file header withing the archive data.
|
||||
* Return the offset of the load file header within the archive data.
|
||||
* @return the local header offset
|
||||
*/
|
||||
long getLocalHeaderOffset();
|
||||
|
|
|
|||
|
|
@ -109,13 +109,13 @@ public class JarFile extends java.util.jar.JarFile {
|
|||
this.rootFile = rootFile;
|
||||
this.pathFromRoot = pathFromRoot;
|
||||
CentralDirectoryParser parser = new CentralDirectoryParser();
|
||||
this.entries = parser.addVistor(new JarFileEntries(this, filter));
|
||||
parser.addVistor(centralDirectoryVistor());
|
||||
this.entries = parser.addVisitor(new JarFileEntries(this, filter));
|
||||
parser.addVisitor(centralDirectoryVisitor());
|
||||
this.data = parser.parse(data, filter == null);
|
||||
}
|
||||
|
||||
private CentralDirectoryVistor centralDirectoryVistor() {
|
||||
return new CentralDirectoryVistor() {
|
||||
private CentralDirectoryVisitor centralDirectoryVisitor() {
|
||||
return new CentralDirectoryVisitor() {
|
||||
|
||||
@Override
|
||||
public void visitStart(CentralDirectoryEndRecord endRecord,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import org.springframework.boot.loader.data.RandomAccessData.ResourceAccess;
|
|||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class JarFileEntries implements CentralDirectoryVistor, Iterable<JarEntry> {
|
||||
class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
|
||||
|
||||
private static final long LOCAL_FILE_HEADER_SIZE = 30;
|
||||
|
||||
|
|
|
|||
|
|
@ -61,24 +61,24 @@ public class CentralDirectoryParserTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void vistsInOrder() throws Exception {
|
||||
CentralDirectoryVistor vistor = mock(CentralDirectoryVistor.class);
|
||||
public void visitsInOrder() throws Exception {
|
||||
CentralDirectoryVisitor visitor = mock(CentralDirectoryVisitor.class);
|
||||
CentralDirectoryParser parser = new CentralDirectoryParser();
|
||||
parser.addVistor(vistor);
|
||||
parser.addVisitor(visitor);
|
||||
parser.parse(this.jarData, false);
|
||||
InOrder ordered = inOrder(vistor);
|
||||
ordered.verify(vistor).visitStart(any(CentralDirectoryEndRecord.class),
|
||||
InOrder ordered = inOrder(visitor);
|
||||
ordered.verify(visitor).visitStart(any(CentralDirectoryEndRecord.class),
|
||||
any(RandomAccessData.class));
|
||||
ordered.verify(vistor, atLeastOnce())
|
||||
ordered.verify(visitor, atLeastOnce())
|
||||
.visitFileHeader(any(CentralDirectoryFileHeader.class), anyInt());
|
||||
ordered.verify(vistor).visitEnd();
|
||||
ordered.verify(visitor).visitEnd();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void vistRecords() throws Exception {
|
||||
public void visitRecords() throws Exception {
|
||||
Collector collector = new Collector();
|
||||
CentralDirectoryParser parser = new CentralDirectoryParser();
|
||||
parser.addVistor(collector);
|
||||
parser.addVisitor(collector);
|
||||
parser.parse(this.jarData, false);
|
||||
Iterator<CentralDirectoryFileHeader> headers = collector.getHeaders().iterator();
|
||||
assertThat(headers.next().getName().toString(), equalTo("META-INF/"));
|
||||
|
|
@ -94,7 +94,7 @@ public class CentralDirectoryParserTests {
|
|||
assertThat(headers.hasNext(), equalTo(false));
|
||||
}
|
||||
|
||||
private static class Collector implements CentralDirectoryVistor {
|
||||
private static class Collector implements CentralDirectoryVisitor {
|
||||
|
||||
private List<CentralDirectoryFileHeader> headers = new ArrayList<CentralDirectoryFileHeader>();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue