/** * @return a {@link File} pointing to the container folder used to temporarily store services on deployment */ public static File getServicesTempFolder() { return new File(getExecutionFolder(), SERVICES_FOLDER); }
/** * @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); }
private File getToolingWorkingDir() { return new File(getExecutionFolder(), TOOLING_FOLDER); }
public static File getAppDataFolder(String appDataFolder) { return new File(getExecutionFolder(), appDataFolder); }
private void createExecutionMuleFolder() { File executionFolder = MuleFoldersUtil.getExecutionFolder(); if (!executionFolder.exists()) { if (!executionFolder.mkdirs()) { throw new MuleRuntimeException(CoreMessages.createStaticMessage(format( "Could not create folder %s, validate that the process has permissions over that directory", executionFolder.getAbsolutePath()))); } } }
private File getPoliciesTempFolder() { return new File(getExecutionFolder(), "policies"); }
/** * This method resolves the deploymentProperties for a new deploy/redeploy considering the new deployment properties passed by * the user as parameter and the deployment properties persisted in a previous deploy. In case no new deployment properties are * passed, the previous persisted properties are returned. Otherwise, the new deployment properties are used and persisted in * .mule/app/deployment-properties/deployment.properties There is one deployment.properties file for each artifact (domain/app). * * @param artifactName name of the artifact. * @param deploymentProperties deployment properties set in the new deploy/redeploy as parameters. * * @return deployment properties * @throws IOException */ public static Properties resolveDeploymentProperties(String artifactName, Optional<Properties> deploymentProperties) throws IOException { File file = new File(getExecutionFolder(), artifactName); String workingDirectory = file.getAbsolutePath(); String deploymentPropertiesPath = workingDirectory + separator + DEPLOYTMENT_PROPERTIES_DIRECTORY; if (!deploymentProperties.isPresent()) { return getDeploymentProperties(deploymentPropertiesPath); } initDeploymentPropertiesDirectory(deploymentPropertiesPath); persistDeploymentPropertiesFile(deploymentPropertiesPath, deploymentProperties.get()); return deploymentProperties.get(); }
@Before public void setUp() throws Exception { coreExtensionManager = mock(MuleCoreExtensionManagerServer.class); container = createMuleContainer(); FileUtils.deleteDirectory(getExecutionFolder()); }
@Test public void onStartAndExecutionFolderExistsDoNotFail() throws Exception { assertThat(getExecutionFolder().mkdirs(), is(true)); container.start(false); }
@Test public void onStartCreateExecutionFolderIfDoesNotExists() throws Exception { container.start(false); assertThat(getExecutionFolder().exists(), is(true)); }
private void testWithMuleHome(CheckedConsumer<ClasspathModuleDiscoverer> testCallback) throws Exception { testWithSystemProperty(MULE_HOME_DIRECTORY_PROPERTY, muleHome.getRoot().getAbsolutePath(), () -> { MuleFoldersUtil.getExecutionFolder().mkdir(); ClasspathModuleDiscoverer moduleDiscoverer = new ClasspathModuleDiscoverer(classLoader); testCallback.accept(moduleDiscoverer); }); }
/** * {@inheritDoc} */ @Override public ConnectivityTestingService build() { checkState(artifactDeclaration != null, "artifact configuration cannot be null"); return new TemporaryArtifactConnectivityTestingService(() -> { String applicationName = UUID.getUUID() + "-connectivity-testing-temp-app"; File applicationFolder = new File(getExecutionFolder(), applicationName); ApplicationDescriptor applicationDescriptor = new ApplicationDescriptor(applicationName); applicationDescriptor.setArtifactDeclaration(artifactDeclaration); applicationDescriptor.setConfigResources(emptySet()); applicationDescriptor.setArtifactLocation(applicationFolder); createDeployablePomFile(applicationFolder, model); updateArtifactPom(applicationFolder, model); MavenClientProvider mavenClientProvider = MavenClientProvider.discoverProvider(DefaultConnectivityTestingServiceBuilder.class.getClassLoader()); applicationDescriptor .setClassLoaderModel(new DeployableMavenClassLoaderModelLoader(mavenClientProvider .createMavenClient(GlobalConfigLoader.getMavenConfig())) .load(applicationFolder, emptyMap(), ArtifactType.APP)); return defaultApplicationFactory.createArtifact(applicationDescriptor); }); }
private void createExecutionMuleFolder() { File executionFolder = MuleFoldersUtil.getExecutionFolder(); if (!executionFolder.exists()) { if (!executionFolder.mkdirs()) { throw new MuleRuntimeException(CoreMessages.createStaticMessage(String.format( "Could not create folder %s, validate that the process has permissions over that directory", executionFolder.getAbsolutePath()))); } } }
private File getPoliciesTempFolder() { return new File(getExecutionFolder(), "policies"); }
/** * This method resolves the deploymentProperties for a new deploy/redeploy considering the new deployment properties passed by * the user as parameter and the deployment properties persisted in a previous deploy. In case no new deployment properties are * passed, the previous persisted properties are returned. Otherwise, the new deployment properties are used and persisted in * .mule/app/deployment-properties/deployment.properties There is one deployment.properties file for each artifact (domain/app). * * @param artifactName name of the artifact. * @param deploymentProperties deployment properties set in the new deploy/redeploy as parameters. * * @return deployment properties * @throws IOException */ public static Properties resolveDeploymentProperties(String artifactName, Optional<Properties> deploymentProperties) throws IOException { File file = new File(getExecutionFolder(), artifactName); String workingDirectory = file.getAbsolutePath(); String deploymentPropertiesPath = workingDirectory + separator + DEPLOYTMENT_PROPERTIES_DIRECTORY; if (!deploymentProperties.isPresent()) { return getDeploymentProperties(deploymentPropertiesPath); } initDeploymentPropertiesDirectory(deploymentPropertiesPath); persistDeploymentPropertiesFile(deploymentPropertiesPath, deploymentProperties.get()); return deploymentProperties.get(); }
/** * {@inheritDoc} */ @Override public ConnectivityTestingService build() { checkState(artifactDeclaration != null, "artifact configuration cannot be null"); return new TemporaryArtifactConnectivityTestingService(() -> { String applicationName = UUID.getUUID() + "-connectivity-testing-temp-app"; File applicationFolder = new File(getExecutionFolder(), applicationName); ApplicationDescriptor applicationDescriptor = new ApplicationDescriptor(applicationName); applicationDescriptor.setArtifactDeclaration(artifactDeclaration); applicationDescriptor.setConfigResources(emptySet()); applicationDescriptor.setArtifactLocation(applicationFolder); createDeployablePomFile(applicationFolder, model); updateArtifactPom(applicationFolder, model); MavenClientProvider mavenClientProvider = MavenClientProvider.discoverProvider(DefaultConnectivityTestingServiceBuilder.class.getClassLoader()); applicationDescriptor .setClassLoaderModel(new DeployableMavenClassLoaderModelLoader(mavenClientProvider .createMavenClient(GlobalConfigLoader.getMavenConfig()), mavenClientProvider.getLocalRepositorySuppliers()) .load(applicationFolder, emptyMap(), ArtifactType.APP)); return defaultApplicationFactory.createArtifact(applicationDescriptor); }); }