Search in sources :

Example 1 with ServiceDescriptor

use of org.mule.runtime.module.service.internal.artifact.ServiceDescriptor in project mule by mulesoft.

the class FileSystemServiceProviderDiscoverer method discover.

@Override
public List<Pair<ArtifactClassLoader, ServiceProvider>> discover() throws ServiceResolutionError {
    final ServiceDescriptorFactory serviceDescriptorFactory = new ServiceDescriptorFactory(descriptorLoaderRepository, artifactDescriptorValidatorBuilder);
    final List<ServiceDescriptor> serviceDescriptors = new LinkedList<>();
    serviceDescriptors.addAll(getServiceDescriptors(serviceDescriptorFactory));
    return createServiceProviders(serviceDescriptors, serviceClassLoaderFactory);
}
Also used : ServiceDescriptorFactory(org.mule.runtime.module.service.internal.artifact.ServiceDescriptorFactory) ServiceDescriptor(org.mule.runtime.module.service.internal.artifact.ServiceDescriptor) LinkedList(java.util.LinkedList)

Example 2 with ServiceDescriptor

use of org.mule.runtime.module.service.internal.artifact.ServiceDescriptor in project mule by mulesoft.

the class FileSystemServiceProviderDiscoverer method getServiceDescriptors.

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;
}
Also used : ServiceDescriptor(org.mule.runtime.module.service.internal.artifact.ServiceDescriptor) ServiceResolutionError(org.mule.runtime.module.service.api.discoverer.ServiceResolutionError) SuffixFileFilter(org.apache.commons.io.filefilter.SuffixFileFilter) IOException(java.io.IOException) File(java.io.File) LinkedList(java.util.LinkedList)

Example 3 with ServiceDescriptor

use of org.mule.runtime.module.service.internal.artifact.ServiceDescriptor in project mule by mulesoft.

the class FileSystemServiceProviderDiscoverer method createServiceProviders.

private List<Pair<ArtifactClassLoader, ServiceProvider>> createServiceProviders(List<ServiceDescriptor> serviceDescriptors, ArtifactClassLoaderFactory<ServiceDescriptor> serviceClassLoaderFactory) throws ServiceResolutionError {
    List<Pair<ArtifactClassLoader, ServiceProvider>> serviceProviders = new LinkedList<>();
    for (ServiceDescriptor serviceDescriptor : serviceDescriptors) {
        final ArtifactClassLoader serviceClassLoader = serviceClassLoaderFactory.create(getServiceArtifactId(serviceDescriptor), serviceDescriptor, apiClassLoader.getClassLoader(), apiClassLoader.getClassLoaderLookupPolicy());
        final ServiceProvider serviceProvider = instantiateServiceProvider(serviceClassLoader.getClassLoader(), serviceDescriptor.getServiceProviderClassName());
        serviceProviders.add(new Pair<>(serviceClassLoader, serviceProvider));
    }
    return serviceProviders;
}
Also used : ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) ServiceDescriptor(org.mule.runtime.module.service.internal.artifact.ServiceDescriptor) ServiceProvider(org.mule.runtime.api.service.ServiceProvider) LinkedList(java.util.LinkedList) Pair(org.mule.runtime.api.util.Pair)

Aggregations

LinkedList (java.util.LinkedList)3 ServiceDescriptor (org.mule.runtime.module.service.internal.artifact.ServiceDescriptor)3 File (java.io.File)1 IOException (java.io.IOException)1 SuffixFileFilter (org.apache.commons.io.filefilter.SuffixFileFilter)1 ServiceProvider (org.mule.runtime.api.service.ServiceProvider)1 Pair (org.mule.runtime.api.util.Pair)1 ArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader)1 ServiceResolutionError (org.mule.runtime.module.service.api.discoverer.ServiceResolutionError)1 ServiceDescriptorFactory (org.mule.runtime.module.service.internal.artifact.ServiceDescriptorFactory)1