OSGI 애플리케이션에서 EntityManager를 제공하는 모범 사례 (Best practice to provide EntityManager in OSGI applications)


문제 설명

OSGI 애플리케이션에서 EntityManager를 제공하는 모범 사례 (Best practice to provide EntityManager in OSGI applications)

제 문제와 관련하여 stackoverflow에서 다른 많은 질문을 읽었지만 적절한 해결책을 찾지 못했습니다.

저는 OSGI 애플리케이션(Equinox)을 개발하고 JPA(EclipseLink)를 사용합니다. 이제 필요한 번들에서 EntityManager를 얻는 가장 좋은 방법을 묻습니다. EntityManagerFactory를 서비스로 게시하고 이를 사용하여 EntityManger를 얻을 때 EntityManager를 사용하는 모든 번들에 persistence.xml을 제공해야 합니다. EntityManger의 한 인스턴스를 공유하는 유틸리티 클래스를 작성하고 이를 서비스로 게시할 때 스레드 동기화 문제가 발생할까봐 두렵습니다.

OSGI 및 JPA를 사용할 때 EntityManager를 제공하는 모범 사례가 있습니까? ?

고마워


참조 솔루션

방법 1:

In EclipseLink when used within OSGi you have to declare in which bundle the persistence.xml could be found by adding “JPA‑PersistenceUnits: myPersistenceUnit” to the bundle’s MANIFEST.MF in which the persistence.xml is located. EclipseLink will search for this declaration and will use the class loader of this bundle to get the persistence.xml. Then you can publish the EntityManagerFactory as Service and don’t need to share the persistence.xml in every bundle using the service. But I think this only works with EclipseLink.

방법 2:

I used this blog to get setup with OpenJPA and separate model bundles without each client bundle knowing about persistence.xml. Since EclipseLink is a JPA provider, it should be roughly the same setup. Be sure to look at the example code that is linked at the bottom of the blog.

(by dandanCarl)

참조 문서

  1. Best practice to provide EntityManager in OSGI applications (CC BY‑SA 3.0/4.0)

#equinox #eclipselink #osgi #jpa #java






관련 질문

Eclipse에서 OSGi 래퍼 번들을 실행할 수 없습니다. .jar은 잘 빌드되고 있지만 파일을 대상/클래스에 복사하려면 어떻게 해야 합니까? (Can't run OSGi wrapper bundle in Eclipse; .jar is building okay, but how do I also copy files into target/classes?)

최대 절전 모드 5.0 + 춘분 4.5.0 및 사용자 정의 UserType (hibernate 5.0 + equinox 4.5.0 and custom UserType)

Domino에 OSGi 서블릿 배치(IBM 프리젠테이션) - 404 오류 (Deploying OSGi Servlet to Domino (IBM presentation) - 404 error)

Java 7을 사용하여 Equinox 3.8.2 프로젝트 컴파일 (Compile Equinox 3.8.2 Project with java 7)

OSGI 애플리케이션에서 EntityManager를 제공하는 모범 사례 (Best practice to provide EntityManager in OSGI applications)

Eclipse RCP 제품 파일 - 플랫폼별 종속성이 있는 여러 플랫폼을 처리하는 방법 (Eclipse RCP Product File - how to handle multiple platforms with platform specific dependencies)

OSGI 번들이 설치 및 시작되었지만 출력이 표시되지 않음 (OSGI Bundle Installed and Started but no visible output)

Jetty 서버의 포트(Equinox OSGi) (Port in Jetty server (Equinox OSGi ))

Equinox에서 Arquillian 실행 (Running Arquillian in Equinox)

OSGi 가져오기 버전 제한을 동적으로 설정하시겠습니까? (Setting OSGi import version restrictions dynamically?)

OSGI의 AspectJ LoadTimeWeaving (AspectJ LoadTimeWeaving on OSGI)

user.home 디렉토리에 쓰지 못하도록 Eclipse 위치를 어떻게 수정합니까? (How modify Eclipse locations to prevent write to user.home directory?)







코멘트