Author: bdaw
Date: 2009-11-03 08:44:56 -0500 (Tue, 03 Nov 2009)
New Revision: 903
Modified:
idm/trunk/idm-hibernate/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
Log:
- fix the problem with concurrent realm creation
Modified:
idm/trunk/idm-hibernate/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
===================================================================
---
idm/trunk/idm-hibernate/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-11-03
12:08:04 UTC (rev 902)
+++
idm/trunk/idm-hibernate/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-11-03
13:44:56 UTC (rev 903)
@@ -40,6 +40,7 @@
import
org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectTypeMetaData;
import
org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.RealmConfigurationMetaData;
import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
import org.jboss.identity.idm.spi.model.IdentityObject;
import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
@@ -338,6 +339,31 @@
addRealm(hibernateSession, DEFAULT_REALM_NAME);
}
+ // If store is realm aware than creat all configured realms
+
+
+
+ if (isRealmAware())
+ {
+ Set<String> realmNames = new HashSet<String>();
+
+ for (RealmConfigurationMetaData realmMD :
configurationContext.getConfigurationMetaData().getRealms())
+ {
+ realmNames.add(realmMD.getId());
+ }
+
+ for (String rid : realmNames)
+ {
+ realm =
(HibernateRealm)hibernateSession.createCriteria(HibernateRealm.class).
+
add(Restrictions.eq("name",rid)).setCacheable(true).uniqueResult();
+
+ if (realm == null)
+ {
+ addRealm(hibernateSession, rid);
+ }
+ }
+ }
+
if (isManageTransactionDuringBootstrap())
{
hibernateSession.getTransaction().commit();
@@ -2432,7 +2458,7 @@
}
- public HibernateRealm getRealm(Session hibernateSession,
IdentityStoreInvocationContext ctx) throws IdentityException
+ private HibernateRealm getRealm(Session hibernateSession,
IdentityStoreInvocationContext ctx) throws IdentityException
{
if (ctx.getRealmId() == null)
{
@@ -2455,7 +2481,7 @@
}
else
{
- realm = (HibernateRealm)hibernateSession.
+ realm = (HibernateRealm)hibernateSession.
createCriteria(HibernateRealm.class).add(Restrictions.eq("name",
ctx.getRealmId())).setCacheable(true).uniqueResult();
// TODO: other way to not lazy initialize realm? special method called on every
new session creation
Show replies by date