0

I'm trying to build a multi-tenant object management platform for an ERP system in which entities are specific to each tenants. I'm generating entities at runtime using bytebuddy once after I load them to the class path, I need to rebuild the emf at runtime by adding the newly generated entities. What is the right way to do this?

BeingVikram
  • 33
  • 2
  • 5
  • I assume you are trying to regenerate the classes and dropping the old ones. You would want to load all objects in a different class loader in this case and through away the old class loader once you regenerate them. – Rafael Winterhalter Feb 24 '19 at 11:05
  • Yes, I'll regenerate classes when the user adds /removes fields, I'm thinking of creating different versions of the class by appending version numbers to the class name and load them to the existing class loader instead of creating a different class loader. I wanted to know is there anyway to recreate **entitymanagerfactory** and replace all the existing reference to the **emf** with the newly created object. I've tried adding `@RefreshScope` to emf configuration class. But it didn't work. – BeingVikram Feb 24 '19 at 13:16
  • You would need to generate a proxy that delegates to the factory that is currently valid. You cannot change the shape of a loaded class. I would also recommend you class loader isolation to allow for unloading unused classes where you will otherwise quickly pollute your heap. – Rafael Winterhalter Feb 24 '19 at 13:32

0 Answers0