/
postgresql-manual.xml
80 lines (67 loc) · 3.65 KB
/
postgresql-manual.xml
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
<?xml version="1.0"?>
<!--
Copyright 2005-2018 Red Hat, Inc.
Red Hat 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.
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<!--
This Blueprint XML shows the _deployment_ method for data source configuration.
With this method, it is not required to use pax-jdbc bundles at all. Instead both database-specific
and generic data sources are declared as Blueprint beans.
We need:
- mvn:org.postgresql/postgresql/42.3.3 bundle
- mvn:org.apache.commons/commons-pool2/2.11.1 bundle
- mvn:org.apache.commons/commons-dbcp2/2.9.0 bundle
Optionally, "jdbc" Karaf feature gives us jdbc:* commands to list and use datasources from shell
This Blueprint XML can be directly dropped to ${karaf.home}/deploy or archived in typical /OSGI-INF/blueprint
directory and installed as normal bundle.
Finally, this set of beans reflects the _canonical_ code example from
org.jboss.fuse.quickstarts.persistence.standalone.StandaloneXADataAccessTest.convenientXADataAccess()
-->
<!--
Database-specific, non-pooling, non-enlisting javax.sql.XADataSource
-->
<bean id="postgresql" class="org.postgresql.xa.PGXADataSource">
<property name="url" value="jdbc:postgresql://localhost:5432/reportdb" />
<property name="user" value="fuse" />
<property name="password" value="fuse" />
<property name="currentSchema" value="report" />
<property name="connectTimeout" value="5" />
</bean>
<!--
Fuse exports this service from fuse-pax-transx-tm-narayana bundle
-->
<reference id="tm" interface="javax.transaction.TransactionManager" />
<!--
Non database-specific, generic, pooling, enlisting javax.sql.DataSource
-->
<bean id="pool" class="org.apache.commons.dbcp2.managed.BasicManagedDataSource">
<property name="xaDataSourceInstance" ref="postgresql" />
<property name="transactionManager" ref="tm" />
<property name="minIdle" value="3" />
<property name="maxTotal" value="10" />
<property name="validationQuery" value="select schema_name, schema_owner from information_schema.schemata" />
</bean>
<!--
Expose datasource to use by application code (like Camel, Spring, ...)
-->
<service interface="javax.sql.DataSource" ref="pool">
<service-properties>
<!-- Giving data source a name using one of these properties makes identification easier in jdbc:ds-list: -->
<entry key="osgi.jndi.service.name" value="jdbc/postgresql" />
<!--<entry key="datasource" value="jdbc/postgresql" />-->
<!--<entry key="name" value="jdbc/postgresql" />-->
<!--<entry key="dataSourceName" value="jdbc/postgresql" />-->
<!-- Without any of the above, name will fallback to "service.id" -->
</service-properties>
</service>
</blueprint>