Package org.cometd.bayeux

Examples of org.cometd.bayeux.ChannelId


    public ChannelId newChannelId(String id)
    {
        ServerChannelImpl channel = _channels.get(id);
        if (channel != null)
            return channel.getChannelId();
        return new ChannelId(id);
    }
View Full Code Here


    {
        boolean initialized = false;
        ServerChannelImpl channel = _channels.get(channelName);
        if (channel == null)
        {
            ChannelId channelId = new ChannelId(channelName);
            ServerChannelImpl candidate = new ServerChannelImpl(this, channelId);
            channel = _channels.putIfAbsent(channelName, candidate);
            if (channel == null)
            {
                // My candidate channel was added to the map, so I'd better initialize it
View Full Code Here

        if (_policy != null && !_policy.canCreate(BayeuxServerImpl.this, session, channel, message))
        {
            _logger.warn("{} denied Create@{} by {}", session, message.getChannel(), _policy);
            return Authorizer.Result.deny("denied_by_security_policy");
        }
        return isOperationAuthorized(Authorizer.Operation.CREATE, session, message, new ChannelId(channel));
    }
View Full Code Here

        CountDownLatch latch = new CountDownLatch(1);
        Object service = new ListenerWithParametersService(latch, value);
        boolean processed = processor.process(service);
        assertTrue(processed);

        String parentChannel = new ChannelId(ListenerWithParametersService.CHANNEL).getParent();

        // Fake a publish
        LocalSession remote = bayeuxServer.newLocalSession("remote");
        remote.handshake();
        ServerMessage.Mutable message = bayeuxServer.newMessage();
View Full Code Here

        CountDownLatch latch = new CountDownLatch(1);
        Object service = new ListenerWithParametersNotBindingService(latch);
        boolean processed = processor.process(service);
        assertTrue(processed);

        String parentChannel = new ChannelId(ListenerWithParametersNotBindingService.CHANNEL).getParent();
        String grandParentChannel = new ChannelId(parentChannel).getParent();

        // Fake a publish
        LocalSession remote = bayeuxServer.newLocalSession("remote");
        remote.handshake();
        ServerMessage.Mutable message = bayeuxServer.newMessage();
View Full Code Here

        CountDownLatch latch = new CountDownLatch(1);
        Object service = new SubscriberWithParametersService(latch, value);
        boolean processed = processor.process(service);
        assertTrue(processed);

        String parentChannel = new ChannelId(SubscriberWithParametersService.CHANNEL).getParent();

        // Fake a publish
        LocalSession remote = bayeuxServer.newLocalSession("remote");
        remote.handshake();
        ServerMessage.Mutable message = bayeuxServer.newMessage();
View Full Code Here

                        if (ChannelId.isMeta(channel))
                            throw new IllegalArgumentException("Annotation @" + Subscription.class.getSimpleName() +
                                    " on method '" + method.getName() + "' on class '" +
                                    method.getDeclaringClass().getName() + "' must specify a non meta channel");

                        ChannelId channelId = new ChannelId(channel);
                        if (channelId.isTemplate())
                            channel = channelId.getWilds().get(0);

                        SubscriptionCallback subscriptionCallback = new SubscriptionCallback(clientSession, bean, method, paramNames, channelId, channel);
                        // We should delay the subscription if the client session did not complete the handshake
                        if (clientSession.isHandshook())
                            clientSession.getChannel(channel).subscribe(subscriptionCallback);
View Full Code Here

public class ChannelIdTest
{
    @Test
    public void testDepth()
    {
        Assert.assertEquals(1, new ChannelId("/foo").depth());
        Assert.assertEquals(1, new ChannelId("/foo/").depth());
        Assert.assertEquals(2, new ChannelId("/foo/bar").depth());
        Assert.assertEquals(2, new ChannelId("/foo/bar/").depth());
        Assert.assertEquals(3, new ChannelId("/foo/bar/*").depth());
        Assert.assertEquals(3, new ChannelId("/foo/bar/**").depth());
    }
View Full Code Here

    }

    @Test
    public void testSegments()
    {
        ChannelId channel = new ChannelId("/foo/bar");

        Assert.assertEquals("foo", channel.getSegment(0));
        Assert.assertEquals("bar", channel.getSegment(1));

        Assert.assertNull(channel.getSegment(2));
        Assert.assertNull(channel.getSegment(3));
    }
View Full Code Here

    }

    @Test
    public void testIsXxx()
    {
        ChannelId id;

        id = new ChannelId("/foo/bar");
        Assert.assertFalse(id.isDeepWild());
        Assert.assertFalse(id.isMeta());
        Assert.assertFalse(id.isService());
        Assert.assertFalse(id.isWild());

        id = new ChannelId("/foo/*");
        Assert.assertTrue(id.isShallowWild());
        Assert.assertFalse(id.isDeepWild());
        Assert.assertFalse(id.isMeta());
        Assert.assertFalse(id.isService());
        Assert.assertTrue(id.isWild());

        id = new ChannelId("/foo/**");
        Assert.assertTrue(id.isDeepWild());
        Assert.assertFalse(id.isMeta());
        Assert.assertFalse(id.isService());
        Assert.assertTrue(id.isWild());

        id = new ChannelId("/meta/bar");
        Assert.assertFalse(id.isDeepWild());
        Assert.assertTrue(id.isMeta());
        Assert.assertFalse(id.isService());
        Assert.assertFalse(id.isWild());

        id = new ChannelId("/service/bar");
        Assert.assertFalse(id.isDeepWild());
        Assert.assertFalse(id.isMeta());
        Assert.assertTrue(id.isService());
        Assert.assertFalse(id.isWild());

        id = new ChannelId("/service/**");
        Assert.assertTrue(id.isDeepWild());
        Assert.assertFalse(id.isMeta());
        Assert.assertTrue(id.isService());
        Assert.assertTrue(id.isWild());

        id = new ChannelId("/service/{var}");
        Assert.assertFalse(id.isMeta());
        Assert.assertTrue(id.isService());
        Assert.assertFalse(id.isWild());
        Assert.assertTrue(id.isTemplate());
    }
View Full Code Here

TOP

Related Classes of org.cometd.bayeux.ChannelId

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.