use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class AbstractQueueTxJournalEntry method write.
public void write(DataOutputStream outputStream, MuleContext muleContext) {
try {
serializeTxId(outputStream);
outputStream.write(operation);
if (isCheckpointOperation(operation)) {
outputStream.flush();
return;
}
outputStream.write(queueName.length());
outputStream.write(queueName.getBytes());
byte[] serializedValue = muleContext.getObjectSerializer().getInternalProtocol().serialize(value);
outputStream.writeInt(serializedValue.length);
outputStream.write(serializedValue);
outputStream.flush();
} catch (IOException e) {
throw new MuleRuntimeException(e);
}
}
use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class MuleObjectStoreManager method doCreateObjectStore.
private <T extends ObjectStore<?>> T doCreateObjectStore(String name, ObjectStoreSettings settings) {
final ObjectStore<? extends Serializable> baseStore = getBaseStore(settings);
T store;
try {
store = getPartitionFromBaseObjectStore(baseStore, name);
} catch (Exception e) {
throw new MuleRuntimeException(createStaticMessage("Found exception trying to create Object Store of name " + name), e);
}
if (settings.getExpirationInterval() > 0 && (settings.getMaxEntries().isPresent() || settings.getEntryTTL().isPresent())) {
store = getMonitorablePartition(name, baseStore, store, settings);
}
return store;
}
use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class AbstractMessageProcessorChain method initialise.
@Override
public void initialise() throws InitialisationException {
processorInterceptorManager.getInterceptorFactories().stream().forEach(interceptorFactory -> {
ReactiveInterceptorAdapter reactiveInterceptorAdapter = new ReactiveInterceptorAdapter(interceptorFactory);
try {
muleContext.getInjector().inject(reactiveInterceptorAdapter);
} catch (MuleException e) {
throw new MuleRuntimeException(e);
}
additionalInterceptors.add(0, reactiveInterceptorAdapter);
});
processorInterceptorManager.getInterceptorFactories().stream().forEach(interceptorFactory -> {
ReactiveAroundInterceptorAdapter reactiveInterceptorAdapter = new ReactiveAroundInterceptorAdapter(interceptorFactory);
try {
muleContext.getInjector().inject(reactiveInterceptorAdapter);
} catch (MuleException e) {
throw new MuleRuntimeException(e);
}
additionalInterceptors.add(0, reactiveInterceptorAdapter);
});
initialiseIfNeeded(getMessageProcessorsForLifecycle(), muleContext);
}
use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class AnnotatedObjectInvocationHandler method removeDynamicAnnotations.
/**
* Returns a newly built object containing the state of the given {@code annotated} object, but without any of its annotations.
* <p>
* This is useful when trying to use the base object in some scenarios where the object is introspected, to avoid the
* dynamically added stuff to interfere with that introspection.
* <p>
* Note that there is no consistent state kept between the {@code annotated} and the returned objects. After calling this
* method, the {@code annotated} object should be discarded (unless it is immutable, which wouldn't cause any problems)
*
* @param annotated the object to remove dynamic stuff from
* @return a newly built object.
*/
public static <T, A> T removeDynamicAnnotations(A annotated) {
if (annotated instanceof DynamicallyComponent) {
Class<?> baseClass = annotated.getClass().getSuperclass();
Map<String, Field> fieldsByName = new HashMap<>();
Class<?> currentClass = baseClass;
while (currentClass != Object.class) {
Field[] targetFields = currentClass.getDeclaredFields();
for (Field field : targetFields) {
if (!isStatic(field.getModifiers()) && !fieldsByName.containsKey(field.getName())) {
fieldsByName.put(field.getName(), field);
}
}
currentClass = currentClass.getSuperclass();
}
try {
T base = (T) baseClass.newInstance();
for (Field field : fieldsByName.values()) {
boolean acc = field.isAccessible();
field.setAccessible(true);
try {
field.set(base, field.get(annotated));
} finally {
field.setAccessible(acc);
}
}
return base;
} catch (Exception e) {
throw new MuleRuntimeException(e);
}
} else {
return (T) annotated;
}
}
use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class AbstractDependencyFileBuilder method getArtifactPomFile.
public File getArtifactPomFile() {
if (artifactPomFile == null) {
checkArgument(!isEmpty(artifactId), "Filename cannot be empty");
final File tempFile = new File(getTempFolder(), artifactId + ".pom");
tempFile.deleteOnExit();
Model model = new Model();
model.setGroupId(getGroupId());
model.setArtifactId(getArtifactId());
model.setVersion(getVersion());
model.setModelVersion("4.0.0");
if (!sharedLibraries.isEmpty()) {
model.setBuild(new Build());
model.getBuild().setPlugins(singletonList(createMuleMavenPlugin()));
}
for (AbstractDependencyFileBuilder fileBuilderDependency : dependencies) {
model.addDependency(fileBuilderDependency.getAsMavenDependency());
}
artifactPomFile = new File(tempFile.getAbsolutePath());
try (FileOutputStream fileOutputStream = new FileOutputStream(artifactPomFile)) {
new MavenXpp3Writer().write(fileOutputStream, model);
} catch (IOException e) {
throw new MuleRuntimeException(e);
}
}
return artifactPomFile;
}
Aggregations