@Override public void initContextForStore(IdentityStoreInvocationContext ctx, IdentityStore store) { if (store instanceof JPAIdentityStore) { if (!ctx.isParameterSet(JPAIdentityStore.INVOCATION_CTX_ENTITY_MANAGER)) { ctx.setParameter(JPAIdentityStore.INVOCATION_CTX_ENTITY_MANAGER, getEntityManager()); } } }
protected EntityManager getEntityManager() { if (!getContext().isParameterSet(INVOCATION_CTX_ENTITY_MANAGER)) { throw new IllegalStateException("Error while trying to determine EntityManager - context parameter not set."); } return (EntityManager) getContext().getParameter(INVOCATION_CTX_ENTITY_MANAGER); }