private static Resource getServiceRegistryInitializerServicesDirectoryResource(
            final CasConfigurationProperties casProperties,
            final ConfigurableApplicationContext applicationContext) {
            val registry = casProperties.getServiceRegistry().getJson();
            if (ResourceUtils.doesResourceExist(registry.getLocation())
                || (ResourceUtils.isJarResource(registry.getLocation()) && !registry.isUsingDefaultLocation())) {
                LOGGER.debug("Using JSON service registry location [{}] for embedded service definitions", registry.getLocation());
                return registry.getLocation();
            }
            val parent = new File(FileUtils.getTempDirectory(), "cas");
            if (!parent.mkdirs() && !parent.exists()) {
                LOGGER.warn("Unable to create folder [{}]", parent);
            }
            val baseName = FilenameUtils.getBaseName(registry.getLocation().getFilename());
            val patterns = Arrays.stream(applicationContext.getEnvironment().getActiveProfiles())
                .map(profile -> String.format("classpath*:/%s/%s/*.json", baseName, profile))
                .collect(Collectors.toList());

            if (casProperties.getServiceRegistry().getCore().isInitDefaultServices()) {
                patterns.add("classpath*:/services/*.json");
            }
            LOGGER.debug("Patterns to scan for embedded service definitions: [{}]", patterns);
            ResourceUtils.exportResources(applicationContext, parent, patterns);
            LOGGER.debug("Using service registry location [{}] for embedded service definitions", parent);
            return new FileSystemResource(parent);
        }
This is {@link CasServiceRegistryInitializationConfiguration}.

@author Misagh Moayyed
@since 5.2.0
core/cas-server-core-services/src/main/java/org/apereo/cas/config/CasServiceRegistryInitializationConfiguration.java