Package org.apache.mina.transport.socket.nio

Examples of org.apache.mina.transport.socket.nio.SocketAcceptorConfig


    private static final boolean USE_SSL = false;

    public static void main(String[] args) throws Exception {
        IoAcceptor acceptor = new SocketAcceptor();
        IoAcceptorConfig config = new SocketAcceptorConfig();
        DefaultIoFilterChainBuilder chain = config.getFilterChain();

        ((SocketSessionConfig) config.getSessionConfig()).setReuseAddress(true);
        // Add SSL filter if SSL is enabled.
        if (USE_SSL) {
            addSSLSupport(chain);
        }
View Full Code Here


        try {
            // Create an acceptor
            IoAcceptor acceptor = new SocketAcceptor();

            // Create a service configuration
            SocketAcceptorConfig cfg = new SocketAcceptorConfig();
            cfg.setReuseAddress(true);
            cfg.getFilterChain().addLast(
                    "protocolFilter",
                    new ProtocolCodecFilter(
                            new HttpServerProtocolCodecFactory()));
            cfg.getFilterChain().addLast("logger", new LoggingFilter());

            acceptor
                    .bind(new InetSocketAddress(port), new ServerHandler(), cfg);

            System.out.println("Server now listening on port " + port);
View Full Code Here

    public static void main(String[] args) throws Exception {
        IoAcceptor acceptor = new SocketAcceptor();

        // Prepare the configuration
        SocketAcceptorConfig cfg = new SocketAcceptorConfig();
        cfg.setReuseAddress(true);
        cfg.getFilterChain().addLast("logger", new LoggingFilter());
        cfg.getFilterChain().addLast(
                "codec",
                new ProtocolCodecFilter(new TextLineCodecFactory(Charset
                        .forName("UTF-8"))));

        // Bind
View Full Code Here

    public static void main(String[] args) throws Throwable {
        IoAcceptor acceptor = new SocketAcceptor();

        // Prepare the service configuration.
        SocketAcceptorConfig cfg = new SocketAcceptorConfig();
        cfg.setReuseAddress(true);
        if (USE_CUSTOM_CODEC) {
            cfg.getFilterChain()
                    .addLast(
                            "codec",
                            new ProtocolCodecFilter(
                                    new SumUpProtocolCodecFactory(true)));
        } else {
            cfg.getFilterChain().addLast(
                    "codec",
                    new ProtocolCodecFilter(
                            new ObjectSerializationCodecFactory()));
        }
        cfg.getFilterChain().addLast("logger", new LoggingFilter());

        acceptor.bind(new InetSocketAddress(SERVER_PORT),
                new ServerSessionHandler(), cfg);

        System.out.println("Listening on port " + SERVER_PORT);
View Full Code Here

    /** Set this to true if you want to make the server SSL */
    private static final boolean USE_SSL = false;

    public static void main(String[] args) throws Exception {
        IoAcceptor acceptor = new SocketAcceptor();
        IoAcceptorConfig config = new SocketAcceptorConfig();
        DefaultIoFilterChainBuilder chain = config.getFilterChain();

        // Add SSL filter if SSL is enabled.
        if (USE_SSL) {
            addSSLSupport(chain);
        }
View Full Code Here

             * Note: I assume that this object will always be of type
             * "SocketAcceptConfig," but the javadocs do not guarantee this so I
             * will be cautious and test first before casting it...
             */
            if (ioConfig instanceof SocketAcceptorConfig) {
                SocketAcceptorConfig socketConfig =
                        (SocketAcceptorConfig) ioConfig;
               
                socketConfig.setReuseAddress(Boolean.parseBoolean(
                        System.getProperty(REUSE_ADDRESS_PROPERTY,
                                           DEFAULT_REUSE_ADDRESS)));
            } else {
                logger.log(Level.WARNING,
                    "IoServiceConfig object from mina SocketAcceptor object" +
View Full Code Here

        // set connect timeout to mina in seconds
        long connectTimeout = timeout > 0 ? timeout : DEFAULT_CONNECT_TIMEOUT;
        connectorConfig.setConnectTimeout((int)(connectTimeout / 1000));

        // acceptor connectorConfig
        SocketAcceptorConfig acceptorConfig = new SocketAcceptorConfig();
        configureSocketCodecFactory("MinaConsumer", acceptorConfig, textline, encoding, codec);
        acceptorConfig.setReuseAddress(true);
        acceptorConfig.setDisconnectOnUnbind(true);
        if (minaLogger) {
            acceptorConfig.getFilterChain().addLast("logger", new LoggingFilter());
        }

        MinaEndpoint endpoint = new MinaEndpoint(uri, this, address, acceptor, acceptorConfig, connector, connectorConfig, lazySessionCreation, timeout, transferExchange, sync);
        if (encoding != null) {
            endpoint.setCharsetName(getEncodingParameter("MinaProducer", encoding).name());
View Full Code Here

        // set connect timeout to mina in seconds
        long connectTimeout = timeout > 0 ? timeout : DEFAULT_CONNECT_TIMEOUT;
        connectorConfig.setConnectTimeout((int)(connectTimeout / 1000));

        // acceptor connectorConfig
        SocketAcceptorConfig acceptorConfig = new SocketAcceptorConfig();
        configureCodecFactory("MinaConsumer", acceptorConfig, textline, encoding, codec);
        acceptorConfig.setReuseAddress(true);
        acceptorConfig.setDisconnectOnUnbind(true);
        if (minaLogger) {
            acceptorConfig.getFilterChain().addLast("logger", new LoggingFilter());
        }

        MinaEndpoint endpoint = new MinaEndpoint(uri, this, address, acceptor, acceptorConfig, connector, connectorConfig, lazySessionCreation, timeout, transferExchange, sync);
        if (encoding != null) {
            endpoint.setCharsetName(getEncodingParameter("MinaProducer", encoding).name());
View Full Code Here

    public void start() throws Exception {
        acceptor = new SocketAcceptor();

        // Prepare the configuration
        SocketAcceptorConfig cfg = new SocketAcceptorConfig();
        cfg.setReuseAddress(true);
        Charset charset = Charset.forName("UTF-8");
        cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(charset)));

        // Bind
        acceptor.bind(new InetSocketAddress(port), new ReverseProtocolHandler(), cfg);
    }
View Full Code Here

        // set connect timeout to mina in seconds
        connectorConfig.setConnectTimeout((int) (timeout / 1000));

        // acceptor connectorConfig
        SocketAcceptorConfig acceptorConfig = new SocketAcceptorConfig();
        // must use manual thread model according to Mina documentation
        acceptorConfig.setThreadModel(ThreadModel.MANUAL);
        configureCodecFactory("MinaConsumer", acceptorConfig, configuration);
        acceptorConfig.setReuseAddress(true);
        acceptorConfig.setDisconnectOnUnbind(true);
        acceptorConfig.getFilterChain().addLast("threadPool",
                new ExecutorFilter(getCamelContext().getExecutorServiceManager().newDefaultThreadPool(this, "MinaThreadPool")));
        if (minaLogger) {
            acceptorConfig.getFilterChain().addLast("logger", new LoggingFilter());
        }
        appendIoFiltersToChain(filters, acceptorConfig.getFilterChain());

        MinaEndpoint endpoint = new MinaEndpoint(uri, this);
        endpoint.setAddress(address);
        endpoint.setAcceptor(acceptor);
        endpoint.setAcceptorConfig(acceptorConfig);
View Full Code Here

TOP

Related Classes of org.apache.mina.transport.socket.nio.SocketAcceptorConfig

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.