This repository is a collection of "just for fun" composed annotations for use with the Spring Framework.
The goal of this project is to demonstrate the power of composed annotations
and the use of @AliasFor
for overriding attributes in meta-annotations by
translating common Spring annotations into different languages. In this
context, the term polyglot therefore refers to spoken languages, not
programming languages.
And who knows...? Perhaps some of these translated annotations will someday make it into the Spring Framework.
The following languages currently have one or more translated annotations that have been submitted to this project.
- German: see DeutscheIntegrationsTests
- Hipster: see HipsterTests
- Japanese: see JapaneseIntegrationTests and SushiTests
- Polish: see PolskieTestyIntegracijne
For example, the following is what an integration test in Spring can look
like when @ContextConfiguration
is translated into German. Yes, this
test actually runs: see DeutscheIntegrationsTests for details.
@Kontextkonfiguration(
Konfigurationsklassen = { LokaleTestkonfiguration.class },
XmlDateienOderGroovySkripte = { /* keine */ },
RessourcenErben = falsch,
Initialisierungsprogramme = { /* keine */ },
InitialisierungsprogrammeErben = falsch,
Ladeprogramm = AnnotationConfigContextLoader.class,
Name = "In diesem Fall spielt der Name keine Rolle."
)
public final class DeutscheIntegrationsTests {
@AutomatischVerdrahtet(erforderlich = jawohl)
private String Nachricht;
@Test
public void nachrichtPrüfen() {
esWirdErwartetDass(Nachricht, istGleich("Alles in Ordnung"));
}
@Konfiguration
static class LokaleTestkonfiguration {
@Bohne
String Nachricht() {
return "Alles in Ordnung";
}
}
}
Yes, this test actually runs: see HipsterTests for details.
@RunWith(SpringFoo.class)
@Konfigz(klassez = Konfig.class, listenToYoParents = false, whoDat = "Not I said the fly")
public class HipsterTests {
@Autowired
String message;
@Test
public void checkItOut() {
assertEquals("Keepin' it real!", message);
}
}
Feel free to contribute your own translated annotations by submitting pull requests to this repository.
Although the spring-polyglot
project is currently just for demonstration purposes,
there is a slight chance that annotations from this project will eventually be
incorporated into official Spring projects. In order to have your pull requests
accepted, we therefore ask that you sign the Contributor License Agreement and
document that you have done so in the commit message or comments of your pull request.
The Spring Polyglot project is released under version 2.0 of the Apache License.
- Spring Annotation Programming Model: official wiki page from the Spring team
- Spring Composed: a collection of "serious" composed annotations for use with the Spring Framework
Spring Polyglot uses a Gradle-based build system. In the instructions
below, ./gradlew
is invoked from the root of the project and serves as
a cross-platform, self-contained bootstrap mechanism for the build.
- Git
- JDK 8 update 60 or later
- Spring Framework 4.2.1 or later
Annotations in the spring-polyglot
project rely on @AliasFor
which
was introduced in Spring Framework 4.2 and therefore require at least Spring
Framework 4.2.1 to work properly.
Be sure that your JAVA_HOME
environment variable points to the jdk1.8.0
folder
extracted from the JDK download.
Build all JARs, distribution ZIP files, and docs:
./gradlew build
./gradlew install