我试图用Equinox实现hibernate-osgi。
我从以下的罐子里创建了一个插件“ my.app.hibernate.osgi ”: jars of my.app.hibernate.osgi
在此插件的 MANIFEST.MF 中,我添加了以下内容:
Bundle-Name: my.app.hibernate.osgi
Bundle-SymbolicName: my.app.hibernate.osgi;singleton:=true
Bundle-Activator: org.hibernate.osgi.HibernateBundleActivator
Bundle-ActivationPolicy: lazy
Eclipse-BuddyPolicy: registered
然后我为我的hibernate配置,实体和DAO创建了另一个插件“ my.app.core.hibernate ”
在这个的 MANIFEST.MF 中,它是这样的:
Bundle-Activator: my.app.core.hibernate.Activator
Bundle-ActivationPolicy: lazy
Eclipse-RegisterBuddy: my.app.hibernate.osgi
Require-Bundle: my.app.hibernate.osgi
org.eclipse.e4.ui.model.workbench,
org.eclipse.e4.core.services,
org.eclipse.osgi,
org.eclipse.core.runtime,
org.eclipse.osgi.services,
org.eclipse.core.net,
...
Meta-Persistence: META_INF/persistence.xml
我的 persistence.xml :
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="myAppPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
...
</persistence-unit>
</persistence>
我还有一个EntityManagerService来获取EntityManager
private static EntityManagerFactory getEntityManagerFactory() {
if ( emf == null ) {
Bundle thisBundle = FrameworkUtil.getBundle( EntityManagerService.class );
BundleContext context = thisBundle.getBundleContext();
ServiceReference serviceReference = context.getServiceReference( PersistenceProvider.class.getName() );
PersistenceProvider persistenceProvider = (PersistenceProvider) context.getService( serviceReference );
emf = persistenceProvider.createEntityManagerFactory( "myAppPU", null );
}
return emf;
}
最后,我有第三个使用我的DAO的插件“ my.app.core ”。 使用以下 MANIFEST.MF :
Eclipse-RegisterBuddy: my.app.hibernate.core
Bundle-ActivationPolicy: lazy
Require-Bundle: my.app.core.hibernate,
org.eclipse.e4.core.di;bundle-version="1.5.0",
org.eclipse.fx.core.di;bundle-version="2.2.0",
org.eclipse.e4.ui.di;bundle-version="1.1.0",
org.eclipse.osgi.services,
org.eclipse.e4.core.contexts,
org.apache.log4j,
javax.inject,
org.apache.commons.lang,
org.eclipse.equinox.app
当我启动我的应用时
emf = persistenceProvider.createEntityManagerFactory( "myAppPU", null );
entityManagerFactory为null
我做错了什么?
(编辑:) 我想(在调试hibernate代码时),在ProviderChercker中,以下行返回null:
final String setting = (String) integration.get( AvailableSettings.PROVIDER );
我应该在persistence.xml中声明什么提供程序?
我正在使用嵌入式H2 db V.1.4.197
(另外,我不确定是否应该将以下两个jar org.osgi.compendium-4.3.1.jar和org.osgi.core-4.3.1.jar包含在我的“my.app”中.hibernate.osgi“插件。 我已经尝试但在这种情况下我有一个ClassCastException:HibernateBundleActivator无法强制转换为BundleActivator)
答案 0 :(得分:0)
提供商名称不好。 好的:
s3.getSignedUrl('putObject', {
Bucket: 'myBucket',
Expires: 60*60,
Key: 'myKey',
ContentType: 'image/jpeg',
}, function (err, url) {
console.log(url);
});