简体   繁体   English

在注入实体管理器之前呼叫捆绑激活器

[英]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 ,容器会在调用Activatorstart方法之前开始处理persistence unitmapping files等。

My question is : is there a way to alter this behavior ? 我的问题是:有没有办法改变这种行为? having the container call the method first ? 让容器首先调用该方法?

Edit 编辑

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM