/** * @return a {@link File} pointing to the container folder used to temporarily store the exported module services for SPI. */ public static File getModulesTempFolder() { return new File(getExecutionFolder(), MODULES_FOLDER); }
/** * Creates a new instance that discover services from Mule Runtime services folder. * * @param containerClassLoader container artifact classLoader. Non null. * @param serviceClassLoaderFactory factory used to create service's classloaders. Non null. * @param descriptorLoaderRepository contains all the {@link ClassLoaderModelLoader} registered on the container. Non null * @param artifactDescriptorValidatorBuilder {@link ArtifactDescriptorValidatorBuilder} to create the {@link org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptorValidator} in order to check the state of the descriptor once loaded. */ public FileSystemServiceProviderDiscoverer(ArtifactClassLoader containerClassLoader, ArtifactClassLoaderFactory<ServiceDescriptor> serviceClassLoaderFactory, DescriptorLoaderRepository descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder artifactDescriptorValidatorBuilder) { this(containerClassLoader, serviceClassLoaderFactory, descriptorLoaderRepository, artifactDescriptorValidatorBuilder, () -> MuleFoldersUtil.getServicesFolder()); }
public static File getDomainLibFolder(String domainName) { return new File(getDomainFolder(domainName), LIB_FOLDER); }
/** * @param appName name of the application to look for * @return the libraries folder in the deployed application with the given name */ public static File getAppLibFolder(String appName) { return new File(getAppFolder(appName), getAppLibsFolderPath()); }
/** * @param appName name of the application to look for * @return the shared libraries folder in the deployed application with the given name */ public static File getAppSharedLibsFolder(String appName) { return new File(getAppFolder(appName), getAppSharedLibsFolderPath()); }
/** * @param appName name of the application to look for * @return the plugins folder in the deployed application with the given name */ public static File getAppPluginsFolder(String appName) { return new File(getAppFolder(appName), getAppPluginsFolderPath()); }
getDomainsFolder().mkdirs(); getDomainFolder("default").mkdirs(); getServicesFolder().mkdirs(); getServerPluginsFolder().mkdirs(); getConfFolder().mkdirs(); getAppsFolder().mkdirs(); File destinationFile = new File(getServicesFolder(), getName(originalFile.getPath())); copyFile(originalFile, destinationFile); File destinationFile = new File(getServerPluginsFolder(), getName(originalFile.getPath()).replace(".zip", "")); try { ZipFile zipFile = new ZipFile(originalFile);
GlobalConfigLoader.reset(); final File domainFolder = getDomainFolder(DEFAULT_DOMAIN_NAME); assertThat(domainFolder.mkdirs(), is(true)); services = getServicesFolder(); services.mkdirs(); copyDirectory(buildSchedulerServiceFile(compilerWorkFolder.newFolder(SCHEDULER_SERVICE_NAME)),
appFolder = getAppFolder(APP_NAME); assertThat(appFolder.mkdirs(), is(true)); File libDir = getAppLibFolder(APP_NAME); assertThat(libDir.mkdirs(), is(true)); URL resourceSrcJarFile = currentThread().getContextClassLoader().getResource("test-jar-with-resources.jar"); domainDir = MuleFoldersUtil.getDomainFolder(DOMAIN_NAME); assertThat(domainDir.mkdirs(), is(true)); FileUtils.stringToFile(new File(domainDir, RESOURCE_JUST_IN_DOMAIN).getAbsolutePath(), "Some text"); .containing(getAppFolder(APP_NAME).toURI().toURL()).build(); applicationDescriptor.setClassLoaderModel(classLoaderModel); appCL = new MuleApplicationClassLoader(APP_NAME, applicationDescriptor, domainCL, null, urls,
/** * @return the runtime repository folder for maven artifacts. */ private static File getRuntimeRepositoryFolder() { return new File(MuleFoldersUtil.getMuleBaseFolder(), "repository"); }
private List<ServiceDescriptor> getServiceDescriptors(ServiceDescriptorFactory serviceDescriptorFactory) throws ServiceResolutionError { List<ServiceDescriptor> foundServices = new LinkedList<>(); for (String serviceFile : getServicesFolder().list(new SuffixFileFilter(".jar"))) { final File tempFolder = new File(getServicesTempFolder(), getBaseName(serviceFile)); try { unzip(new File(getServicesFolder(), serviceFile), tempFolder); } catch (IOException e) { throw new ServiceResolutionError("Error processing service JAR file", e); } final ServiceDescriptor serviceDescriptor = serviceDescriptorFactory.create(tempFolder, empty()); foundServices.add(serviceDescriptor); } return foundServices; }
@Override public void dispose() { File appLocation = this.getLocation(); try { super.dispose(); } catch (Throwable t) { logger.warn(format("Error while disposing application: {} ", this.getArtifactName()), t); } deleteQuietly(appLocation); deleteQuietly(getAppDataFolder(getArtifactName())); }
public static File getDomainFolder(String domainName) { return new File(getDomainsFolder(), domainName); }
@Test public void createServiceDescriptor() throws Exception { File servicesFolder = getServicesFolder(); assertThat(servicesFolder.mkdirs(), is(true)); final ServiceFileBuilder fooService = new ServiceFileBuilder(SERVICE_NAME) .withServiceProviderClass(PROVIDER_CLASS_NAME) .forContract(SERVICE_API_CLASS_NAME); unzip(fooService.getArtifactFile(), getServiceFolder(SERVICE_NAME)); ServiceDescriptor descriptor = serviceDescriptorFactory.create(getServiceFolder(SERVICE_NAME), empty()); assertThat(descriptor.getName(), equalTo(SERVICE_NAME)); assertThat(descriptor.getRootFolder(), equalTo(getServiceFolder(SERVICE_NAME))); assertThat(descriptor.getContractModels(), hasSize(1)); MuleServiceContractModel contractModel = descriptor.getContractModels().get(0); assertThat(contractModel.getServiceProviderClassName(), equalTo(PROVIDER_CLASS_NAME)); assertThat(contractModel.getContractClassName(), equalTo(SERVICE_API_CLASS_NAME)); } }
@After public void tearDown() { deleteIfNeeded(getDomainsFolder()); deleteIfNeeded(new File(getMuleLibFolder(), "shared")); }
public static File getMuleLibFolder() { return new File(getMuleHomeFolder(), LIB_FOLDER); }
public static File getAppFolder(String appName) { return new File(getAppsFolder(), appName); }
@Override protected File getArtifactFolder() { return getAppFolder(ARTIFACT_NAME); }
GlobalConfigLoader.reset(); final File domainFolder = getDomainFolder(DEFAULT_DOMAIN_NAME); assertThat(domainFolder.mkdirs(), is(true)); services = getServicesFolder(); services.mkdirs(); copyFileToDirectory(buildSchedulerServiceFile(compilerWorkFolder.newFolder("schedulerService")), services);
appFolder = getAppFolder(APP_NAME); assertThat(appFolder.mkdirs(), is(true)); File libDir = getAppLibFolder(APP_NAME); assertThat(libDir.mkdirs(), is(true)); URL resourceSrcJarFile = currentThread().getContextClassLoader().getResource("test-jar-with-resources.jar"); domainDir = MuleFoldersUtil.getDomainFolder(DOMAIN_NAME); assertThat(domainDir.mkdirs(), is(true)); FileUtils.stringToFile(new File(domainDir, RESOURCE_JUST_IN_DOMAIN).getAbsolutePath(), "Some text"); .containing(getAppFolder(APP_NAME).toURI().toURL()).build(); applicationDescriptor.setClassLoaderModel(classLoaderModel); appCL = new MuleApplicationClassLoader(APP_NAME, applicationDescriptor, domainCL, null, urls,