From eb695f12f76ef2f72bcee3b04121ef7479d95b5f Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Wed, 28 Jan 2015 11:26:46 +0100 Subject: [PATCH] KEYCLOAK-1000 Module provider loader --- integration/wildfly-extensions/pom.xml | 51 +++++++++++++++++++ .../wildfly/ModuleProviderLoaderFactory.java | 33 ++++++++++++ ...rg.keycloak.provider.ProviderLoaderFactory | 1 + 3 files changed, 85 insertions(+) create mode 100755 integration/wildfly-extensions/pom.xml create mode 100644 integration/wildfly-extensions/src/main/java/org/keycloak/provider/wildfly/ModuleProviderLoaderFactory.java create mode 100644 integration/wildfly-extensions/src/main/resources/META-INF/services/org.keycloak.provider.ProviderLoaderFactory diff --git a/integration/wildfly-extensions/pom.xml b/integration/wildfly-extensions/pom.xml new file mode 100755 index 0000000000..e627d32897 --- /dev/null +++ b/integration/wildfly-extensions/pom.xml @@ -0,0 +1,51 @@ + + + + 4.0.0 + + + org.keycloak + keycloak-parent + 1.2.0.Beta1-SNAPSHOT + ../../pom.xml + + + keycloak-wildfly-extensions + Keycloak WildFly Extensions + + jar + + + + org.wildfly.core + wildfly-controller + provided + + + org.keycloak + keycloak-model-api + ${project.version} + provided + + + org.keycloak + keycloak-services + ${project.version} + provided + + + diff --git a/integration/wildfly-extensions/src/main/java/org/keycloak/provider/wildfly/ModuleProviderLoaderFactory.java b/integration/wildfly-extensions/src/main/java/org/keycloak/provider/wildfly/ModuleProviderLoaderFactory.java new file mode 100644 index 0000000000..cb4a6f19e6 --- /dev/null +++ b/integration/wildfly-extensions/src/main/java/org/keycloak/provider/wildfly/ModuleProviderLoaderFactory.java @@ -0,0 +1,33 @@ +package org.keycloak.provider.wildfly; + +import org.jboss.modules.Module; +import org.jboss.modules.ModuleClassLoader; +import org.jboss.modules.ModuleIdentifier; +import org.jboss.modules.ModuleLoadException; +import org.keycloak.provider.DefaultProviderLoader; +import org.keycloak.provider.ProviderLoader; +import org.keycloak.provider.ProviderLoaderFactory; + +/** + * @author Stian Thorgersen + */ +public class ModuleProviderLoaderFactory implements ProviderLoaderFactory { + + @Override + public boolean supports(String type) { + return "module".equals(type); + } + + @Override + public ProviderLoader create(ClassLoader baseClassLoader, String resource) { + try { + System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx"); + Module module = Module.getContextModuleLoader().loadModule(ModuleIdentifier.fromString(resource)); + ModuleClassLoader classLoader = module.getClassLoader(); + return new DefaultProviderLoader(classLoader); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/integration/wildfly-extensions/src/main/resources/META-INF/services/org.keycloak.provider.ProviderLoaderFactory b/integration/wildfly-extensions/src/main/resources/META-INF/services/org.keycloak.provider.ProviderLoaderFactory new file mode 100644 index 0000000000..52aec1f65c --- /dev/null +++ b/integration/wildfly-extensions/src/main/resources/META-INF/services/org.keycloak.provider.ProviderLoaderFactory @@ -0,0 +1 @@ +org.keycloak.provider.wildfly.ModuleProviderLoaderFactory \ No newline at end of file