use of org.mule.runtime.core.api.config.bootstrap.PropertiesBootstrapService in project mule by mulesoft.
the class TestBootstrapServiceDiscovererConfigurationBuilder method getArtifactBootstrapService.
private List<BootstrapService> getArtifactBootstrapService(Object artifactClassLoader) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException {
// Uses reflection to access the class loader as classes were loaded from different class loaders so they cannot be casted
ClassLoader classLoader = (ClassLoader) artifactClassLoader.getClass().getMethod("getClassLoader").invoke(artifactClassLoader);
final Enumeration<URL> resources = (Enumeration<URL>) classLoader.getClass().getMethod("findResources", String.class).invoke(classLoader, BOOTSTRAP_PROPERTIES);
final List<BootstrapService> bootstrapServices = new ArrayList<>();
if (resources.hasMoreElements()) {
while (resources.hasMoreElements()) {
final URL localResource = resources.nextElement();
final Properties properties = PropertiesUtils.loadProperties(localResource);
final PropertiesBootstrapService propertiesBootstrapService = new PropertiesBootstrapService(classLoader, properties);
bootstrapServices.add(propertiesBootstrapService);
}
}
return bootstrapServices;
}
use of org.mule.runtime.core.api.config.bootstrap.PropertiesBootstrapService in project mule by mulesoft.
the class ArtifactBootstrapServiceDiscovererConfigurationBuilder method doConfigure.
@Override
protected void doConfigure(MuleContext muleContext) throws Exception {
final PropertiesBootstrapServiceDiscoverer propertiesBootstrapServiceDiscoverer = new PropertiesBootstrapServiceDiscoverer(this.getClass().getClassLoader());
List<BootstrapService> bootstrapServices = new LinkedList<>();
bootstrapServices.addAll(propertiesBootstrapServiceDiscoverer.discover());
for (ArtifactPlugin artifactPlugin : artifactPlugins) {
final Enumeration<URL> resources = artifactPlugin.getArtifactClassLoader().findResources(BOOTSTRAP_PROPERTIES);
while (resources.hasMoreElements()) {
final URL localResource = resources.nextElement();
final Properties properties = PropertiesUtils.loadProperties(localResource);
final BootstrapService pluginBootstrapService = new PropertiesBootstrapService(artifactPlugin.getArtifactClassLoader().getClassLoader(), properties);
bootstrapServices.add(pluginBootstrapService);
}
}
muleContext.setBootstrapServiceDiscoverer(() -> bootstrapServices);
}
Aggregations