Skip to content

Commit f3b8d71

Browse files
committed
Consistent use of tabs for sample code in the reference documentation
1 parent 47383fc commit f3b8d71

8 files changed

+818
-707
lines changed

src/asciidoc/core-beans.adoc

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ delegates, e.g. with `XmlBeanDefinitionReader` for XML files:
370370
----
371371
GenericApplicationContext context = new GenericApplicationContext();
372372
new XmlBeanDefinitionReader(context).loadBeanDefinitions("services.xml", "daos.xml");
373-
context.refresh();
373+
context.refresh();
374374
----
375375

376376
Or with `GroovyBeanDefinitionReader` for Groovy files:
@@ -380,7 +380,7 @@ Or with `GroovyBeanDefinitionReader` for Groovy files:
380380
----
381381
GenericApplicationContext context = new GenericApplicationContext();
382382
new GroovyBeanDefinitionReader(context).loadBeanDefinitions("services.groovy", "daos.groovy");
383-
context.refresh();
383+
context.refresh();
384384
----
385385

386386
Such reader delegates can be mixed and matched on the same `ApplicationContext`,
@@ -1682,7 +1682,7 @@ The preceding example is equivalent to the following Java code:
16821682
[source,java,indent=0]
16831683
[subs="verbatim,quotes"]
16841684
----
1685-
exampleBean.setEmail("")
1685+
exampleBean.setEmail("");
16861686
----
16871687

16881688
The `<null/>` element handles `null` values. For example:
@@ -1702,7 +1702,7 @@ The above configuration is equivalent to the following Java code:
17021702
[source,java,indent=0]
17031703
[subs="verbatim,quotes"]
17041704
----
1705-
exampleBean.setEmail(null)
1705+
exampleBean.setEmail(null);
17061706
----
17071707

17081708

@@ -3853,7 +3853,6 @@ Find below the custom `BeanPostProcessor` implementation class definition:
38533853
package scripting;
38543854
38553855
import org.springframework.beans.factory.config.BeanPostProcessor;
3856-
import org.springframework.beans.BeansException;
38573856
38583857
public class InstantiationTracingBeanPostProcessor implements BeanPostProcessor {
38593858
@@ -5261,6 +5260,7 @@ For details about the effects of combining various lifecycle mechanisms, see
52615260

52625261
[[beans-classpath-scanning]]
52635262
== Classpath scanning and managed components
5263+
52645264
Most examples in this chapter use XML to specify the configuration metadata that produces
52655265
each `BeanDefinition` within the Spring container. The previous section
52665266
(<<beans-annotation-config>>) demonstrates how to provide a lot of the configuration
@@ -5427,7 +5427,7 @@ comma/semicolon/space-separated list that includes the parent package of each cl
54275427
@Configuration
54285428
@ComponentScan(basePackages = "org.example")
54295429
public class AppConfig {
5430-
...
5430+
...
54315431
}
54325432
----
54335433

@@ -5532,12 +5532,12 @@ and using "stub" repositories instead.
55325532
[subs="verbatim,quotes"]
55335533
----
55345534
@Configuration
5535-
@ComponentScan(basePackages = "org.example",
5536-
includeFilters = @Filter(type = FilterType.REGEX, pattern = ".*Stub.*Repository"),
5537-
excludeFilters = @Filter(Repository.class))
5538-
public class AppConfig {
5539-
...
5540-
}
5535+
@ComponentScan(basePackages = "org.example",
5536+
includeFilters = @Filter(type = FilterType.REGEX, pattern = ".*Stub.*Repository"),
5537+
excludeFilters = @Filter(Repository.class))
5538+
public class AppConfig {
5539+
...
5540+
}
55415541
----
55425542

55435543
and the equivalent using XML
@@ -5767,10 +5767,10 @@ fully-qualified class name when configuring the scanner:
57675767
[subs="verbatim,quotes"]
57685768
----
57695769
@Configuration
5770-
@ComponentScan(basePackages = "org.example", nameGenerator = MyNameGenerator.class)
5771-
public class AppConfig {
5772-
...
5773-
}
5770+
@ComponentScan(basePackages = "org.example", nameGenerator = MyNameGenerator.class)
5771+
public class AppConfig {
5772+
...
5773+
}
57745774
----
57755775

57765776
[source,xml,indent=0]
@@ -5824,8 +5824,8 @@ fully-qualified class name when configuring the scanner:
58245824
@Configuration
58255825
@ComponentScan(basePackages = "org.example", scopeResolver = MyScopeResolver.class)
58265826
public class AppConfig {
5827-
...
5828-
}
5827+
...
5828+
}
58295829
----
58305830

58315831
[source,xml,indent=0]
@@ -5849,8 +5849,8 @@ the following configuration will result in standard JDK dynamic proxies:
58495849
@Configuration
58505850
@ComponentScan(basePackages = "org.example", scopedProxy = ScopedProxyMode.INTERFACES)
58515851
public class AppConfig {
5852-
...
5853-
}
5852+
...
5853+
}
58545854
----
58555855

58565856
[source,xml,indent=0]
@@ -6108,7 +6108,7 @@ exact same way as when using Spring annotations:
61086108
@Configuration
61096109
@ComponentScan(basePackages = "org.example")
61106110
public class AppConfig {
6111-
...
6111+
...
61126112
}
61136113
----
61146114

@@ -6338,7 +6338,7 @@ To enable component scanning, just annotate your `@Configuration` class as follo
63386338
@Configuration
63396339
@ComponentScan(basePackages = "com.acme")
63406340
public class AppConfig {
6341-
...
6341+
...
63426342
}
63436343
----
63446344

@@ -6657,7 +6657,7 @@ method directly during construction:
66576657
public Foo foo() {
66586658
Foo foo = new Foo();
66596659
foo.init();
6660-
return foo;
6660+
return foo;
66616661
}
66626662
66636663
// ...
@@ -6975,7 +6975,7 @@ another configuration class:
69756975
@Configuration
69766976
public class ConfigA {
69776977
6978-
@Bean
6978+
@Bean
69796979
public A a() {
69806980
return new A();
69816981
}
@@ -8645,18 +8645,18 @@ environment provides:
86458645
[subs="verbatim,quotes"]
86468646
----
86478647
public class EntityCreatedEvent<T>
8648-
extends ApplicationEvent implements ResolvableTypeProvider {
8648+
extends ApplicationEvent implements ResolvableTypeProvider {
86498649
8650-
public EntityCreatedEvent(T entity) {
8651-
super(entity);
8652-
}
8650+
public EntityCreatedEvent(T entity) {
8651+
super(entity);
8652+
}
86538653
8654-
@Override
8655-
public ResolvableType getResolvableType() {
8656-
return ResolvableType.forClassWithGenerics(getClass(),
8657-
ResolvableType.forInstance(getSource()));
8658-
}
8659-
}
8654+
@Override
8655+
public ResolvableType getResolvableType() {
8656+
return ResolvableType.forClassWithGenerics(getClass(),
8657+
ResolvableType.forInstance(getSource()));
8658+
}
8659+
}
86608660
----
86618661

86628662
[TIP]

src/asciidoc/core-resources.adoc

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
= Resources
44

55

6+
7+
68
[[resources-introduction]]
79
== Introduction
10+
811
Java's standard `java.net.URL` class and standard handlers for various URL prefixes
912
unfortunately are not quite adequate enough for all access to low-level resources. For
1013
example, there is no standardized `URL` implementation that may be used to access a
@@ -15,6 +18,8 @@ quite complicated, and the `URL` interface still lacks some desirable functional
1518
such as a method to check for the existence of the resource being pointed to.
1619

1720

21+
22+
1823
[[resources-resource]]
1924
== The Resource interface
2025

@@ -378,6 +383,7 @@ used. The following two examples show how to force a `ClassPathResource` and a
378383

379384
[[resources-app-ctx-construction]]
380385
=== Constructing application contexts
386+
381387
An application context constructor (for a specific application context type) generally
382388
takes a string or array of strings as the location path(s) of the resource(s) such as
383389
XML files that make up the definition of the context.
@@ -439,8 +445,8 @@ this:
439445
----
440446
com/
441447
foo/
442-
services.xml
443-
daos.xml
448+
services.xml
449+
daos.xml
444450
MessengerService.class
445451
----
446452

@@ -461,6 +467,7 @@ on the various constructors.
461467

462468
[[resources-app-ctx-wildcards-in-resource-paths]]
463469
=== Wildcards in application context constructor resource paths
470+
464471
The resource paths in application context constructor values may be a simple path (as
465472
shown above) which has a one-to-one mapping to a target Resource, or alternately may
466473
contain the special "classpath*:" prefix and/or internal Ant-style regular expressions
@@ -481,6 +488,7 @@ a resource points to just one resource at a time.
481488

482489
[[resources-app-ctx-ant-patterns-in-paths]]
483490
==== Ant-style Patterns
491+
484492
When the path location contains an Ant-style pattern, for example:
485493

486494
[literal]
@@ -503,6 +511,7 @@ the wildcards.
503511

504512
[[resources-app-ctx-portability]]
505513
===== Implications on portability
514+
506515
If the specified path is already a file URL (either explicitly, or implicitly because
507516
the base `ResourceLoader` is a filesystem one, then wildcarding is guaranteed to work in
508517
a completely portable fashion.
@@ -525,7 +534,7 @@ environment before you rely on it.
525534

526535

527536
[[resources-classpath-wildcards]]
528-
==== The Classpath*: portability classpath*: prefix
537+
==== The classpath*: prefix
529538

530539
When constructing an XML-based application context, a location string may use the
531540
special `classpath*:` prefix:
@@ -565,13 +574,28 @@ strategy described above is used for the wildcard subpath.
565574

566575
[[resources-wildcards-in-path-other-stuff]]
567576
==== Other notes relating to wildcards
577+
568578
Please note that `classpath*:` when combined with Ant-style patterns will only work
569579
reliably with at least one root directory before the pattern starts, unless the actual
570580
target files reside in the file system. This means that a pattern like
571-
`classpath*:*.xml` will not retrieve files from the root of jar files but rather only
572-
from the root of expanded directories. This originates from a limitation in the JDK's
581+
`classpath*:*.xml` might not retrieve files from the root of jar files but rather only
582+
from the root of expanded directories.
583+
584+
Spring's ability to retrieve classpath entries originates from the JDK's
573585
`ClassLoader.getResources()` method which only returns file system locations for a
574-
passed-in empty string (indicating potential roots to search).
586+
passed-in empty string (indicating potential roots to search). Spring evaluates
587+
`URLClassLoader` runtime configuration and the "java.class.path" manifest in jar files
588+
as well but this is not guaranteed to lead to portable behavior.
589+
590+
[NOTE]
591+
====
592+
The scanning of classpath packages requires the presence of corresponding directory
593+
entries in the classpath. When you build JARs with Ant, make sure that you do __not__
594+
activate the files-only switch of the JAR task. Also, classpath directories may not
595+
get exposed based on security policies in some environments, e.g. standalone apps on
596+
JDK 1.7.0_45 and higher (which requires 'Trusted-Library' setup in your manifests; see
597+
http://stackoverflow.com/questions/19394570/java-jre-7u45-breaks-classloader-getresources).
598+
====
575599

576600
Ant-style patterns with `classpath:` resources are not guaranteed to find matching
577601
resources if the root package to search is available in multiple class path locations.
@@ -663,4 +687,3 @@ just force the use of a `UrlResource`, by using the `file:` URL prefix.
663687
ApplicationContext ctx =
664688
new FileSystemXmlApplicationContext("file:///conf/context.xml");
665689
----
666-

0 commit comments

Comments
 (0)