【问题标题】:Runtime Enhancement in OSGi environment using code使用代码在 OSGi 环境中增强运行时
【发布时间】:2014-11-06 11:10:54
【问题描述】:

问题: 1. JPA 类/实体在 Bundle 1 和 Bundle 2 中使用相同的持久性单元 2. Bundle 3 正在尝试访问(用于 DB API 抽象的包装器 API)Bundle 1 和 Bundle 2 中的类。 3. 运行时增强不起作用。

所以我打算做的是使用 Code 增强 JPA 实体,在 bundle 3 出现之前,可以增强 Bundle 1 中的这些实体。 我正计划这样做,因为运行时增强没有完成并且捆绑 3 出现了。由于未创建表,这会导致 DB API(Bundle 3 API)失败。

【问题讨论】:

  • 为什么不使用编译时增强? OpenJPA 可以为您做到这一点。在我看来,运行时字节码操作是一件非常邪恶的事情,应该避免。

标签: osgi openjpa osgi-bundle persistence.xml openjpa-maven-plugin


【解决方案1】:

我们在以前的 openjpa 和 OSGi 项目中遇到了同样的问题。幸运的是,OpenJPA 支持编译时增强,这可以通过 openjpa maven 插件完成,如下所述:http://openjpa.apache.org/enhancement-with-maven.html

还有一个 Eclipse maven 连接器,它支持 IDE 内部的运行时增强,如果你想使用远程部署,这真的很舒服。 http://openjpa-maven-connector.googlecode.com/svn/trunk/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-04
    • 2017-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-24
    • 2023-02-01
    相关资源
    最近更新 更多