Lookup Seam integration resource loader.
@return the Seam integration resource loader
@throws DeploymentUnitProcessingException for any error
328614
protected synchronized ResourceRoot getSeamIntResourceRoot() throws DeploymentUnitProcessingException {
        try {
            if (seamIntResourceRoot == null) {
                final ModuleLoader moduleLoader = Module.getBootModuleLoader();
                Module extModule = moduleLoader.loadModule(EXT_CONTENT_MODULE);
                URL url = extModule.getExportedResource(SEAM_INT_JAR);
                if (url == null)
                    throw ServerLogger.ROOT_LOGGER.noSeamIntegrationJarPresent(extModule);

                File file = new File(url.toURI());
                VirtualFile vf = VFS.getChild(file.toURI());
                final Closeable mountHandle = VFS.mountZip(file, vf, TempFileProviderService.provider());
                Service<Closeable> mountHandleService = new Service<Closeable>() {
                    public void start(StartContext startContext) throws StartException {
                    }

                    public void stop(StopContext stopContext) {
                        VFSUtils.safeClose(mountHandle);
                    }

                    public Closeable getValue() throws IllegalStateException, IllegalArgumentException {
                        return mountHandle;
                    }
                };
                ServiceBuilder<Closeable> builder = serviceTarget.addService(ServiceName.JBOSS.append(SEAM_INT_JAR),
                        mountHandleService);
                builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
                serviceTarget = null; // our cleanup service install work is done

                MountHandle dummy = MountHandle.create(null); // actual close is done by the MSC service above
                seamIntResourceRoot = new ResourceRoot(vf, dummy);
            }
            return seamIntResourceRoot;
        } catch (Exception e) {
            throw new DeploymentUnitProcessingException(e);
        }
    }
1132160
protected CmsJspLoader getJspLoader() {

        if (m_jspLoader == null) {
            try {
                m_jspLoader = (CmsJspLoader)OpenCms.getResourceManager().getLoader(CmsJspLoader.RESOURCE_LOADER_ID);
            } catch (ArrayIndexOutOfBoundsException e) {
                // ignore, loader not configured
            }
        }
        return m_jspLoader;
    }
340340
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();

    if(!ProcessApplicationAttachments.isProcessApplication(deploymentUnit)) {
      return;
    }

    final Module module = deploymentUnit.getAttachment(MODULE);

    // read @ProcessApplication annotation of PA-component
    String[] deploymentDescriptors = getDeploymentDescriptors(deploymentUnit);

    // load all processes.xml files
    List<URL> deploymentDescriptorURLs = getDeploymentDescriptorUrls(module, deploymentDescriptors);

    for (URL processesXmlResource : deploymentDescriptorURLs) {
      VirtualFile processesXmlFile = getFile(processesXmlResource);

      // parse processes.xml metadata.
      ProcessesXml processesXml = null;
      if(isEmptyFile(processesXmlResource)) {
        processesXml = ProcessesXml.EMPTY_PROCESSES_XML;
      } else {
        processesXml = parseProcessesXml(processesXmlResource);
      }

      // add the parsed metadata to the attachment list
      ProcessApplicationAttachments.addProcessesXml(deploymentUnit, new ProcessesXmlWrapper(processesXml, processesXmlFile));
    }
  }
297013
public EJBHome getEJBHome() throws RemoteException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "getEJBHome");

        if (home == null)
        {
            try
            {
                Class homeClass = null;
                try
                {
                    //
                    // If we are running on the server side, then the thread
                    // context loader would have been set appropriately by
                    // the container. If running on a client, then check the
                    // thread context class loader first
                    //
                    ClassLoader cl = Thread.currentThread().getContextClassLoader();
                    if (cl != null)
                    {
                        homeClass = cl.loadClass(homeInterface);
                    }
                    else
                    {
                        throw new ClassNotFoundException();
                    }
                } catch (ClassNotFoundException ex)
                {
                    //FFDCFilter.processException(ex, CLASS_NAME + ".getEJBHome", "141", this);
                    try
                    {
                        homeClass = Class.forName(homeInterface);
                    } catch (ClassNotFoundException e)
                    {
                        //FFDCFilter.processException(e, CLASS_NAME + ".getEJBHome",
                        //                       "148", this);
                        throw new ClassNotFoundException(homeInterface);
                    }
                }

                InitialContext ctx = null;
                try
                {
                    // Locate the home
                    //91851 begin
                    if (this.initialContextProperties == null)
                    {
                        ctx = new InitialContext();
                    }
                    else
                    {
                        try
                        {
                            ctx = new InitialContext(this.initialContextProperties);

                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) // d144064
                                Tr.debug(tc, "Created an initial context with the " +
                                             "initialContextProperties, providerURL = " +
                                             (String) initialContextProperties.get("java.naming.provider.url") +
                                             " INITIAL_CONTEXT_FACTORY = " +
                                             (String) initialContextProperties.get(Context.INITIAL_CONTEXT_FACTORY));
                        } catch (NamingException ne)
                        {
                            //FFDCFilter.processException(ne, CLASS_NAME + ".getEJBHome",
                            //                          "177", this);
                            ctx = new InitialContext();
                        }
                    }
                    //91851 end
                    home = (EJBHome) PortableRemoteObject.
                                    narrow(ctx.lookup(homeJNDIName), homeClass);
                } catch (NoInitialContextException e)
                {
                    //FFDCFilter.processException(e, CLASS_NAME + ".getEJBHome", "188", this);
                    java.util.Properties p = new java.util.Properties();
                    p.put(Context.INITIAL_CONTEXT_FACTORY,
                          "com.ibm.websphere.naming.WsnInitialContextFactory");
                    ctx = new InitialContext(p);
                    home = (EJBHome) PortableRemoteObject.
                                    narrow(ctx.lookup(homeJNDIName), homeClass);
                }
            } catch (NamingException e)
            {
                // Problem looking up the home

                //FFDCFilter.processException(e, CLASS_NAME + ".getEJBHome", "201", this);
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    Tr.exit(tc, "getEJBHome", e);

                RemoteException re = new NoSuchObjectException("Could not find home in JNDI");
                re.detail = e;
                throw re;
            } catch (ClassNotFoundException e)
            {
                // We couldn't find the home interface's class

                //FFDCFilter.processException(e, CLASS_NAME + ".getEJBHome", "213", this);
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    Tr.exit(tc, "getEJBHome", e);
                throw new RemoteException("Could not load home interface", e);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "getEJBHome");

        return home;
    }
162149
public static Resource getConsoleResource(BeanContext context) {
        SlingHttpServletRequest request = context.getRequest();
        ResourceResolver resolver = request.getResourceResolver();
        String path = null;
        // use the resource set by a probably executed 'defineObjects' tag (supports including components)
        Resource resource = context.getAttribute("resource", Resource.class);
        if (resource == null) {
            resource = request.getResource();
        }
        if (resource != null) {
            path = resource.getPath();
        }
        // use the suffix as the resource path if the resource is not defined or references a servlet
        if (StringUtils.isBlank(path) || path.startsWith("/bin/")) {
            RequestPathInfo requestPathInfo = request.getRequestPathInfo();
            path = requestPathInfo.getSuffix();
            resource = null;
        }
        if (resource == null && StringUtils.isNotBlank(path)) {
            resource = resolver.getResource(path);
        }
        if (resource == null) {
            // fallback to the root node if the servlet request has no suffix
            resource = resolver.getResource("/");
        }
        return resource;
    }
694790
@SuppressWarnings("unchecked")
   private <T> T loadService(Class<T> spiType, Class<?> defaultImpl, ClassLoader loader)
   {
      final String defaultImplName = defaultImpl != null ? defaultImpl.getName() : null;
      return (T)ServiceLoader.loadService(spiType.getName(), defaultImplName, loader);
   }
443489
@Override
    public <T> CachedResource<T> getResource(Resource resource, Loader<T> builder)
            throws IOException {
        return this.getResource(resource, builder, this.checkInterval);
    }
280123
public ResourceClassLoader getCustomResourceClassLoader(Resource[] resources) throws IOException {

	if (ArrayUtil.isEmpty(resources)) return this;

	String key = hash(resources);
	ResourceClassLoader rcl = (customCLs == null) ? null : customCLs.get(key);

	if (rcl != null) return rcl;

	resources = ResourceUtil.merge(this.getResources(), resources);
	rcl = new ResourceClassLoader(resources, getParent());

	if (customCLs == null) customCLs = new ReferenceMap<String, ResourceClassLoader>();

	customCLs.put(key, rcl);
	return rcl;
    }
343568
public static void indexResourceRoot(final ResourceRoot resourceRoot) throws DeploymentUnitProcessingException {
        if (resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX) != null) {
            return;
        }

        VirtualFile indexFile = resourceRoot.getRoot().getChild(ModuleIndexBuilder.INDEX_LOCATION);
        if (indexFile.exists()) {
            try {
                IndexReader reader = new IndexReader(indexFile.openStream());
                resourceRoot.putAttachment(Attachments.ANNOTATION_INDEX, reader.read());
                ServerLogger.DEPLOYMENT_LOGGER.tracef("Found and read index at: %s", indexFile);
                return;
            } catch (Exception e) {
                ServerLogger.DEPLOYMENT_LOGGER.cannotLoadAnnotationIndex(indexFile.getPathName());
            }
        }

        // if this flag is present and set to false then do not index the resource
        Boolean shouldIndexResource = resourceRoot.getAttachment(Attachments.INDEX_RESOURCE_ROOT);
        if (shouldIndexResource != null && !shouldIndexResource) {
            return;
        }

        final List<String> indexIgnorePathList = resourceRoot.getAttachment(Attachments.INDEX_IGNORE_PATHS);
        final Set<String> indexIgnorePaths;
        if (indexIgnorePathList != null && !indexIgnorePathList.isEmpty()) {
            indexIgnorePaths = new HashSet<String>(indexIgnorePathList);
        } else {
            indexIgnorePaths = null;
        }

        final VirtualFile virtualFile = resourceRoot.getRoot();
        final Indexer indexer = new Indexer();
        try {
            final VisitorAttributes visitorAttributes = new VisitorAttributes();
            visitorAttributes.setLeavesOnly(true);
            visitorAttributes.setRecurseFilter(new VirtualFileFilter() {
                public boolean accepts(VirtualFile file) {
                    return indexIgnorePaths == null || !indexIgnorePaths.contains(file.getPathNameRelativeTo(virtualFile));
                }
            });

            final List<VirtualFile> classChildren = virtualFile.getChildren(new SuffixMatchFilter(".class", visitorAttributes));
            for (VirtualFile classFile : classChildren) {
                InputStream inputStream = null;
                try {
                    inputStream = classFile.openStream();
                    indexer.index(inputStream);
                } catch (Exception e) {
                    ServerLogger.DEPLOYMENT_LOGGER.cannotIndexClass(classFile.getPathNameRelativeTo(virtualFile), virtualFile.getPathName(), e);
                } finally {
                    VFSUtils.safeClose(inputStream);
                }
            }
            final Index index = indexer.complete();
            resourceRoot.putAttachment(Attachments.ANNOTATION_INDEX, index);
            ServerLogger.DEPLOYMENT_LOGGER.tracef("Generated index for archive %s", virtualFile);
        } catch (Throwable t) {
            throw ServerLogger.ROOT_LOGGER.deploymentIndexingFailed(t);
        }
    }
1142123
protected ResourceBundleHandler initResourceBundleHandler() {
		ResourceBundleHandler rsHandler = null;
		if (jawrConfig.getUseBundleMapping() && StringUtils.isNotEmpty(jawrConfig.getJawrWorkingDirectory())) {
			rsHandler = new ServletContextResourceBundleHandler(servletContext, jawrConfig.getJawrWorkingDirectory(),
					jawrConfig.getResourceCharset(), jawrConfig.getGeneratorRegistry(), resourceType);
		} else {
			rsHandler = new ServletContextResourceBundleHandler(servletContext, jawrConfig.getResourceCharset(),
					jawrConfig.getGeneratorRegistry(), resourceType);
		}
		return rsHandler;
	}
887803
public ResourceInformationProvider getResourceInformationBuilder() {
        if (resourceInformationProvider == null) {
            resourceInformationProvider =
                    new CombinedResourceInformationProvider(
                            Prioritizable.prioritze(aggregatedModule.getResourceInformationProviders()));
            InformationBuilder informationBuilder = new DefaultInformationBuilder(typeParser);
            DefaultResourceInformationProviderContext context =
                    new DefaultResourceInformationProviderContext(resourceInformationProvider, informationBuilder, typeParser,
                            objectMapper);
            resourceInformationProvider.init(context);
        }
        return resourceInformationProvider;
    }
623054
private ClassLoader getClassLoader()
        throws MojoExecutionException
    {
        List<URL> classpathURLs = new ArrayList<URL>();
        this.addRelevantPluginDependenciesToClasspath( classpathURLs );
        this.addRelevantProjectDependenciesToClasspath( classpathURLs );
        this.addAdditionalClasspathElements( classpathURLs );
        
        if (outputDirectory.isDirectory()) {
        	// load compiled classes
        	Collection listFiles = FileUtils.listFiles(outputDirectory, new String[]{"class"}, true);
        	for (Object object : listFiles) {
        		if (object instanceof File) {
        			File f = (File) object;
        			if (f.isFile()) {
        				try {
        					classpathURLs.add(f.toURI().toURL());
        				} catch (Exception e) {
        					// TODO: handle exception
        				}
        			}
        		}
        	}
        }
        
        
        return new URLClassLoader( classpathURLs.toArray( new URL[classpathURLs.size()] ) , getClass().getClassLoader());
    }
626332
public ConfigurationProvider build() {
    LOG.info("Initializing ConfigurationProvider with "
        + configurationSource.getClass().getCanonicalName() + " source, "
        + reloadStrategy.getClass().getCanonicalName() + " reload strategy and "
        + environment.getClass().getCanonicalName() + " environment");

    final CachedConfigurationSource cachedConfigurationSource = new CachedConfigurationSource(configurationSource);
    if (metricRegistry != null) {
      configurationSource = new MeteredConfigurationSource(metricRegistry, prefix, cachedConfigurationSource);
    }
    cachedConfigurationSource.init();

    Reloadable reloadable = () -> cachedConfigurationSource.reload(environment);

    if (metricRegistry != null) {
      reloadable = new MeteredReloadable(metricRegistry, prefix, reloadable);
    }
    reloadable.reload();
    reloadStrategy.register(reloadable);

    SimpleConfigurationProvider configurationProvider = new SimpleConfigurationProvider(cachedConfigurationSource, environment);
    if (metricRegistry != null) {
      return new MeteredConfigurationProvider(metricRegistry, prefix, configurationProvider);
    }

    return configurationProvider;
  }
952556
@Override
    public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
        List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit);
        for (ResourceRoot resourceRoot : resourceRoots) {
            if (IgnoreMetaInfMarker.isIgnoreMetaInf(resourceRoot)) {
                continue;
            }
            Manifest manifest = getManifest(resourceRoot);
            if (manifest != null)
                resourceRoot.putAttachment(Attachments.MANIFEST, manifest);
        }
    }
772208
public ResourceInformationBuilder getResourceInformationBuilder() {
		CombinedResourceInformationBuilder resourceInformationBuilder = new CombinedResourceInformationBuilder(aggregatedModule.getResourceInformationBuilders());
		DefaultResourceInformationBuilderContext context = new DefaultResourceInformationBuilderContext(resourceInformationBuilder, typeParser);
		resourceInformationBuilder.init(context);
		return resourceInformationBuilder;
	}
152668
public CmsResourceUtil getResourceUtil() {

        if (m_resourceUtil == null) {
            try {
                m_resourceUtil = new CmsResourceUtil(OpenCms.initCmsObject(getCms()));
                m_resourceUtil.setReferenceProject(getProject());
            } catch (CmsException ex) {
                if (LOG.isErrorEnabled()) {
                    LOG.error(ex.getLocalizedMessage(), ex);
                }
            }
        }
        return m_resourceUtil;
    }
1019798
public static List<ResourceRoot> allResourceRoots(DeploymentUnit deploymentUnit) {
        List<ResourceRoot> roots = new ArrayList<ResourceRoot>();
        // not all deployment units have a deployment root
        final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        if (deploymentRoot != null)
            roots.add(deploymentRoot);
        roots.addAll(deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS));
        return roots;
    }