Package org.cometd.bayeux.server

Examples of org.cometd.bayeux.server.ServerTransport


    {
        super.doStop();

        for (String allowedTransportName : getAllowedTransports())
        {
            ServerTransport transport = getTransport(allowedTransportName);
            if (transport instanceof AbstractServerTransport)
                ((AbstractServerTransport)transport).destroy();
        }

        _listeners.clear();
View Full Code Here


        {
            String option = (String)getOption(TRANSPORTS_OPTION);
            if (option == null)
            {
                // Order is important, see #findHttpTransport()
                ServerTransport transport = newWebSocketTransport();
                if (transport != null)
                    addTransport(transport);
                addTransport(newJSONTransport());
                addTransport(new JSONPTransport(this));
            }
            else
            {
                for (String className : option.split(","))
                {
                    ServerTransport transport = newServerTransport(className.trim());
                    if (transport != null)
                        addTransport(transport);
                }

                if (_transports.isEmpty())
                    throw new IllegalArgumentException("Option '" + TRANSPORTS_OPTION +
                            "' does not contain a valid list of server transport class names");
            }
        }

        if (_allowedTransports.isEmpty())
        {
            String option = (String)getOption(ALLOWED_TRANSPORTS_OPTION);
            if (option == null)
            {
                _allowedTransports.addAll(_transports.keySet());
            }
            else
            {
                for (String transportName : option.split(","))
                {
                    if (_transports.containsKey(transportName))
                        _allowedTransports.add(transportName);
                }

                if (_allowedTransports.isEmpty())
                    throw new IllegalArgumentException("Option '" + ALLOWED_TRANSPORTS_OPTION +
                            "' does not contain at least one configured server transport name");
            }
        }

        List<String> activeTransports = new ArrayList<>();
        for (String transportName : _allowedTransports)
        {
            ServerTransport serverTransport = getTransport(transportName);
            if (serverTransport instanceof AbstractServerTransport)
            {
                ((AbstractServerTransport)serverTransport).init();
                activeTransports.add(serverTransport.getName());
            }
        }
        if (_logger.isDebugEnabled())
            _logger.debug("Active transports: {}", activeTransports);
    }
View Full Code Here

        try
        {
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            loader.loadClass("javax.websocket.server.ServerContainer");
            String transportClass = "org.cometd.websocket.server.WebSocketTransport";
            ServerTransport transport = newServerTransport(transportClass);
            if (transport == null)
            {
                _logger.info("JSR 356 WebSocket classes available, but " + transportClass +
                        " unavailable: JSR 356 WebSocket transport disabled");
            }
View Full Code Here

        return _currentTransport.get();
    }

    public BayeuxContext getContext()
    {
        ServerTransport transport = _currentTransport.get();
        return transport == null ? null : transport.getContext();
    }
View Full Code Here

        return _transports.get(transport);
    }

    public ServerTransport addTransport(ServerTransport transport)
    {
        ServerTransport result = _transports.put(transport.getName(), transport);
        if (_logger.isDebugEnabled())
            _logger.debug("Added transport {} from {}", transport.getName(), transport.getClass());
        return result;
    }
View Full Code Here

    {
        // Avoid allocation of the Iterator
        for (int i = 0; i < _allowedTransports.size(); ++i)
        {
            String transportName = _allowedTransports.get(i);
            ServerTransport serverTransport = getTransport(transportName);
            if (serverTransport instanceof AbstractHttpTransport)
            {
                AbstractHttpTransport transport = (AbstractHttpTransport)serverTransport;
                if (transport.accept(request))
                    return transport;
View Full Code Here

        id.insert(index, Long.toString(_idCount.incrementAndGet(), 36));

        _id = id.toString();

        ServerTransport transport = _bayeux.getCurrentTransport();
        if (transport != null)
            _intervalTimestamp = System.currentTimeMillis() + transport.getMaxInterval();

        _broadcastToPublisher = _bayeux.isBroadcastToPublisher();
    }
View Full Code Here

        Assert.assertNotNull(bayeuxServer);
        Assert.assertTrue(bayeuxServer.isStarted());

        Assert.assertSame(bayeuxServer, bayeux);

        ServerTransport transport = bayeuxServer.getTransport("websocket");
        Assert.assertNotNull(transport);

        final BayeuxClient client = newBayeuxClient();
        client.handshake();
        Assert.assertTrue(client.waitFor(5000, BayeuxClient.State.CONNECTED));
View Full Code Here

        bayeuxServer.setOption("sweepIntervalMs", -1);
        long maxInterval = 1000;
        bayeuxServer.setOption("maxInterval", maxInterval);
        bayeuxServer.setOption("maxServerInterval", maxInterval);
        bayeuxServer.start();
        ServerTransport serverTransport = bayeuxServer.getTransport("long-polling");
        bayeuxServer.setCurrentTransport((AbstractServerTransport)serverTransport);

        // LocalSessions do not perform heartbeat so we should not sweep them until disconnected
        LocalSession localSession = bayeuxServer.newLocalSession("test_sweep");
        localSession.handshake();
View Full Code Here

TOP

Related Classes of org.cometd.bayeux.server.ServerTransport

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.