Apologies if this is a repost, I could not find the search terms to locate a similar question.
The application that I work on has support for plugins that can be loaded or unloaded at runtime. There are several API hooks that allow these plugins, among other things, to register richer objects then those provided out of the box. When a plugin is activated and registers a new domain object, I need to alert hibernate to the new object (and the removal of that object when the plugin is deactivated). All of our objects are marked up with JPA / Hibernate annotations.
System Class
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue("CORE")
public class User {
protected @Id @GeneratedValue int id;
protected String userName;
...
}
Plugin Class (found in a JAR classloader)
@Entity
@DiscriminatorValue("LDAP_USER")
public class LdapUser extends User {
protected boolean active;
...
}
Plugin entry point API hook
public void activate() {
UserManager.getInstance().registerType(LdapUser.class);
}
public void deactivate() {
UserManager.getInstance().unregisterType(LdapUser.class);
}
I know that hybernate supports configuration of the mapping via some APIs, but I also know that this can have some serious repercussions when there are active sessions.
So my question is: how can I reconfigure and augment the current mapping configuration 'in-flight' when Spring is managing my sessions.