use of org.mule.runtime.container.api.MuleCoreExtension in project mule by mulesoft.
the class ClasspathMuleCoreExtensionDiscoverer method discover.
@Override
public List<MuleCoreExtension> discover() throws MuleException {
List<MuleCoreExtension> result = new LinkedList<>();
Enumeration<?> e = ClassUtils.getResources(CORE_EXTENSION_RESOURCE_NAME, getClass().getClassLoader());
List<Properties> extensions = new LinkedList<Properties>();
// load ALL of the extension files first
while (e.hasMoreElements()) {
try {
URL url = (URL) e.nextElement();
if (logger.isDebugEnabled()) {
logger.debug("Reading extension file: " + url.toString());
}
extensions.add(loadProperties(url.openStream()));
} catch (Exception ex) {
throw new DefaultMuleException("Error loading Mule core extensions", ex);
}
}
for (Properties extProps : extensions) {
for (Map.Entry entry : extProps.entrySet()) {
String extName = (String) entry.getKey();
String extClass = (String) entry.getValue();
try {
MuleCoreExtension extension = (MuleCoreExtension) ClassUtils.instantiateClass(extClass);
extension.setContainerClassLoader(containerClassLoader);
result.add(extension);
} catch (Throwable t) {
throw new DefaultMuleException(format("Error starting Mule core extension '%s'. Extension class is %s", extName, extClass), t);
}
}
}
return result;
}
use of org.mule.runtime.container.api.MuleCoreExtension in project mule by mulesoft.
the class DefaultMuleCoreExtensionManagerServer method dispose.
@Override
public void dispose() {
LOGGER.info("Disposing core extensions");
for (MuleCoreExtension extension : coreExtensions) {
if (initializedCoreExtensions.contains(extension)) {
try {
extension.dispose();
LOGGER.info("Core extension '{}' disposed", extension.toString());
} catch (Exception ex) {
LOGGER.error("Error disposing core extension " + extension.getName(), ex);
}
}
}
initializedCoreExtensions.clear();
}
use of org.mule.runtime.container.api.MuleCoreExtension in project mule by mulesoft.
the class DefaultMuleCoreExtensionManagerServer method stop.
@Override
public void stop() throws MuleException {
if (orderedCoreExtensions == null) {
return;
}
LOGGER.info("Stopping core extensions");
for (int i = orderedCoreExtensions.size() - 1; i >= 0; i--) {
MuleCoreExtension extension = orderedCoreExtensions.get(i);
if (startedCoreExtensions.contains(extension)) {
try {
extension.stop();
LOGGER.info("Core extension '{}' stopped", extension.toString());
} catch (Throwable e) {
LOGGER.warn("Error stopping core extension: " + extension.getName(), e);
}
}
}
startedCoreExtensions.clear();
}
Aggregations