1

We are developing a sort of SDK for internal use which includes some custom annotations, request filters and a few JPA entities for storing information about our organization's users. The SDK is a maven artifact and includes the definition of a persistence unit holding the user information entities.

Our problem is this: we must support multiple applications using our SDK being deployed to the same container or in their own containers. (The SDK's persistence components can't be refactored into their own Microservice)

Our question: since the persistent unit our authorization component uses is defined in the SDK, will it cause problems for multiple Java projects running in the same container to reference the same datasource/persistence unit combination? Or is there a way around this that we can and should implement?

KG6ZVP
  • 3,610
  • 4
  • 26
  • 45
  • One solution I can think of would be that all projects add the SDK as a normal Maven dependency, but each application has its own persistence.xml where the SDK is also references and entities are included with my-sdk.jar – simdevmon Mar 21 '17 at 11:49
  • That just doesn't sound like the right way to do it. We're trying to reduce the complexity to a single maven dependency. We are able to get it to work by checking out files from git and manually modifying files in projects, but our project is specifically to reduce it to an inclusion from Maven. – KG6ZVP Mar 22 '17 at 06:34

1 Answers1

0

One way I can think of is to have a template for the persistence.xml which will have all the configurations except the pu name which needs to a placeholder in the sdk and while building individual application have an ant run script (may be a java class ) from the sdk which will take the project specific pu name from a property file of the app and creates the persistence.xml file of the app by replacing the pu place holder from the template.

OTM
  • 656
  • 5
  • 8