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);
}
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;
}
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;
}
Aggregations