Search in sources :

Example 46 with Service

use of com.adaptris.core.Service in project interlok by adaptris.

the class ServiceCollectionCase method testSetAtPosition.

@Test
public void testSetAtPosition() throws Exception {
    ServiceCollectionImp sc = createServiceCollection();
    sc.addService(new NullService(UUID.randomUUID().toString()));
    WaitService wait = new WaitService(UUID.randomUUID().toString());
    sc.addService(wait);
    sc.addService(new NullService(UUID.randomUUID().toString()));
    Service s = sc.set(1, new NullService(UUID.randomUUID().toString()));
    assertEquals(WaitService.class, s.getClass());
    assertEquals(wait, s);
    assertEquals(3, sc.size());
    assertFalse(sc.contains(wait));
}
Also used : WaitService(com.adaptris.core.services.WaitService) ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) NullService(com.adaptris.core.NullService) Service(com.adaptris.core.Service) EventHandlerAwareService(com.adaptris.core.stubs.EventHandlerAwareService) WaitService(com.adaptris.core.services.WaitService) Test(org.junit.Test)

Example 47 with Service

use of com.adaptris.core.Service in project interlok by adaptris.

the class ServiceCollectionCase method testSetServices.

@Test
public void testSetServices() throws Exception {
    ServiceCollectionImp sc = createServiceCollection();
    List<Service> services = Arrays.asList(new Service[] { new NullService(UUID.randomUUID().toString()), new NullService(UUID.randomUUID().toString()) });
    sc.setServices(services);
    assertEquals(2, sc.size());
    assertEquals(services, sc.getServices());
    try {
        sc.setServices(null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    assertEquals(2, sc.size());
    assertEquals(services, sc.getServices());
}
Also used : ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) NullService(com.adaptris.core.NullService) Service(com.adaptris.core.Service) EventHandlerAwareService(com.adaptris.core.stubs.EventHandlerAwareService) WaitService(com.adaptris.core.services.WaitService) Test(org.junit.Test)

Example 48 with Service

use of com.adaptris.core.Service in project interlok by adaptris.

the class DynamicServiceExecutor method doService.

@Override
public void doService(AdaptrisMessage msg) throws ServiceException {
    try {
        Service service = createService(msg);
        log.trace("Created service [{}]", friendlyName(service));
        LifecycleHelper.registerEventHandler(service, eventHandler);
        LifecycleHelper.initAndStart(service, false);
        service.doService(msg);
        LifecycleHelper.stopAndClose(service, false);
    } catch (Exception e) {
        throw ExceptionHelper.wrapServiceException(e);
    }
}
Also used : Service(com.adaptris.core.Service) ServiceException(com.adaptris.core.ServiceException) CoreException(com.adaptris.core.CoreException)

Example 49 with Service

use of com.adaptris.core.Service in project interlok by adaptris.

the class ServiceUtil method rewriteConnectionsForTesting.

public static Service rewriteConnectionsForTesting(Service service) throws CoreException {
    Service rewritten = service;
    if (rewritten instanceof ConnectedService) {
        ConnectedService connectedService = (ConnectedService) rewritten;
        connectedService.setConnection(cloneForTesting(connectedService.getConnection()));
    }
    if (rewritten instanceof ServiceCollection) {
        rewriteConnectionsForTesting((ServiceCollection) rewritten);
    }
    if (rewritten instanceof ServiceWrapper) {
        rewriteConnectionsForTesting((ServiceWrapper) rewritten);
    }
    return rewritten;
}
Also used : ServiceCollection(com.adaptris.core.ServiceCollection) ServiceWrapper(com.adaptris.core.ServiceWrapper) ConnectedService(com.adaptris.core.ConnectedService) Service(com.adaptris.core.Service) ConnectedService(com.adaptris.core.ConnectedService)

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