with hibernate i can add entities programmatically this way:
sessionFactory = new AnnotationConfiguration()
Is there something similar in EclipseLink?
This question is often asked but i could not find a satisfing answer. One answer said Dynamic JPA could be a solution but the description says:
"map relational tables to virtual classes which are created dynamically at runtime"
My classes are not created dynamically, they are already existing, but have to be registered at the entityManager.
As i understood the composite persistence unit is mainly for using different database. The requirement to define the Plugins (or more concrete: jar files) "A" and "B" in the composite persistence unit crushes the modulartiy again...
Yes, you can dynamically change the persistence unit using a metadata source to add in what is needed: http://wiki.eclipse.org/EclipseLink/Examples/JPA/MetadataSource
With this, you can define your own Metadata source that can return your classes from outside the persistence unit. The metadata source is akin to an orm.xml file and is processed about the same time, so you would only need to list the classes and they will then get processed regularly.
This feature ships with an implementation that will load orm.xml files, but I have seen others post more dynamic implementations I just don't have any links or examples handy.