Search in sources :

Example 26 with Service

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);
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Service(com.adaptris.core.Service)

Example 27 with Service

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;
}
Also used : Service(com.adaptris.core.Service)

Example 28 with Service

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;
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) Service(com.adaptris.core.Service)

Example 29 with Service

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));
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) ServiceList(com.adaptris.core.ServiceList) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) JmsTransactedWorkflow(com.adaptris.core.jms.JmsTransactedWorkflow) ConfiguredException(com.adaptris.core.services.exception.ConfiguredException) Service(com.adaptris.core.Service) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) PtpProducer(com.adaptris.core.jms.PtpProducer) StandardProcessingExceptionHandler(com.adaptris.core.StandardProcessingExceptionHandler) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 30 with Service

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;
}
Also used : Service(com.adaptris.core.Service)

Aggregations

Service (com.adaptris.core.Service)49 Test (org.junit.Test)38 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)28 ServiceList (com.adaptris.core.ServiceList)16 ArrayList (java.util.ArrayList)16 ComponentLifecycle (com.adaptris.core.ComponentLifecycle)14 AdvancedJdbcPooledConnection (com.adaptris.core.jdbc.AdvancedJdbcPooledConnection)12 PooledConnectionHelper (com.adaptris.core.jdbc.PooledConnectionHelper)12 ServiceException (com.adaptris.core.ServiceException)11 MetadataElement (com.adaptris.core.MetadataElement)10 NullService (com.adaptris.core.NullService)10 StandaloneProducer (com.adaptris.core.StandaloneProducer)10 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)10 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)9 LogMessageService (com.adaptris.core.services.LogMessageService)8 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)7 MockChannel (com.adaptris.core.stubs.MockChannel)7 StandardProcessingExceptionHandler (com.adaptris.core.StandardProcessingExceptionHandler)6 JdbcPooledConnection (com.adaptris.core.jdbc.JdbcPooledConnection)6 GuidGenerator (com.adaptris.util.GuidGenerator)6