diff --git a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java index df8eec3ae7..03407519c7 100755 --- a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java +++ b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java @@ -1,7 +1,6 @@ package org.keycloak.services.resources; import org.keycloak.SkeletonKeyContextResolver; -import org.keycloak.models.mongo.keycloak.adapters.MongoDBSessionFactory; import org.keycloak.services.managers.TokenManager; import org.keycloak.models.KeycloakSessionFactory; import org.keycloak.models.picketlink.PicketlinkKeycloakSession; @@ -23,6 +22,8 @@ import javax.persistence.Persistence; import javax.servlet.ServletContext; import javax.ws.rs.core.Application; import javax.ws.rs.core.Context; + +import java.lang.reflect.Constructor; import java.util.HashSet; import java.util.Set; @@ -76,7 +77,15 @@ public class KeycloakApplication extends Application { int port = PropertiesManager.getMongoPort(); String dbName = PropertiesManager.getMongoDbName(); boolean dropDatabaseOnStartup = PropertiesManager.dropDatabaseOnStartup(); - return new MongoDBSessionFactory(host, port, dbName, dropDatabaseOnStartup); + + // Create MongoDBSessionFactory via reflection now + try { + Class mongoDBSessionFactoryClass = (Class)Class.forName("org.keycloak.models.mongo.keycloak.adapters.MongoDBSessionFactory"); + Constructor constr = mongoDBSessionFactoryClass.getConstructor(String.class, int.class, String.class, boolean.class); + return constr.newInstance(host, port, dbName, dropDatabaseOnStartup); + } catch (Exception e) { + throw new RuntimeException(e); + } } public KeycloakSessionFactory getFactory() { diff --git a/testsuite/performance/src/test/java/org/keycloak/testsuite/performance/RemoveUsersWorker.java b/testsuite/performance/src/test/java/org/keycloak/testsuite/performance/RemoveUsersWorker.java index c5b3633445..262ad932a6 100644 --- a/testsuite/performance/src/test/java/org/keycloak/testsuite/performance/RemoveUsersWorker.java +++ b/testsuite/performance/src/test/java/org/keycloak/testsuite/performance/RemoveUsersWorker.java @@ -7,8 +7,6 @@ import org.apache.jorphan.logging.LoggingManager; import org.apache.log.Logger; import org.keycloak.models.KeycloakSession; import org.keycloak.models.RealmModel; -import org.keycloak.models.mongo.keycloak.adapters.RealmAdapter; -import org.keycloak.services.resources.KeycloakApplication; import org.keycloak.services.utils.PropertiesManager; /** @@ -45,6 +43,8 @@ public class RemoveUsersWorker implements Worker { @Override public void run(SampleResult result, KeycloakSession identitySession) { + throw new IllegalStateException("Not yet supported"); + /* int userNumber = ++userCounterInRealm; int totalUserNumber = totalUserCounter.incrementAndGet(); @@ -63,6 +63,7 @@ public class RemoveUsersWorker implements Worker { int labelC = ((totalUserNumber - 1) / NUMBER_OF_USERS_IN_EACH_REPORT) * NUMBER_OF_USERS_IN_EACH_REPORT; result.setSampleLabel("ReadUsers " + (labelC + 1) + "-" + (labelC + NUMBER_OF_USERS_IN_EACH_REPORT)); + */ } @Override