Package org.cometd.bayeux.server

Examples of org.cometd.bayeux.server.BayeuxServer$Extension


        data.put(Info.NAME_FIELD, getName());
        data.put(Info.OBJECT_FIELD, serialize(newObject));

        if (logger.isDebugEnabled())
            logger.debug("Sharing {}", data);
        BayeuxServer bayeuxServer = oort.getBayeuxServer();
        bayeuxServer.getChannel(getChannelName()).publish(getLocalSession(), data);

        return data.getResult();
    }
View Full Code Here


        assertNotNull(service);
        Seti seti = service.seti;
        assertNotNull(seti);
        Oort oort = seti.getOort();
        assertNotNull(oort);
        BayeuxServer bayeux = oort.getBayeuxServer();
        assertNotNull(bayeux);

        SecurityPolicy policy = bayeux.getSecurityPolicy();
        assertNotNull(policy);
        assertTrue(policy instanceof OortSecurityPolicy);

        server.stop();
    }
View Full Code Here

    {
        super.init(config);

        ServletContext context = config.getServletContext();

        BayeuxServer bayeux = (BayeuxServer)context.getAttribute(BayeuxServer.ATTRIBUTE);
        Oort oort = (Oort)context.getAttribute(Oort.OORT_ATTRIBUTE);
        Seti seti = (Seti)context.getAttribute(Seti.SETI_ATTRIBUTE);

        _processor = new ServerAnnotationProcessor(bayeux, oort, seti);
        _service = new OortChatService();
        _processor.process(_service);

        bayeux.addExtension(new TimesyncExtension());
    }
View Full Code Here

    @Test
    public void testObserveNonStartedOortAndDetectStart() throws Exception
    {
        Server server1 = startServer(0);
        String url = (String)server1.getAttribute(OortConfigServlet.OORT_URL_PARAM);
        final BayeuxServer bayeuxServer = (BayeuxServer)server1.getAttribute(BayeuxServer.ATTRIBUTE);
        Oort oort1 = new Oort(bayeuxServer, url);
        oort1.start();

        Server server2 = startServer(0);
        String url2 = (String)server2.getAttribute(OortConfigServlet.OORT_URL_PARAM);
View Full Code Here

        Oort oortA = startOort(serverA);
        stopOort(oortA);
        oortA.setAckExtensionEnabled(true);
        oortA.start();

        BayeuxServer bayeuxServerA = oortA.getBayeuxServer();
        int ackExtensions = 0;
        for (BayeuxServer.Extension extension : bayeuxServerA.getExtensions())
            if (extension instanceof AcknowledgedMessagesExtension)
                ++ackExtensions;
        Assert.assertEquals(1, ackExtensions);

        Server serverB = startServer(0);
        BayeuxServer bayeuxServerB = (BayeuxServer)serverB.getAttribute(BayeuxServer.ATTRIBUTE);
        bayeuxServerB.addExtension(new AcknowledgedMessagesExtension());
        Oort oortB = startOort(serverB);
        stopOort(oortB);
        oortB.setAckExtensionEnabled(true);
        oortB.start();

        ackExtensions = 0;
        for (BayeuxServer.Extension extension : bayeuxServerB.getExtensions())
            if (extension instanceof AcknowledgedMessagesExtension)
                ++ackExtensions;
        Assert.assertEquals(1, ackExtensions);

        CountDownLatch latch1 = new CountDownLatch(2);
View Full Code Here

    @Test
    public void testPublishDuringCometJoined() throws Exception
    {
        Server serverA = startServer(0);
        final Oort oortA = startOort(serverA);
        final BayeuxServer bayeuxServerA = oortA.getBayeuxServer();

        final LocalSession serviceA = bayeuxServerA.newLocalSession("test");
        serviceA.handshake();
        final String channelName = "/test";
        final String data = "data";
        final CountDownLatch joinedLatch = new CountDownLatch(1);
        oortA.addCometListener(new Oort.CometListener.Adapter()
        {
            public void cometJoined(Event event)
            {
                bayeuxServerA.createChannelIfAbsent(channelName).getReference().publish(serviceA, data);
                joinedLatch.countDown();
            }
        });
        oortA.observeChannel(channelName);

        Server serverB = startServer(0);
        Oort oortB = startOort(serverB);
        oortB.observeChannel(channelName);

        BayeuxServer bayeuxServerB = oortB.getBayeuxServer();
        final CountDownLatch latch = new CountDownLatch(1);
        bayeuxServerB.createChannelIfAbsent(channelName).getReference().addListener(new ServerChannel.MessageListener()
        {
            public boolean onMessage(ServerSession from, ServerChannel channel, ServerMessage.Mutable message)
            {
                if (data.equals(message.getData()))
                    latch.countDown();
View Full Code Here

        ServletHolder demo = context.addServlet(CometDDemoServlet.class, "/demo");
        demo.setInitOrder(3);

        server.start();

        BayeuxServer bayeux = cometdServlet.getBayeux();
        bayeux.setSecurityPolicy(new DefaultSecurityPolicy());

        // Demo lazy messages
        if (Boolean.getBoolean("LAZY"))
        {
            bayeux.addExtension(new BayeuxServer.Extension.Adapter()
            {
                @Override
                public boolean rcv(ServerSession from, Mutable message)
                {
                    if (message.getChannel().startsWith("/chat/") && !message.isPublishReply() && message.getData().toString().contains("lazy"))
                        message.setLazy(true);
                    return true;
                }
            });
        }

        // Demo lazy messages
        if (Boolean.getBoolean("LAZYCHAT"))
        {
            String channelName = "/chat/demo";
            final ServerChannel chat_demo = bayeux.createChannelIfAbsent(channelName).getReference();
            chat_demo.setLazy(true);
            chat_demo.setPersistent(true);
        }
    }
View Full Code Here

        data.put(Info.TYPE_FIELD, TYPE_FIELD_ELEMENT_VALUE);
        data.put(Info.ACTION_FIELD, ACTION_FIELD_ADD_VALUE);

        if (logger.isDebugEnabled())
            logger.debug("Sharing list add {}", data);
        BayeuxServer bayeuxServer = getOort().getBayeuxServer();
        bayeuxServer.getChannel(getChannelName()).publish(getLocalSession(), data);

        return data.getResult();
    }
View Full Code Here

        data.put(Info.TYPE_FIELD, TYPE_FIELD_ELEMENT_VALUE);
        data.put(Info.ACTION_FIELD, ACTION_FIELD_REMOVE_VALUE);

        if (logger.isDebugEnabled())
            logger.debug("Sharing list remove {}", data);
        BayeuxServer bayeuxServer = getOort().getBayeuxServer();
        bayeuxServer.getChannel(getChannelName()).publish(getLocalSession(), data);

        return data.getResult();
    }
View Full Code Here

        data.put(Info.TYPE_FIELD, TYPE_FIELD_ENTRY_VALUE);
        data.put(Info.ACTION_FIELD, ACTION_FIELD_PUT_VALUE);

        if (logger.isDebugEnabled())
            logger.debug("Sharing map put {}", data);
        BayeuxServer bayeuxServer = getOort().getBayeuxServer();
        bayeuxServer.getChannel(getChannelName()).publish(getLocalSession(), data);

        return data.getResult();
    }
View Full Code Here

TOP

Related Classes of org.cometd.bayeux.server.BayeuxServer$Extension

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.