Skip to content

Commit 2505f61

Browse files
committed
HHH-10041 features.xml generation: collapse 3 mains into one hibernate-orm
1 parent 2057bb3 commit 2505f61

File tree

3 files changed

+36
-59
lines changed

3 files changed

+36
-59
lines changed

documentation/src/main/docbook/userGuide/en-US/chapters/osgi/OSGi.xml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@
6868
<para>
6969
Apache Karaf environments tend to make heavy use of its "features" concept, where a feature is a set of order-specific
7070
bundles focused on a concise capability. These features are typically defined in a <literal>features.xml</literal> file.
71-
Hibernate produces and releases its own <literal>features.xml</literal> that defines features for each of the three runtime configurations.
71+
Hibernate produces and releases its own <literal>features.xml</literal> that defines a core <literal>hibernate-orm</literal>,
72+
as well as additional features for optional functionality (caching, Envers, etc.).
7273
This is included in the binary distribution, as well as deployed to the JBoss Nexus repository
73-
(using the <literal>org.hibernate</literal> groupId and <literal>hibernate-osgi</literal> with the <literal>karaf</literal> classifier).
74+
(using the <literal>org.hibernate</literal> groupId and <literal>hibernate-osgi</literal> with the <literal>karaf.xml</literal> classifier).
7475
</para>
7576

7677
<para>
@@ -80,8 +81,10 @@
8081
</para>
8182

8283
<para>
83-
Also note that hibernate-osgi, theoretically, supports a variety of OSGi containers, such as Equinox. In that case,
84-
please use features.xml as a reference for necessary bundles to activate and their correct ordering.
84+
hibernate-osgi, theoretically, supports a variety of OSGi containers, such as Equinox. In that case,
85+
please use features.xml as a reference for necessary bundles to activate and their correct ordering. However,
86+
note that Karaf starts a number of bundles automatically, several of which would need to be installed manually
87+
on alternatives.
8588
</para>
8689
</section>
8790

@@ -103,6 +106,24 @@
103106
<literal>PersistenceProvider</literal> service.
104107
</para>
105108

109+
<section>
110+
<title>Enterprise OSGi JPA Container</title>
111+
<para>
112+
In order to utilize container-managed JPA, an Enterprise OSGi JPA container must be active in the runtime.
113+
In Karaf, this means Aries JPA, which is included out-of-the-box (simply activate the <literal>jpa</literal>
114+
and <literal>jta</literal> features). Originally, we intended to include those dependencies within our own
115+
<literal>features.xml</literal>. However, after guidance from the Karaf and Aries teams, it was pulled out.
116+
This allows Hibernate OSGi to be portable and not be directly tied to Aries versions, instead having
117+
the user choose which to use.
118+
</para>
119+
<para>
120+
That being said, the QuickStart/Demo projects include a sample
121+
<link xl:href="https://github.com/hibernate/hibernate-demos/tree/master/hibernate-orm/osgi/managed-jpa/features.xml">features.xml</link>
122+
showing which features need activated in Karaf in order to support this environment. As mentioned, use this
123+
purely as a reference!
124+
</para>
125+
</section>
126+
106127
<section>
107128
<title>persistence.xml</title>
108129
<para>
@@ -155,16 +176,6 @@
155176
</para>
156177
</section>
157178

158-
<section>
159-
<title>JPA 2.1</title>
160-
<para>
161-
No Enterprise OSGi JPA container currently supports JPA 2.1 (the spec is not yet released). For
162-
testing, the managed-jpa example makes use of
163-
<link xl:href="https://github.com/brmeyer/aries/tree/jpa21">Brett's fork of Aries</link>. To work
164-
with Hibernate 4.3/5.0, clone the fork and build Aries JPA.
165-
</para>
166-
</section>
167-
168179
<section>
169180
<title>Obtaining an EntityManger</title>
170181
<para>
@@ -417,14 +428,6 @@
417428
<literal>features.xml</literal> for example sequences.
418429
</para>
419430
</listitem>
420-
<listitem>
421-
<para>
422-
No Enterprise OSGi JPA container currently supports JPA 2.1 (the spec is not yet released). For
423-
testing, the managed-jpa example makes use of
424-
<link xl:href="https://github.com/brmeyer/aries/tree/jpa21">Brett's fork of Aries</link>. To work
425-
with Hibernate 4.3, clone the fork and build Aries JPA.
426-
</para>
427-
</listitem>
428431
</itemizedlist>
429432
</section>
430433

hibernate-osgi/hibernate-osgi.gradle

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ configurations {
2020
description = 'Configuration used to isolate the dependency on the Karaf distro'
2121
transitive = false
2222
}
23-
aries {
24-
description = 'Runtime dependencies for Aries for the hibernate-jpa-aries Karaf feature'
25-
}
2623
hibernateEntityManager {
2724
description = 'Used in Karaf feature generation to define the Hibernate JPA dependencies'
2825
transitive = false
@@ -66,9 +63,6 @@ dependencies {
6663
}
6764

6865
karafDistro "org.apache.karaf:apache-karaf:${karafVersion}@tar.gz"
69-
70-
aries 'org.apache.aries.transaction:org.apache.aries.transaction.blueprint:1.0.0'
71-
aries 'org.apache.aries.transaction:org.apache.aries.transaction.manager:1.0.1'
7266
}
7367

7468
mavenPom {
@@ -116,9 +110,9 @@ task generateVersionFile {
116110

117111
karafFeatures {
118112
features {
119-
hibernateBase {
120-
name = 'hibernate-base'
121-
description = 'Isolates all Hibernate core dependencies into a single feature'
113+
hibernateOrm {
114+
name = 'hibernate-orm'
115+
description = 'Combines all Hibernate core dependencies and required modules into a single feature'
122116
projects = [
123117
rootProject.childProjects.'hibernate-core',
124118
rootProject.childProjects.'hibernate-entitymanager',
@@ -159,31 +153,12 @@ karafFeatures {
159153
remap group: 'org.apache.servicemix.bundles', module: 'org.apache.servicemix.bundles.dom4j', version: '1.6.1_5'
160154
}
161155
}
162-
hibernateNative {
163-
name = 'hibernate-native'
164-
description = 'Defines support for using Hibernate native APIs (SessionFactory, Session) in user applications/bundles'
165-
dependencyFeatureNames = ['hibernate-base']
166-
projects = []
167-
}
168-
hibernateJpa {
169-
name = 'hibernate-jpa'
170-
description = 'Defines support for using Hibernate JPA implementation in user applications/bundles in an unmanaged manner'
171-
dependencyFeatureNames = ['hibernate-base']
172-
projects = []
173-
}
174-
hibernateJpaAries {
175-
name = 'hibernate-jpa-aries'
176-
description = 'Defines support for using Hibernate JPA implementation in user applications/bundles in an managed manner using Aries for OSGi JPA support'
177-
bundleDependencies = [project.configurations.aries]
178-
dependencyFeatureNames = ['hibernate-base']
179-
projects = []
180-
}
181156
// NOTE : would like to include spatial as well, but we need to wait for
182157
// it to not define dependency on postgresql driver
183158
hibernateEnvers {
184159
name = 'hibernate-envers'
185-
description = 'Feature for easily adding Envers support to hibernate-native, hibernate-jpa or hibernate-jpa-aries'
186-
dependencyFeatureNames = ['hibernate-base']
160+
description = 'Feature for easily adding Envers support to hibernate-orm'
161+
dependencyFeatureNames = ['hibernate-orm']
187162
projects = [rootProject.childProjects.'hibernate-envers']
188163
bundle {
189164
match group: 'org.hibernate', module: 'hibernate-core'
@@ -212,8 +187,8 @@ karafFeatures {
212187
}
213188
hibernateInfinispan {
214189
name = 'hibernate-infinispan'
215-
description = 'Feature for easily adding Infinispan-based caching support to hibernate-native, hibernate-jpa or hibernate-jpa-aries'
216-
dependencyFeatureNames = ['hibernate-base']
190+
description = 'Feature for easily adding Infinispan-based caching support to hibernate-orm'
191+
dependencyFeatureNames = ['hibernate-orm']
217192
projects = [rootProject.childProjects.'hibernate-infinispan']
218193
bundle {
219194
match group: 'org.hibernate', module: 'hibernate-core'
@@ -242,8 +217,8 @@ karafFeatures {
242217
}
243218
hibernateEhcache {
244219
name = 'hibernate-ehcache'
245-
description = 'Feature for easily adding Ehcache-based caching support to hibernate-native, hibernate-jpa or hibernate-jpa-aries'
246-
dependencyFeatureNames = ['hibernate-base']
220+
description = 'Feature for easily adding Ehcache-based caching support to hibernate-orm'
221+
dependencyFeatureNames = ['hibernate-orm']
247222
projects = [rootProject.childProjects.'hibernate-ehcache']
248223
bundle {
249224
match group: 'org.hibernate', module: 'hibernate-core'

hibernate-osgi/src/test/java/org/hibernate/osgi/test/OsgiIntegrationTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public Option[] config() throws Exception {
111111
configureConsole().ignoreLocalConsole().ignoreRemoteShell(),
112112
when( debug ).useOptions( keepRuntimeFolder() ),
113113
logLevel( LogLevelOption.LogLevel.INFO ),
114-
features( featureXmlUrl( paxExamEnvironment ), "hibernate-native", "hibernate-jpa" ),
114+
features( featureXmlUrl( paxExamEnvironment ), "hibernate-orm" ),
115115
features( testingFeatureXmlUrl(), "hibernate-osgi-testing" )
116116
);
117117
}
@@ -191,8 +191,7 @@ public static void setLocaleToEnglish() {
191191

192192
@Test
193193
public void testFeatureInstallation() throws Exception {
194-
assertTrue( featuresService.isInstalled( featuresService.getFeature( "hibernate-jpa" ) ) );
195-
assertTrue( featuresService.isInstalled( featuresService.getFeature( "hibernate-native" ) ) );
194+
assertTrue( featuresService.isInstalled( featuresService.getFeature( "hibernate-orm" ) ) );
196195
}
197196

198197
@Test

0 commit comments

Comments
 (0)