OSGi Hibernate 支持

OSGi Hibernate envers Support

我卡在 osgi envers 支持集成到我的包中。我正在使用 hibernate-core 和 hibernate envers 4.2.22 redhat version,如何在蓝图中实现它?

我有带有@Audited 注释并导入的实体 org.hibernate.envers packages

我想使用审计和修订。

See Chapter 17.7 of the hibernate docs.

您将 envers 扩展注册为 OSGi 服务。

<blueprint default-activation="eager">
    <bean id="integrator" class="org.hibernate.envers.event.spi.EnversIntegrator" />
    <service ref="integrator" interface="org.hibernate.integrator.spi.Integrator" />
</blueprint>

注册envers扩展服务后,在我的清单中导入需要envers支持的包。 所需的包应通过嵌入依赖方法导入。使用 Include-Resource 标签来包含休眠资源,并确保添加 Bundle-Classpath 以定义 envers 依赖项。现在它在 JBoss 基于 fuse karaf 的 OSGi 容器中运行良好,然后成功创建了 revinfo 和 _aud 表。

这是我的清单,

Manifest-Version: 1.0
Bnd-LastModified: 1481971039345
Build-Jdk: 1.8.0_112
Built-By: Smile
Bundle-Activator: com.fuse.hibernate.services.OsgiBundleActiva
 tor
Bundle-Blueprint: OSGI-INF/blueprint/blueprint.xml
Bundle-ClassPath: .,hibernate-envers-4.2.22.Final-redhat-1.jar
Bundle-ManifestVersion: 2
Bundle-Name: FUSE-HIBERNATE
Bundle-SymbolicName: fuse-hibernate
Bundle-Version: 1.0.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: <Exported Packages>
Export-Service: com.fuse.repository.CustomRepository
Import-Package: org.hibernate.annotations;version="[4.2,5)",org.hibernat
 e.annotations.common.reflection;version="[4.0,5)",javax.persistence;ver
 sion="[2.0,3)",org.hibernate.proxy;version="[4.2,5)",javassist.util.pro
 xy;version="[3.18,4)",org.slf4j;version="[1.7,2)",javax.management,java
 x.naming,javax.persistence.metamodel;version="[2.0,3)",javax.transactio
 n;version="[1.1,2)",org.apache.commons.beanutils;version="[1.8,2)",org.
 apache.commons.lang3;version="[3.0,4)",org.apache.tools.ant,org.dom4j,o
 rg.dom4j.io,org.dom4j.tree,org.hibernate;version="[4.2,5)",org.hibernat
 e.action.spi;version="[4.2,5)",org.hibernate.cache;version="[4.2,5)",or
 g.hibernate.cfg;version="[4.2,5)",org.hibernate.collection.spi;version=
 "[4.2,5)",org.hibernate.criterion;version="[4.2,5)",org.hibernate.diale
 ct;version="[4.2,5)",org.hibernate.engine.jdbc.spi;version="[4.2,5)",or
 g.hibernate.engine.loading.internal,org.hibernate.engine.spi;version="[
 4.2,5)",org.hibernate.engine.transaction.spi;version="[4.2,5)",org.hibe
 rnate.event.service.spi;version="[4.2,5)",org.hibernate.event.spi;versi
 on="[4.2,5)",org.hibernate.id;version="[4.2,5)",org.hibernate.id.enhanc
 ed;version="[4.2,5)",org.hibernate.integrator.spi;version="[4.2,5)",org
 .hibernate.internal,org.hibernate.internal.util;version="[4.2,5)",org.h
 ibernate.internal.util.collections,org.hibernate.internal.util.config,o
 rg.hibernate.internal.util.xml,org.hibernate.jdbc;version="[4.2,5)",org
 .hibernate.mapping;version="[4.2,5)",org.hibernate.metamodel.source;ver
 sion="[4.2,5)",org.hibernate.metamodel.spi;version="[4.2,5)",org.hibern
 ate.persister.collection;version="[4.2,5)",org.hibernate.persister.enti
 ty;version="[4.2,5)",org.hibernate.property;version="[4.2,5)",org.hiber
 nate.service;version="[4.2,5)",org.hibernate.service.classloading.spi;v
 ersion="[4.2,5)",org.hibernate.service.jdbc.dialect.internal,org.hibern
 ate.service.jndi;version="[4.2,5)",org.hibernate.service.spi;version="[
 4.2,5)",org.hibernate.sql;version="[4.2,5)",org.hibernate.tool.hbm2ddl;
 version="[4.2,5)",org.hibernate.type;version="[4.2,5)",org.hibernate.us
 ertype;version="[4.2,5)",org.jboss.logging;version="[3.1,4)",org.joda.t
 ime;version="[2.9,3)",org.osgi.framework;version="[1.6,2)",org.osgi.ser
 vice.blueprint;version="[1.0.0,2.0.0)",org.w3c.dom,javax.sql
Meta-Persistence: META-INF/persistence.xml