use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class ArtifactFunctionalTestCase method createServiceManager.
private static void createServiceManager() {
serviceRepository = ServiceManager.create(ServiceDiscoverer.create(new IsolatedServiceProviderDiscoverer(serviceClassLoaders)));
try {
serviceRepository.start();
} catch (MuleException e) {
throw new IllegalStateException("Couldn't start service manager", e);
}
serviceConfigurator = new TestServicesMuleContextConfigurator(serviceRepository);
}
use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class ExtensionMessageSourceTestCase method workManagerDisposedIfSourceFailsToStart.
@Test
public void workManagerDisposedIfSourceFailsToStart() throws Exception {
start();
Exception e = new RuntimeException();
doThrow(e).when(source).onStop();
expectedException.expect(new BaseMatcher<Throwable>() {
@Override
public boolean matches(Object item) {
Exception exception = (Exception) item;
return exception.getCause() instanceof MuleException && exception.getCause().getCause() == e;
}
@Override
public void describeTo(Description description) {
description.appendText("Exception was not wrapped as expected");
}
});
}
use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class MuleContainer method shutdown.
/**
* Will shut down the server displaying the cause and time of the shutdown
*
* @param e the exception that caused the shutdown
*/
public void shutdown(Throwable e) throws MuleException {
I18nMessage msg = fatalErrorWhileRunning();
MuleException muleException = getRootMuleException(e);
if (muleException != null) {
logger.error(muleException.getDetailedMessage());
} else {
logger.error(msg.toString() + " " + e.getMessage(), e);
}
List<String> msgs = new ArrayList<>();
msgs.add(msg.getMessage());
Throwable root = getRootException(e);
msgs.add(root.getMessage() + " (" + root.getClass().getName() + ")");
msgs.add(" ");
msgs.add(fatalErrorInShutdown().getMessage());
String shutdownMessage = getBoilerPlate(msgs, '*', 80);
logger.error(shutdownMessage);
doShutdown();
System.exit(1);
}
use of org.mule.runtime.api.exception.MuleException 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.api.exception.MuleException in project mule by mulesoft.
the class ExtensionActivator method registerEnumTransformers.
private void registerEnumTransformers(ExtensionModel extensionModel) {
ClassLoader classLoader = getClassLoader(extensionModel);
Set<Class<?>> parameterClasses = new HashSet<>();
parameterClasses.addAll(getParameterClasses(extensionModel, classLoader));
parameterClasses.addAll(getSubtypeClasses(extensionModel, classLoader));
parameterClasses.stream().filter(type -> Enum.class.isAssignableFrom(type)).forEach(type -> {
final Class<Enum> enumClass = (Class<Enum>) type;
if (enumTypes.add(enumClass)) {
try {
StringToEnum stringToEnum = new StringToEnum(enumClass);
registerObject(muleContext, getName(stringToEnum), stringToEnum, Transformer.class);
} catch (MuleException e) {
throw new MuleRuntimeException(createStaticMessage("Could not register transformer for enum " + enumClass.getName()), e);
}
}
});
}
Aggregations