Search in sources :

Example 86 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project keycloak by keycloak.

the class KeycloakProviderDependencyProcessor method getKeycloakProviderDeploymentInfo.

public static KeycloakDeploymentInfo getKeycloakProviderDeploymentInfo(DeploymentUnit du) {
    KeycloakDeploymentInfo info = KeycloakDeploymentInfo.create();
    info.name(du.getName());
    final ResourceRoot resourceRoot = du.getAttachment(Attachments.DEPLOYMENT_ROOT);
    if (resourceRoot != null) {
        final VirtualFile deploymentRoot = resourceRoot.getRoot();
        if (deploymentRoot != null && deploymentRoot.exists()) {
            if (deploymentRoot.getChild("META-INF/keycloak-themes.json").exists() && deploymentRoot.getChild("theme").exists()) {
                info.themes();
            }
            if (deploymentRoot.getChild("theme-resources").exists()) {
                info.themeResources();
            }
            VirtualFile services = deploymentRoot.getChild("META-INF/services");
            if (services.exists()) {
                try {
                    List<VirtualFile> archives = services.getChildren(new AbstractVirtualFileFilterWithAttributes() {

                        @Override
                        public boolean accepts(VirtualFile file) {
                            return file.getName().startsWith("org.keycloak");
                        }
                    });
                    if (!archives.isEmpty()) {
                        info.services();
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return info;
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) KeycloakDeploymentInfo(org.keycloak.provider.KeycloakDeploymentInfo) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) AbstractVirtualFileFilterWithAttributes(org.jboss.vfs.util.AbstractVirtualFileFilterWithAttributes) IOException(java.io.IOException)

Aggregations

ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)86 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)56 VirtualFile (org.jboss.vfs.VirtualFile)47 IOException (java.io.IOException)20 ArrayList (java.util.ArrayList)19 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)13 HashMap (java.util.HashMap)12 MountHandle (org.jboss.as.server.deployment.module.MountHandle)12 WarMetaData (org.jboss.as.web.common.WarMetaData)12 HashSet (java.util.HashSet)11 Closeable (java.io.Closeable)10 PersistenceUnitMetadataHolder (org.jboss.as.jpa.config.PersistenceUnitMetadataHolder)10 Index (org.jboss.jandex.Index)8 EarMetaData (org.jboss.metadata.ear.spec.EarMetaData)8 Module (org.jboss.modules.Module)8 URL (java.net.URL)7 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)7 ServiceName (org.jboss.msc.service.ServiceName)7 InputStream (java.io.InputStream)6 JBossWebMetaData (org.jboss.metadata.web.jboss.JBossWebMetaData)6