Search in sources :

Example 1 with IoFilter

use of org.apache.mina.core.filterchain.IoFilter in project camel by apache.

the class Mina2Consumer method setupDatagramProtocol.

protected void setupDatagramProtocol(String uri, Mina2Configuration configuration) {
    boolean minaLogger = configuration.isMinaLogger();
    List<IoFilter> filters = configuration.getFilters();
    address = new InetSocketAddress(configuration.getHost(), configuration.getPort());
    acceptor = new NioDatagramAcceptor();
    // acceptor connectorConfig
    configureDataGramCodecFactory("Mina2Consumer", acceptor, configuration);
    acceptor.setCloseOnDeactivation(true);
    // reuse address is default true for datagram
    if (configuration.isOrderedThreadPoolExecutor()) {
        workerPool = new OrderedThreadPoolExecutor(configuration.getMaximumPoolSize());
    } else {
        workerPool = new UnorderedThreadPoolExecutor(configuration.getMaximumPoolSize());
    }
    acceptor.getFilterChain().addLast("threadPool", new ExecutorFilter(workerPool));
    if (minaLogger) {
        acceptor.getFilterChain().addLast("logger", new LoggingFilter());
    }
    appendIoFiltersToChain(filters, acceptor.getFilterChain());
    if (configuration.getSslContextParameters() != null) {
        LOG.warn("Using datagram protocol, " + configuration.getProtocol() + ", but an SSLContextParameters instance was provided.  SSLContextParameters is only supported on the TCP protocol.");
    }
}
Also used : UnorderedThreadPoolExecutor(org.apache.mina.filter.executor.UnorderedThreadPoolExecutor) OrderedThreadPoolExecutor(org.apache.mina.filter.executor.OrderedThreadPoolExecutor) InetSocketAddress(java.net.InetSocketAddress) ExecutorFilter(org.apache.mina.filter.executor.ExecutorFilter) LoggingFilter(org.apache.mina.filter.logging.LoggingFilter) IoFilter(org.apache.mina.core.filterchain.IoFilter) NioDatagramAcceptor(org.apache.mina.transport.socket.nio.NioDatagramAcceptor)

Example 2 with IoFilter

use of org.apache.mina.core.filterchain.IoFilter in project camel by apache.

the class Mina2FiltersTest method createJndiContext.

@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    IoFilter myFilter = new TestFilter();
    List<IoFilter> myFilters = new ArrayList<IoFilter>();
    myFilters.add(myFilter);
    answer.bind("myFilters", myFilters);
    answer.bind("myFilter", myFilter);
    return answer;
}
Also used : JndiContext(org.apache.camel.util.jndi.JndiContext) ArrayList(java.util.ArrayList) IoFilter(org.apache.mina.core.filterchain.IoFilter)

Example 3 with IoFilter

use of org.apache.mina.core.filterchain.IoFilter in project camel by apache.

the class Mina2Consumer method setupSocketProtocol.

protected void setupSocketProtocol(String uri, Mina2Configuration configuration) throws Exception {
    LOG.debug("createSocketEndpoint");
    boolean minaLogger = configuration.isMinaLogger();
    List<IoFilter> filters = configuration.getFilters();
    address = new InetSocketAddress(configuration.getHost(), configuration.getPort());
    final int processorCount = Runtime.getRuntime().availableProcessors() + 1;
    acceptor = new NioSocketAcceptor(processorCount);
    // acceptor connectorConfig
    configureCodecFactory("Mina2Consumer", acceptor, configuration);
    ((NioSocketAcceptor) acceptor).setReuseAddress(true);
    acceptor.setCloseOnDeactivation(true);
    if (configuration.isOrderedThreadPoolExecutor()) {
        workerPool = new OrderedThreadPoolExecutor(configuration.getMaximumPoolSize());
    } else {
        workerPool = new UnorderedThreadPoolExecutor(configuration.getMaximumPoolSize());
    }
    acceptor.getFilterChain().addLast("threadPool", new ExecutorFilter(workerPool));
    if (minaLogger) {
        acceptor.getFilterChain().addLast("logger", new LoggingFilter());
    }
    appendIoFiltersToChain(filters, acceptor.getFilterChain());
    if (configuration.getSslContextParameters() != null) {
        SslFilter filter = new SslFilter(configuration.getSslContextParameters().createSSLContext(getEndpoint().getCamelContext()), configuration.isAutoStartTls());
        filter.setUseClientMode(false);
        acceptor.getFilterChain().addFirst("sslFilter", filter);
    }
}
Also used : SslFilter(org.apache.mina.filter.ssl.SslFilter) UnorderedThreadPoolExecutor(org.apache.mina.filter.executor.UnorderedThreadPoolExecutor) OrderedThreadPoolExecutor(org.apache.mina.filter.executor.OrderedThreadPoolExecutor) InetSocketAddress(java.net.InetSocketAddress) ExecutorFilter(org.apache.mina.filter.executor.ExecutorFilter) LoggingFilter(org.apache.mina.filter.logging.LoggingFilter) IoFilter(org.apache.mina.core.filterchain.IoFilter) NioSocketAcceptor(org.apache.mina.transport.socket.nio.NioSocketAcceptor)

Example 4 with IoFilter

use of org.apache.mina.core.filterchain.IoFilter in project camel by apache.

the class Mina2Consumer method setupVmProtocol.

// Implementation methods
//-------------------------------------------------------------------------
protected void setupVmProtocol(String uri, Mina2Configuration configuration) {
    boolean minaLogger = configuration.isMinaLogger();
    List<IoFilter> filters = configuration.getFilters();
    address = new VmPipeAddress(configuration.getPort());
    acceptor = new VmPipeAcceptor();
    // acceptor connectorConfig
    configureCodecFactory("Mina2Consumer", acceptor, configuration);
    if (minaLogger) {
        acceptor.getFilterChain().addLast("logger", new LoggingFilter());
    }
    appendIoFiltersToChain(filters, acceptor.getFilterChain());
    if (configuration.getSslContextParameters() != null) {
        LOG.warn("Using vm protocol" + ", but an SSLContextParameters instance was provided.  SSLContextParameters is only supported on the TCP protocol.");
    }
}
Also used : VmPipeAcceptor(org.apache.mina.transport.vmpipe.VmPipeAcceptor) LoggingFilter(org.apache.mina.filter.logging.LoggingFilter) IoFilter(org.apache.mina.core.filterchain.IoFilter) VmPipeAddress(org.apache.mina.transport.vmpipe.VmPipeAddress)

Example 5 with IoFilter

use of org.apache.mina.core.filterchain.IoFilter in project camel by apache.

the class Mina2Consumer method setupClientSocketProtocol.

protected void setupClientSocketProtocol(String uri, Mina2Configuration configuration) throws Exception {
    boolean minaLogger = configuration.isMinaLogger();
    long timeout = configuration.getTimeout();
    List<IoFilter> filters = configuration.getFilters();
    address = new InetSocketAddress(configuration.getHost(), configuration.getPort());
    final int processorCount = Runtime.getRuntime().availableProcessors() + 1;
    connector = new NioSocketConnector(processorCount);
    if (configuration.isOrderedThreadPoolExecutor()) {
        workerPool = new OrderedThreadPoolExecutor(configuration.getMaximumPoolSize());
    } else {
        workerPool = new UnorderedThreadPoolExecutor(configuration.getMaximumPoolSize());
    }
    connector.getFilterChain().addLast("threadPool", new ExecutorFilter(workerPool));
    if (minaLogger) {
        connector.getFilterChain().addLast("logger", new LoggingFilter());
    }
    appendIoFiltersToChain(filters, connector.getFilterChain());
    if (configuration.getSslContextParameters() != null) {
        SslFilter filter = new SslFilter(configuration.getSslContextParameters().createSSLContext(getEndpoint().getCamelContext()), configuration.isAutoStartTls());
        filter.setUseClientMode(true);
        connector.getFilterChain().addFirst("sslFilter", filter);
    }
    configureCodecFactory("Mina2Consumer", connector, configuration);
    connector.setConnectTimeoutMillis(timeout);
}
Also used : SslFilter(org.apache.mina.filter.ssl.SslFilter) NioSocketConnector(org.apache.mina.transport.socket.nio.NioSocketConnector) UnorderedThreadPoolExecutor(org.apache.mina.filter.executor.UnorderedThreadPoolExecutor) OrderedThreadPoolExecutor(org.apache.mina.filter.executor.OrderedThreadPoolExecutor) InetSocketAddress(java.net.InetSocketAddress) ExecutorFilter(org.apache.mina.filter.executor.ExecutorFilter) LoggingFilter(org.apache.mina.filter.logging.LoggingFilter) IoFilter(org.apache.mina.core.filterchain.IoFilter)

Aggregations

IoFilter (org.apache.mina.core.filterchain.IoFilter)9 LoggingFilter (org.apache.mina.filter.logging.LoggingFilter)7 InetSocketAddress (java.net.InetSocketAddress)5 ExecutorFilter (org.apache.mina.filter.executor.ExecutorFilter)5 OrderedThreadPoolExecutor (org.apache.mina.filter.executor.OrderedThreadPoolExecutor)5 UnorderedThreadPoolExecutor (org.apache.mina.filter.executor.UnorderedThreadPoolExecutor)5 SslFilter (org.apache.mina.filter.ssl.SslFilter)3 NioSocketConnector (org.apache.mina.transport.socket.nio.NioSocketConnector)2 VmPipeAddress (org.apache.mina.transport.vmpipe.VmPipeAddress)2 ArrayList (java.util.ArrayList)1 JndiContext (org.apache.camel.util.jndi.JndiContext)1 DefaultIoFilterChainBuilder (org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder)1 ProtocolCodecFilter (org.apache.mina.filter.codec.ProtocolCodecFilter)1 NioDatagramAcceptor (org.apache.mina.transport.socket.nio.NioDatagramAcceptor)1 NioDatagramConnector (org.apache.mina.transport.socket.nio.NioDatagramConnector)1 NioSocketAcceptor (org.apache.mina.transport.socket.nio.NioSocketAcceptor)1 VmPipeAcceptor (org.apache.mina.transport.vmpipe.VmPipeAcceptor)1 VmPipeConnector (org.apache.mina.transport.vmpipe.VmPipeConnector)1