Search in sources :

Example 1 with MULE_ARTIFACT_PATH_INSIDE_JAR

use of org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor.MULE_ARTIFACT_PATH_INSIDE_JAR in project mule by mulesoft.

the class ArtifactPluginDescriptorFactory method create.

@Override
public ArtifactPluginDescriptor create(File pluginJarFile, Optional<Properties> deploymentProperties) throws ArtifactDescriptorCreateException {
    try {
        checkArgument(pluginJarFile.isDirectory() || pluginJarFile.getName().endsWith(".jar"), "provided file is not a plugin: " + pluginJarFile.getAbsolutePath());
        // Use / instead of File.separator as the file is going to be accessed inside the jar as a URL
        String mulePluginJsonPathInsideJarFile = MULE_ARTIFACT_PATH_INSIDE_JAR + "/" + MULE_ARTIFACT_JSON_DESCRIPTOR;
        Optional<byte[]> jsonDescriptorContentOptional = loadFileContentFrom(pluginJarFile, mulePluginJsonPathInsideJarFile);
        return jsonDescriptorContentOptional.map(jsonDescriptorContent -> loadFromJsonDescriptor(pluginJarFile, loadModelFromJson(new String(jsonDescriptorContent)), deploymentProperties)).orElseThrow(() -> new ArtifactDescriptorCreateException(pluginDescriptorNotFound(pluginJarFile, mulePluginJsonPathInsideJarFile)));
    } catch (ArtifactDescriptorCreateException e) {
        throw e;
    } catch (IOException e) {
        throw new ArtifactDescriptorCreateException(e);
    }
}
Also used : Properties(java.util.Properties) ArtifactPluginDescriptor(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor) ServiceRegistryDescriptorLoaderRepository(org.mule.runtime.module.deployment.impl.internal.artifact.ServiceRegistryDescriptorLoaderRepository) ArtifactDescriptorCreateException(org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptorCreateException) Preconditions.checkArgument(org.mule.runtime.api.util.Preconditions.checkArgument) MULE_ARTIFACT_PATH_INSIDE_JAR(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor.MULE_ARTIFACT_PATH_INSIDE_JAR) ArtifactDescriptorValidatorBuilder(org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptorValidatorBuilder) IOException(java.io.IOException) String.format(java.lang.String.format) File(java.io.File) SpiServiceRegistry(org.mule.runtime.core.api.registry.SpiServiceRegistry) AbstractMuleArtifactModelJsonSerializer(org.mule.runtime.api.deployment.persistence.AbstractMuleArtifactModelJsonSerializer) DescriptorLoaderRepository(org.mule.runtime.module.artifact.api.descriptor.DescriptorLoaderRepository) ArtifactType(org.mule.runtime.core.api.config.bootstrap.ArtifactType) AbstractArtifactDescriptorFactory(org.mule.runtime.module.artifact.api.descriptor.AbstractArtifactDescriptorFactory) MulePluginModelJsonSerializer(org.mule.runtime.api.deployment.persistence.MulePluginModelJsonSerializer) LoaderDescriber(org.mule.runtime.deployment.model.api.plugin.LoaderDescriber) ClassLoaderModelLoader(org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModelLoader) JarUtils.loadFileContentFrom(org.mule.runtime.core.internal.util.JarUtils.loadFileContentFrom) MULE_ARTIFACT_JSON_DESCRIPTOR(org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptor.MULE_ARTIFACT_JSON_DESCRIPTOR) Optional(java.util.Optional) PLUGIN(org.mule.runtime.core.api.config.bootstrap.ArtifactType.PLUGIN) MulePluginModel(org.mule.runtime.api.deployment.meta.MulePluginModel) ArtifactDescriptorCreateException(org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptorCreateException) IOException(java.io.IOException)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 String.format (java.lang.String.format)1 Optional (java.util.Optional)1 Properties (java.util.Properties)1 MulePluginModel (org.mule.runtime.api.deployment.meta.MulePluginModel)1 AbstractMuleArtifactModelJsonSerializer (org.mule.runtime.api.deployment.persistence.AbstractMuleArtifactModelJsonSerializer)1 MulePluginModelJsonSerializer (org.mule.runtime.api.deployment.persistence.MulePluginModelJsonSerializer)1 Preconditions.checkArgument (org.mule.runtime.api.util.Preconditions.checkArgument)1 ArtifactType (org.mule.runtime.core.api.config.bootstrap.ArtifactType)1 PLUGIN (org.mule.runtime.core.api.config.bootstrap.ArtifactType.PLUGIN)1 SpiServiceRegistry (org.mule.runtime.core.api.registry.SpiServiceRegistry)1 JarUtils.loadFileContentFrom (org.mule.runtime.core.internal.util.JarUtils.loadFileContentFrom)1 ArtifactPluginDescriptor (org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor)1 MULE_ARTIFACT_PATH_INSIDE_JAR (org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor.MULE_ARTIFACT_PATH_INSIDE_JAR)1 LoaderDescriber (org.mule.runtime.deployment.model.api.plugin.LoaderDescriber)1 AbstractArtifactDescriptorFactory (org.mule.runtime.module.artifact.api.descriptor.AbstractArtifactDescriptorFactory)1 MULE_ARTIFACT_JSON_DESCRIPTOR (org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptor.MULE_ARTIFACT_JSON_DESCRIPTOR)1 ArtifactDescriptorCreateException (org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptorCreateException)1 ArtifactDescriptorValidatorBuilder (org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptorValidatorBuilder)1