Package org.mokai

Examples of org.mokai.ConnectorService


  public String route(Message message) {

    // check if the message already has a destination
    if (message.getDestination() != null) {

      ConnectorService connectorService = getConnectorService(message.getDestination());

      if (connectorService != null && acceptsMessage(connectorService, message, false)) {
        return getUriPrefix() + connectorService.getId();
      }

      // unroutable
      message.setStatus(Message.STATUS_UNROUTABLE);
      return getUnroutableMessagesUri();
    }

    // try to route the message
    List<ConnectorService> connectorServices = getConnectorServices();
    for (ConnectorService connectorService : connectorServices) {
      if (acceptsMessage(connectorService, message, true)) {
        return getUriPrefix() + connectorService.getId();
      }
    }

    // unroutable
    message.setStatus(Message.STATUS_UNROUTABLE);
View Full Code Here


  }

  private void removeAndDestroyConnector(String id, Map<String,ConnectorService> map, String mapName) {
    Validate.notEmpty(id);

    ConnectorService cs = map.remove(id);
    if (cs == null) {
      throw new ObjectNotFoundException("Connector with id " + id + " doesnt exists in map of " + mapName);
    }

    // call the destroy method on the processor or receiver service
    cs.destroy();
  }
View Full Code Here

  }

  private ConnectorService getConnector(String id, Map<String,ConnectorService> map) {
    Validate.notEmpty(id);

    ConnectorService cs = map.get(id);
    if (cs != null && ConnectorService.class.isInstance(cs)) {
      return cs;
    }

    return null;
View Full Code Here

    // build the post-receiving actions
    final List<Action> postReceivingActions = buildActions(connectorElement.element("post-receiving-actions"));

    String id = connectorElement.attributeValue("id");
    int priority = getPriority(connectorElement);
    ConnectorService processorService = addConnector(id, connector);
    processorService.setPriority(priority);

    // set maxConcurrentMsgs of the ProcessorService
    int maxConcurrentMsgs = getMaxConcurrentMsgs(connectorElement);
    processorService.setMaxConcurrentMsgs(maxConcurrentMsgs);

    // add acceptors to the processor
    for (Acceptor acceptor : acceptors) {
      processorService.addAcceptor(acceptor);
    }

    // add pre-processing-actions to the processor
    for (Action action : preProcessingActions) {
      processorService.addPreProcessingAction(action);
    }

    // add post-processing-actions to the processor
    for (Action action : postProcessingActions) {
      processorService.addPostProcessingAction(action);
    }

    // add post-receiving-actions to the processor
    for (Action action : postReceivingActions) {
      processorService.addPostReceivingAction(action);
    }
  }
View Full Code Here

    testGoodFile(path, null);
  }

  private void testGoodFile(String path, PluginMechanism pluginMechanism) throws Exception {
    ConnectorService connectorService1 = mock(ConnectorService.class);
    ConnectorService connectorService2 = mock(ConnectorService.class);

    ConfigDelegator delegator = mock(ConfigDelegator.class);
    when(delegator.addConnector(eq("test-1"), any(Connector.class)))
        .thenAnswer(new ConnectorServiceAnswer(connectorService1, 500));
    when(delegator.addConnector(eq("test-2"), any(Processor.class)))
View Full Code Here

  @Test
  public void testLoadFileWithPluginMechanism() throws Exception {
    String path = "src/test/resources/config-test/plugin-connectors.xml";

    ConnectorService connectorService = mock(ConnectorService.class);

    ConfigDelegator delegator = mock(ConfigDelegator.class);
    when(delegator.addConnector(anyString(), any(Connector.class)))
      .thenReturn(connectorService);
View Full Code Here

    List<ConnectorService> connectorServices = delegator.getConnectors();
    Assert.assertNotNull(connectorServices);
    Assert.assertEquals(connectorServices.size(), 1);

    ConnectorService connectorService = connectorServices.iterator().next();
    Assert.assertNotNull(connectorService);

    MockConnectorWithConnectors connector = (MockConnectorWithConnectors) connectorService.getConnector();
    Assert.assertNotNull(connector);

    Assert.assertNotNull(connector.getConnector());
    Assert.assertEquals(connector.getListConnectors().size(), 1);
    Assert.assertEquals(connector.getMapConnectors().size(), 1);
View Full Code Here

    List<ConnectorService> connectorServices = delegator.getConnectors();
    Assert.assertNotNull(connectorServices);
    Assert.assertEquals(connectorServices.size(), 1);

    ConnectorService connectorService = connectorServices.iterator().next();
    Assert.assertNotNull(connectorService);

    List<Acceptor> acceptors = connectorService.getAcceptors();
    Assert.assertNotNull(acceptors);
    Assert.assertEquals(acceptors.size(), 1);

    MockAcceptorWithAcceptor acceptor = (MockAcceptorWithAcceptor) acceptors.iterator().next();
    Assert.assertNotNull(acceptor);
View Full Code Here

    List<ConnectorService> connectorServices = delegator.getConnectors();
    Assert.assertNotNull(connectorServices);
    Assert.assertEquals(connectorServices.size(), 1);

    ConnectorService connectorService = connectorServices.iterator().next();
    Assert.assertNotNull(connectorService);

    List<Acceptor> acceptors = connectorService.getAcceptors();
    Assert.assertNotNull(acceptors);
    Assert.assertEquals(acceptors.size(), 3);

    Acceptor acceptor0 = acceptors.get(0);
    Assert.assertNotNull(acceptor0);
View Full Code Here

    List<ConnectorService> connectorServices = delegator.getConnectors();
    Assert.assertNotNull(connectorServices);
    Assert.assertEquals(connectorServices.size(), 1);

    ConnectorService connectorService = connectorServices.iterator().next();
    Assert.assertNotNull(connectorService);

    List<Acceptor> acceptors = connectorService.getAcceptors();
    Assert.assertNotNull(acceptors);
    Assert.assertEquals(acceptors.size(), 2);

    Acceptor acceptor0 = acceptors.get(0);
    Assert.assertNotNull(acceptor0);
View Full Code Here

TOP

Related Classes of org.mokai.ConnectorService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.