use of com.adaptris.core.Service in project interlok by adaptris.
the class AdapterComponentChecker method applyService.
@Override
public SerializableMessage applyService(String xml, SerializableMessage serializedMsg, boolean rewriteConnections) throws CoreException {
AdaptrisMarshaller marshaller = DefaultMarshaller.getDefaultMarshaller();
Service service = (Service) marshaller.unmarshal(xml);
if (rewriteConnections) {
service = rewriteConnectionsForTesting(service);
}
AdaptrisMessage msg = messageTranslator.translate(serializedMsg);
try {
initAndStart(service);
service.doService(msg);
} finally {
stopAndClose(service);
}
return messageTranslator.translate(msg);
}
use of com.adaptris.core.Service in project interlok by adaptris.
the class AdapterManager method addAndBindSharedService.
@Override
public boolean addAndBindSharedService(String xmlString) throws CoreException, IllegalStateException, IllegalArgumentException {
ensureState(StartedState.getInstance(), InitialisedState.getInstance(), StoppedState.getInstance());
Service comp = (Service) DefaultMarshaller.getDefaultMarshaller().unmarshal(xmlString);
boolean result = getWrappedComponent().getSharedComponents().addService(comp);
if (result) {
getWrappedComponent().getSharedComponents().bindJNDI(comp.getUniqueId());
marshalAndSendNotification();
}
return result;
}
use of com.adaptris.core.Service in project interlok by adaptris.
the class ServiceWorkerPool method cloneService.
private Service cloneService(Service original) throws Exception {
Service result = DefaultMarshaller.roundTrip(original);
LifecycleHelper.registerEventHandler(result, eventHandler);
return result;
}
use of com.adaptris.core.Service in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testServiceExceptionStrictWithErrorHandler.
// In Strict Mode, Then even if you have configured an error handler, then
// the transaction is unsucessful if we have an exception, leading to msgs on
// the queue.
@Test
public void testServiceExceptionStrictWithErrorHandler() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
MockMessageProducer meh = new MockMessageProducer();
Channel channel = createStartableChannel(activeMqBroker, true, "testServiceExceptionStrictWithErrorHandler", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
workflow.setStrict(Boolean.TRUE);
workflow.getServiceCollection().addService(new ThrowExceptionService(new ConfiguredException("Fail")));
channel.setMessageErrorHandler(new StandardProcessingExceptionHandler(new ServiceList(new ArrayList<Service>(Arrays.asList(new Service[] { new StandaloneProducer(meh) })))));
try {
channel.requestStart();
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
send(sender, msgCount);
} finally {
channel.requestClose();
}
assertEquals(msgCount, activeMqBroker.messagesOnQueue(destination));
}
use of com.adaptris.core.Service in project interlok by adaptris.
the class AdapterManager method addSharedService.
@Override
public boolean addSharedService(String xmlString) throws CoreException, IllegalStateException, IllegalArgumentException {
ensureState(ClosedState.getInstance());
Service comp = (Service) DefaultMarshaller.getDefaultMarshaller().unmarshal(xmlString);
boolean result = getWrappedComponent().getSharedComponents().addService(comp);
if (result) {
marshalAndSendNotification();
}
return result;
}
Aggregations