Skip to content

Commit 9781f60

Browse files
committed
DATACMNS-295 - Expose modify-on-creation flag in XML namespace.
Introduced additional attribute in schema in version 1.6. Added parsing of the attribute.
1 parent 645a605 commit 9781f60

File tree

6 files changed

+235
-6
lines changed

6 files changed

+235
-6
lines changed

src/main/java/org/springframework/data/config/AuditingHandlerBeanDefinitionParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012 the original author or authors.
2+
* Copyright 2012-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,7 +69,7 @@ protected void doParse(Element element, BeanDefinitionBuilder builder) {
6969

7070
ParsingUtils.setPropertyValue(builder, element, "set-dates", "dateTimeForNow");
7171
ParsingUtils.setPropertyReference(builder, element, "date-time-provider-ref", "dateTimeProvider");
72-
72+
ParsingUtils.setPropertyValue(builder, element, "modify-on-creation", "modifyOnCreation");
7373
}
7474

7575
private BeanDefinition createLazyInitTargetSourceBeanDefinition(String auditorAwareRef) {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
http\://www.springframework.org/schema/data/repository/spring-repository-1.0.xsd=org/springframework/data/repository/config/spring-repository-1.0.xsd
22
http\://www.springframework.org/schema/data/repository/spring-repository-1.4.xsd=org/springframework/data/repository/config/spring-repository-1.4.xsd
33
http\://www.springframework.org/schema/data/repository/spring-repository-1.5.xsd=org/springframework/data/repository/config/spring-repository-1.5.xsd
4-
http\://www.springframework.org/schema/data/repository/spring-repository.xsd=org/springframework/data/repository/config/spring-repository-1.5.xsd
4+
http\://www.springframework.org/schema/data/repository/spring-repository-1.6.xsd=org/springframework/data/repository/config/spring-repository-1.6.xsd
5+
http\://www.springframework.org/schema/data/repository/spring-repository.xsd=org/springframework/data/repository/config/spring-repository-1.6.xsd

src/main/resources/org/springframework/data/repository/config/spring-repository-1.0.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<xsd:import namespace="http://www.springframework.org/schema/tool" />
1010
<xsd:import namespace="http://www.springframework.org/schema/context"
11-
schemaLocation="http://www.springframework.org/schema/context/spring-context.xsd" />
11+
schemaLocation="http://www.springframework.org/schema/context/spring-context.xsd" />
1212

1313
<xsd:complexType name="repositories">
1414
<xsd:sequence>

src/main/resources/org/springframework/data/repository/config/spring-repository-1.4.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<xsd:import namespace="http://www.springframework.org/schema/tool" />
1010
<xsd:import namespace="http://www.springframework.org/schema/context"
11-
schemaLocation="http://www.springframework.org/schema/context/spring-context.xsd" />
11+
schemaLocation="http://www.springframework.org/schema/context/spring-context.xsd" />
1212

1313
<xsd:complexType name="repositories">
1414
<xsd:sequence>

src/main/resources/org/springframework/data/repository/config/spring-repository-1.5.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<xsd:import namespace="http://www.springframework.org/schema/tool" />
1010
<xsd:import namespace="http://www.springframework.org/schema/context"
11-
schemaLocation="http://www.springframework.org/schema/context/spring-context.xsd" />
11+
schemaLocation="http://www.springframework.org/schema/context/spring-context.xsd" />
1212

1313
<xsd:complexType name="repositories">
1414
<xsd:sequence>
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<xsd:schema xmlns="http://www.springframework.org/schema/data/repository"
3+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4+
xmlns:tool="http://www.springframework.org/schema/tool"
5+
xmlns:context="http://www.springframework.org/schema/context"
6+
targetNamespace="http://www.springframework.org/schema/data/repository"
7+
elementFormDefault="qualified" attributeFormDefault="unqualified">
8+
9+
<xsd:import namespace="http://www.springframework.org/schema/tool" />
10+
<xsd:import namespace="http://www.springframework.org/schema/context"
11+
schemaLocation="http://www.springframework.org/schema/context/spring-context.xsd" />
12+
13+
<xsd:complexType name="repositories">
14+
<xsd:sequence>
15+
<xsd:element name="include-filter" type="context:filterType" minOccurs="0" maxOccurs="unbounded">
16+
<xsd:annotation>
17+
<xsd:documentation><![CDATA[
18+
Controls which eligible types to include for component scanning.
19+
]]></xsd:documentation>
20+
</xsd:annotation>
21+
</xsd:element>
22+
<xsd:element name="exclude-filter" type="context:filterType" minOccurs="0" maxOccurs="unbounded">
23+
<xsd:annotation>
24+
<xsd:documentation><![CDATA[
25+
Controls which eligible types to exclude for component scanning.
26+
]]></xsd:documentation>
27+
</xsd:annotation>
28+
</xsd:element>
29+
</xsd:sequence>
30+
<xsd:attribute name="base-package" type="xsd:string" use="required">
31+
<xsd:annotation>
32+
<xsd:documentation><![CDATA[
33+
Defines the base package where the DAO interface will be tried to be detected.
34+
]]></xsd:documentation>
35+
</xsd:annotation>
36+
</xsd:attribute>
37+
<xsd:attribute name="named-queries-location" type="xsd:string">
38+
<xsd:annotation>
39+
<xsd:documentation><![CDATA[
40+
Defines the location to look for a Properties file containing externally defined queries.
41+
]]></xsd:documentation>
42+
</xsd:annotation>
43+
</xsd:attribute>
44+
</xsd:complexType>
45+
46+
<xsd:complexType name="populator">
47+
<xsd:attribute name="locations" type="xsd:string" use="required">
48+
<xsd:annotation>
49+
<xsd:documentation>
50+
Where to find the files to read the objects from the repository shall be populated with.
51+
</xsd:documentation>
52+
</xsd:annotation>
53+
</xsd:attribute>
54+
<xsd:attribute name="id" type="xsd:string" />
55+
</xsd:complexType>
56+
57+
<!-- XML (Unmarshaller) initializer -->
58+
59+
<xsd:element name="unmarshaller-populator">
60+
<xsd:complexType>
61+
<xsd:complexContent>
62+
<xsd:extension base="populator">
63+
<xsd:attribute name="unmarshaller-ref" type="unmarshallerRefType" use="required" />
64+
</xsd:extension>
65+
</xsd:complexContent>
66+
</xsd:complexType>
67+
</xsd:element>
68+
69+
<xsd:simpleType name="unmarshallerRefType">
70+
<xsd:annotation>
71+
<xsd:appinfo>
72+
<tool:expected-type type="org.springframework.oxm.Unmarshaller" />
73+
</xsd:appinfo>
74+
</xsd:annotation>
75+
<xsd:union memberTypes="xsd:string" />
76+
</xsd:simpleType>
77+
78+
<!-- JSON (Jackson) initializer -->
79+
80+
<xsd:element name="jackson-populator">
81+
<xsd:complexType>
82+
<xsd:complexContent>
83+
<xsd:extension base="populator">
84+
<xsd:attribute name="object-mapper-ref" type="objectMapperType" />
85+
</xsd:extension>
86+
</xsd:complexContent>
87+
</xsd:complexType>
88+
</xsd:element>
89+
90+
<xsd:simpleType name="objectMapperType">
91+
<xsd:annotation>
92+
<xsd:appinfo>
93+
<tool:expected-type type="org.codehaus.jackson.map.ObjectMapper" />
94+
</xsd:appinfo>
95+
</xsd:annotation>
96+
<xsd:union memberTypes="xsd:string" />
97+
</xsd:simpleType>
98+
99+
<xsd:attributeGroup name="repository-attributes">
100+
<xsd:attribute name="repository-impl-postfix" type="xsd:string"/>
101+
<xsd:attribute name="query-lookup-strategy" type="query-strategy"/>
102+
<xsd:attribute name="factory-class" type="classType"/>
103+
</xsd:attributeGroup>
104+
105+
<xsd:attributeGroup name="transactional-repository-attributes">
106+
<xsd:attributeGroup ref="repository-attributes"/>
107+
<xsd:attribute name="transaction-manager-ref" type="transactionManagerRef"/>
108+
</xsd:attributeGroup>
109+
110+
<xsd:attributeGroup name="auditing-attributes">
111+
<xsd:attribute name="auditor-aware-ref">
112+
<xsd:annotation>
113+
<xsd:documentation><![CDATA[
114+
References a bean of type AuditorAware to represent the current principal.
115+
]]></xsd:documentation>
116+
<xsd:appinfo>
117+
<tool:annotation kind="ref">
118+
<tool:assignable-to type="org.springframework.data.domain.AuditorAware" />
119+
</tool:annotation>
120+
</xsd:appinfo>
121+
</xsd:annotation>
122+
</xsd:attribute>
123+
<xsd:attribute name="set-dates" default="true" type="xsd:boolean">
124+
<xsd:annotation>
125+
<xsd:documentation><![CDATA[
126+
Configures whether the creation and modification dates are set.
127+
]]></xsd:documentation>
128+
</xsd:annotation>
129+
</xsd:attribute>
130+
<xsd:attribute name="date-time-provider-ref">
131+
<xsd:annotation>
132+
<xsd:documentation><![CDATA[
133+
Configures a DateTimeProvider that allows customizing which DateTime shall be used for setting
134+
creation and modification dates.
135+
]]></xsd:documentation>
136+
<xsd:appinfo>
137+
<tool:annotation kind="ref">
138+
<tool:assignable-to type="org.springframework.data.jpa.domain.support.DateTimeProvider" />
139+
</tool:annotation>
140+
</xsd:appinfo>
141+
</xsd:annotation>
142+
</xsd:attribute>
143+
<xsd:attribute name="modify-on-creation" default="true" type="xsd:boolean">
144+
<xsd:annotation>
145+
<xsd:documentation><![CDATA[
146+
Configures whether the entity shall be marked as modified on creation.
147+
]]></xsd:documentation>
148+
</xsd:annotation>
149+
</xsd:attribute>
150+
</xsd:attributeGroup>
151+
152+
<xsd:simpleType name="query-strategy">
153+
<xsd:annotation>
154+
<xsd:documentation><![CDATA[
155+
Determines the way query methods are being executed.
156+
]]></xsd:documentation>
157+
</xsd:annotation>
158+
<xsd:restriction base="xsd:string">
159+
<xsd:enumeration value="create-if-not-found">
160+
<xsd:annotation>
161+
<xsd:documentation><![CDATA[
162+
Tries to find a named query but creates a custom query if
163+
none can be found. (Default)
164+
]]></xsd:documentation>
165+
</xsd:annotation>
166+
</xsd:enumeration>
167+
<xsd:enumeration value="create">
168+
<xsd:annotation>
169+
<xsd:documentation><![CDATA[
170+
Creates a query from the query method's name.
171+
]]></xsd:documentation>
172+
</xsd:annotation>
173+
</xsd:enumeration>
174+
<xsd:enumeration value="use-declared-query">
175+
<xsd:annotation>
176+
<xsd:documentation><![CDATA[
177+
Uses a declared query to execute. Fails if no
178+
declared query (either through named query or through @Query)
179+
is defined.
180+
]]></xsd:documentation>
181+
</xsd:annotation>
182+
</xsd:enumeration>
183+
</xsd:restriction>
184+
</xsd:simpleType>
185+
186+
<xsd:simpleType name="customImplementationReference">
187+
<xsd:annotation>
188+
<xsd:appinfo>
189+
<tool:annotation kind="ref"/>
190+
</xsd:appinfo>
191+
</xsd:annotation>
192+
<xsd:union memberTypes="xsd:string"/>
193+
</xsd:simpleType>
194+
195+
<xsd:simpleType name="entityManagerFactoryRef">
196+
<xsd:annotation>
197+
<xsd:appinfo>
198+
<tool:annotation kind="ref">
199+
<tool:assignable-to type="org.springframework.orm.jpa.AbstractEntityManagerFactoryBean"/>
200+
</tool:annotation>
201+
</xsd:appinfo>
202+
</xsd:annotation>
203+
<xsd:union memberTypes="xsd:string"/>
204+
</xsd:simpleType>
205+
206+
<xsd:simpleType name="transactionManagerRef">
207+
<xsd:annotation>
208+
<xsd:appinfo>
209+
<tool:annotation kind="ref">
210+
<tool:assignable-to type="org.springframework.transaction.PlatformTransactionManager"/>
211+
</tool:annotation>
212+
</xsd:appinfo>
213+
</xsd:annotation>
214+
<xsd:union memberTypes="xsd:string"/>
215+
</xsd:simpleType>
216+
217+
<xsd:simpleType name="classType">
218+
<xsd:annotation>
219+
<xsd:appinfo>
220+
<tool:annotation kind="direct">
221+
<tool:expected-type type="java.lang.Class"/>
222+
</tool:annotation>
223+
</xsd:appinfo>
224+
</xsd:annotation>
225+
<xsd:union memberTypes="xsd:string"/>
226+
</xsd:simpleType>
227+
228+
</xsd:schema>

0 commit comments

Comments
 (0)