[英]Call Bundle Activator Before Injecting Entity Manager
I have a persistence bundle (has a Meta-Persistence
), it also has an Activator
class 我有一个持久性捆绑包(具有
Meta-Persistence
),它也有一个Activator
类
when deployed into karaf
, the container starts processing the persistence unit
& mapping files
etc, before calling the start
method of the Activator
当部署到
karaf
,容器会在调用Activator
的start
方法之前开始处理persistence unit
和mapping files
等。
My question is : is there a way to alter this behavior ? 我的问题是:有没有办法改变这种行为? having the container call the method first ?
让容器首先调用该方法?
The reason I need the activator to be called first: 我首先需要激活器的原因:
I have some mapped entities
that rely on jackson
which itself relies on spring
, what happens is, when hibernate
is loading the entities
, it arrives at a home-made class that blocks while no spring context
is injected into it. 我有一些
mapped entities
依赖于jackson
,而jackson
本身依赖于spring
,发生的事情是,当hibernate
加载entities
,它到达了一个自制类,该类在没有注入spring context
会阻塞。 So the bundle is forever on a starting
state 因此,捆绑包永远处于
starting
状态
So I though a possible solution would be to make use of the Activator
to inject the spring context
所以我虽然可能的解决方案是利用
Activator
注入spring context
Thank you 谢谢
The container (or more precisely Aries JPA) must start processing the persistence unit before the bundle is started. 容器(或更准确地说是Aries JPA)必须在开始分发包之前开始处理持久性单元。
The reason is that Aries JPA needs to do load time weaving in some cases. 原因是在某些情况下,Aries JPA需要进行加载时间编织。 This kind of weaving must be done before classes to be weaved are loaded the first time by any bundle.
这种编织必须在任何捆绑包第一次加载要编织的类之前完成。 So the only safe time to do this is directly after the bundle is resolved.
因此,唯一安全的时间是在解决捆绑包之后。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.