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

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


            {
                ssc = ServerSocketChannel.open();
                ssc.configureBlocking( false );
               
                // Configure the server socket,
                SocketAcceptorConfig cfg;
                if( req.config instanceof SocketAcceptorConfig )
                {
                    cfg = ( SocketAcceptorConfig ) req.config;
                }
                else
                {
                    cfg = ( SocketAcceptorConfig ) getDefaultConfig();
                }
               
                ssc.socket().setReuseAddress( cfg.isReuseAddress() );
                ssc.socket().setReceiveBufferSize(
                        ( ( SocketSessionConfig ) cfg.getSessionConfig() ).getReceiveBufferSize() );
               
                // and bind.
                ssc.socket().bind( req.address, cfg.getBacklog() );
                ssc.register( selector, SelectionKey.OP_ACCEPT, req );

                synchronized( channels )
                {
                    channels.put( req.address, ssc );
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

     *
     * @see org.xmatthew.spy2servers.command.Command#execute()
     */
    public void execute(List<String> params) {
        IoAcceptor acceptor = new SocketAcceptor();
        IoAcceptorConfig config = new SocketAcceptorConfig();

        int port = DEFAULT_PORT;
        if (params != null && params.size() > 0) {
            String sPort = params.get(0);

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(workerPool));
        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

    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

    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

    if (clientPortStr != null) {
      try {
        int port = Integer.parseInt(clientPortStr);
        if (Utils.isValidPort(port)) {
          this.localPort = port;
          SocketAcceptorConfig cfg = new SocketAcceptorConfig();
          cfg.setBacklog(100);
          cfg.getFilterChain().addLast("logger", new LoggingFilter());
          cfg.getFilterChain().addLast(
              "serialization",
              new ProtocolCodecFilter(
                  new ObjectSerializationCodecFactory()));
          try {
            messageAcceptor.bind(new InetSocketAddress("localhost",
View Full Code Here

    this.endpoint.register();
  }

  public synchronized void run() throws IOException {
    if (acceptor == null && localPort != 0) {
      SocketAcceptorConfig cfg = new SocketAcceptorConfig();
      cfg.getFilterChain().addLast("logger", new LoggingFilter());
      cfg.getFilterChain().addLast(
          "serialization",
          new ProtocolCodecFilter(
              new ObjectSerializationCodecFactory()));
      acceptor = new SocketAcceptor(2, Executors.newCachedThreadPool());
      acceptor.bind(new InetSocketAddress("localhost", localPort),
View Full Code Here

            org.apache.mina.transport.socket.nio.SocketAcceptor
                    minaSocketAcceptor =
                    new org.apache.mina.transport.socket.nio.SocketAcceptor(
                    numProcessors, executor);
           
            SocketAcceptorConfig socketConfig =
                                 minaSocketAcceptor.getDefaultConfig();
               
            socketConfig.setReuseAddress(Boolean.parseBoolean(
                    System.getProperty(REUSE_ADDRESS_PROPERTY,
                                       DEFAULT_REUSE_ADDRESS)));
     
            minaAcceptor = minaSocketAcceptor;
        } else {
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

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.