This repository was archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathsql.txt
More file actions
219 lines (143 loc) · 5.52 KB
/
Copy pathsql.txt
File metadata and controls
219 lines (143 loc) · 5.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
///////////////////////////////////////////////////////////////
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
///////////////////////////////////////////////////////////////
[[library-sql,SQL Library]]
= SQL =
[devstatus]
--------------
source=libraries/sql/dev-status.xml
--------------
The SQL Library provides facilities for working with SQL databases.
The center piece is the DataSource support that comes with
<<library-circuitbreaker>> and <<library-jmx>> support.
TIP: See the <<sample-sql-support>> that demonstrate combined use of <<library-sql>>, <<extension-es-sqlkv>> and
<<extension-indexing-sql>>.
Moreover, supplementary libraries helps dealing with different connection pool implementations and schema migrations.
None of theses libraries depends on an actual JDBC driver, you are free to use the one that suits your needs.
include::../../build/docs/buildinfo/artifact.txt[]
== DataSource and connection pools ==
DataSource support comes in three flavors:
- using the http://jolbox.com/[BoneCP] connection pool
- using the http://commons.apache.org/dbcp/[Apache DBCP] connection pool
- importing an existing DataSource provided at assembly time
=== Connection Pools ===
Connection Pools support is provided by supplementary libraries.
*BoneCP*
[devstatus]
--------------
source=libraries/sql-bonecp/dev-status.xml
--------------
include::../../../sql-bonecp/build/docs/buildinfo/artifact.txt[]
BoneCP support resides in the *sql-bonecp* module.
[snippet,java]
----
source=libraries/sql/src/test/java/org/apache/polygene/library/sql/DocumentationSupport.java
tag=bonecp
----
*Apache DBCP*
[devstatus]
--------------
source=libraries/sql-dbcp/dev-status.xml
--------------
include::../../../sql-dbcp/build/docs/buildinfo/artifact.txt[]
[snippet,java]
----
source=libraries/sql/src/test/java/org/apache/polygene/library/sql/DocumentationSupport.java
tag=dbcp
----
=== DataSource ===
*Assembly*
[snippet,java]
----
source=libraries/sql/src/test/java/org/apache/polygene/library/sql/DocumentationSupport.java
tag=datasource
----
Assembled DataSources must be visible from the connection pool importer service.
*Configuration*
You need to provide a DataSource Configuration Entity per assembled DataSource.
See <<howto-configure-service>>.
[snippet,java]
----
source=libraries/sql/src/main/java/org/apache/polygene/library/sql/datasource/DataSourceConfigurationState.java
tag=config
----
Sample DataSource configuration defaults:
[source]
----
include::../test/resources/testds.properties[]
----
=== Importing an existing DataSource ===
Importing an existing DataSource at assembly time is usefull when your Polygene
Application runs in an environment where DataSource are already provided.
[snippet,java]
----
source=libraries/sql/src/test/java/org/apache/polygene/library/sql/datasource/ExternalDataSourceTest.java
tag=assembly
----
This mechanism is provided as an integration convenience and using the embedded
connection pools described above is recommended.
== Circuit Breaker ==
Assemblers for managed and external DataSource takes an optional
CircuitBreaker and set it as <<def-metainfo>> of the DataSource.
[snippet,java]
----
source=libraries/sql/src/test/java/org/apache/polygene/library/sql/DocumentationSupport.java
tag=cb-assembly
----
Then, when you gets injected or lookup a DataSource it will be automatically wrapped
by a CircuitBreaker proxy.
[snippet,java]
----
source=libraries/sql/src/test/java/org/apache/polygene/library/sql/DocumentationSupport.java
tag=cb-datasource
----
== JMX ==
Thanks to the <<library-jmx>> the Configuration of DataSources is exposed
through JMX.
[snippet,java]
----
source=libraries/sql/src/test/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java
tag=jmx
----
Every DataSource visible from the DataSourceConfigurationManager Service
will get its Configuration available using a JMX client.
Note that the JMX support does not apply to existing DataSource imported as
described above.
== Schema migration ==
Database schema migration can be delegated to http://www.liquibase.org/[Liquibase].
[devstatus]
--------------
source=libraries/sql-liquibase/dev-status.xml
--------------
include::../../../sql-liquibase/build/docs/buildinfo/artifact.txt[]
*Assembly*
[snippet,java]
----
source=libraries/sql-liquibase/src/test/java/org/apache/polygene/library/sql/liquibase/LiquibaseServiceTest.java
tag=assembly
----
The LiquibaseService is activated on Application startup and if enabled it
applies the configured changelog.
*Configuration*
[snippet,java]
----
source=libraries/sql-liquibase/src/main/java/org/apache/polygene/library/sql/liquibase/LiquibaseConfiguration.java
tag=config
----
For the Liquibase service to be enabled you must set it's Configuration
+enabled+ Property to TRUE. *contexts* and *changeLog* are optional.