Search in sources :

Example 1 with PropertiesBootstrapServiceDiscoverer

use of org.mule.runtime.core.api.config.bootstrap.PropertiesBootstrapServiceDiscoverer 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);
}
Also used : PropertiesBootstrapServiceDiscoverer(org.mule.runtime.core.api.config.bootstrap.PropertiesBootstrapServiceDiscoverer) PropertiesBootstrapService(org.mule.runtime.core.api.config.bootstrap.PropertiesBootstrapService) Properties(java.util.Properties) LinkedList(java.util.LinkedList) URL(java.net.URL) BootstrapService(org.mule.runtime.core.api.config.bootstrap.BootstrapService) PropertiesBootstrapService(org.mule.runtime.core.api.config.bootstrap.PropertiesBootstrapService) ArtifactPlugin(org.mule.runtime.deployment.model.api.plugin.ArtifactPlugin)

Example 2 with PropertiesBootstrapServiceDiscoverer

use of org.mule.runtime.core.api.config.bootstrap.PropertiesBootstrapServiceDiscoverer in project mule by mulesoft.

the class TestBootstrapServiceDiscovererConfigurationBuilder method doConfigure.

@Override
protected void doConfigure(MuleContext muleContext) throws Exception {
    final PropertiesBootstrapServiceDiscoverer propertiesBootstrapServiceDiscoverer = new PropertiesBootstrapServiceDiscoverer(containerClassLoader);
    List<BootstrapService> bootstrapServices = new LinkedList<>();
    bootstrapServices.addAll(propertiesBootstrapServiceDiscoverer.discover());
    // Uses Object instead of ArtifactClassLoader because that class was originally loaded from a different class loader
    for (Object pluginClassLoader : pluginClassLoaders) {
        List<BootstrapService> pluginBootstrapServices = getArtifactBootstrapService(pluginClassLoader);
        bootstrapServices.addAll(pluginBootstrapServices);
    }
    List<BootstrapService> appBootstrapServices = getArtifactBootstrapService(executionClassLoader);
    bootstrapServices.addAll(appBootstrapServices);
    muleContext.setBootstrapServiceDiscoverer(() -> bootstrapServices);
}
Also used : PropertiesBootstrapServiceDiscoverer(org.mule.runtime.core.api.config.bootstrap.PropertiesBootstrapServiceDiscoverer) LinkedList(java.util.LinkedList) BootstrapService(org.mule.runtime.core.api.config.bootstrap.BootstrapService) PropertiesBootstrapService(org.mule.runtime.core.api.config.bootstrap.PropertiesBootstrapService)

Aggregations

LinkedList (java.util.LinkedList)2 BootstrapService (org.mule.runtime.core.api.config.bootstrap.BootstrapService)2 PropertiesBootstrapService (org.mule.runtime.core.api.config.bootstrap.PropertiesBootstrapService)2 PropertiesBootstrapServiceDiscoverer (org.mule.runtime.core.api.config.bootstrap.PropertiesBootstrapServiceDiscoverer)2 URL (java.net.URL)1 Properties (java.util.Properties)1 ArtifactPlugin (org.mule.runtime.deployment.model.api.plugin.ArtifactPlugin)1