Examples of ChannelID


Examples of org.cometd.bayeux.ChannelId

    }

    @Test
    public void testWilds()
    {
        ChannelId id = new ChannelId("/foo/bar/*");
        List<String> wilds = id.getWilds();
        Assert.assertEquals(0, wilds.size());

        id = new ChannelId("/foo");
        wilds = id.getWilds();
        Assert.assertEquals(2, wilds.size());
        Assert.assertEquals("/*", wilds.get(0));
        Assert.assertEquals("/**", wilds.get(1));

        id = new ChannelId("/foo/bar");
        wilds = id.getWilds();
        Assert.assertEquals(3, wilds.size());
        Assert.assertEquals("/foo/*", wilds.get(0));
        Assert.assertEquals("/foo/**", wilds.get(1));
        Assert.assertEquals("/**", wilds.get(2));

        id = new ChannelId("/foo/bar/bob");
        wilds = id.getWilds();
        Assert.assertEquals(4, wilds.size());
        Assert.assertEquals("/foo/bar/*", wilds.get(0));
        Assert.assertEquals("/foo/bar/**", wilds.get(1));
        Assert.assertEquals("/foo/**", wilds.get(2));
        Assert.assertEquals("/**", wilds.get(3));

        id = new ChannelId("/foo/{bar}");
        wilds = id.getWilds();
        Assert.assertEquals(3, wilds.size());
        Assert.assertEquals("/foo/*", wilds.get(0));
        Assert.assertEquals("/foo/**", wilds.get(1));
        Assert.assertEquals("/**", wilds.get(2));

        id = new ChannelId("/foo/{bar}/baz");
        wilds = id.getWilds();
        Assert.assertEquals(2, wilds.size());
        Assert.assertEquals("/foo/**", wilds.get(0));
        Assert.assertEquals("/**", wilds.get(1));
    }
View Full Code Here

Examples of org.cometd.bayeux.ChannelId

    }

    @Test
    public void testRegularPart() throws Exception
    {
        Assert.assertEquals("/foo", new ChannelId("/foo/*").getRegularPart());
        Assert.assertEquals("/foo/bar", new ChannelId("/foo/bar/**").getRegularPart());
        Assert.assertEquals("/foo", new ChannelId("/foo/{p}").getRegularPart());
        Assert.assertEquals("/foo/bar", new ChannelId("/foo/bar/{p}").getRegularPart());
        Assert.assertEquals("/foo", new ChannelId("/foo/{p1}/{p2}").getRegularPart());
        Assert.assertNull(new ChannelId("/*").getRegularPart());
        Assert.assertNull(new ChannelId("/**").getRegularPart());
        Assert.assertNull(new ChannelId("/{p}").getRegularPart());
        Assert.assertNull(new ChannelId("/{p1}/{p2}").getRegularPart());
    }
View Full Code Here

Examples of org.cometd.bayeux.ChannelId

    private void assertInvalid(String channel)
    {
        try
        {
            // Call depth() to ensure the ChannelId is resolved.
            new ChannelId(channel).depth();
            Assert.fail(channel);
        }
        catch (IllegalArgumentException x)
        {
            // Expected
View Full Code Here

Examples of org.cometd.bayeux.ChannelId

        return (String)get(CHANNEL_FIELD);
    }

    public ChannelId getChannelId()
    {
        return new ChannelId(getChannel());
    }
View Full Code Here

Examples of org.cometd.bayeux.ChannelId

                    checkSignaturesMatch(method, ListenerCallback.signature, paramNames);

                    String[] channels = listener.value();
                    for (String channel : channels)
                    {
                        ChannelId channelId = new ChannelId(channel);
                        if (channelId.isTemplate())
                        {
                            List<String> parameters = channelId.getParameters();
                            if (parameters.size() != paramNames.size())
                                throw new IllegalArgumentException("Wrong number of template parameters in annotation @" +
                                        Listener.class.getSimpleName() + " on method: " + method.getName() + "(...).");
                            if (!parameters.equals(paramNames))
                                throw new IllegalArgumentException("Wrong parameter names in annotation @" +
                                        Listener.class.getSimpleName() + " on method: " + method.getName() + "(...).");
                            channel = channelId.getRegularPart() + "/" + (parameters.size() < 2 ? ChannelId.WILD : ChannelId.DEEPWILD);
                        }

                        MarkedReference<ServerChannel> initializedChannel = bayeuxServer.createChannelIfAbsent(channel);
                        ListenerCallback listenerCallback = new ListenerCallback(localSession, bean, method, paramNames, channelId, channel, listener.receiveOwnPublishes());
                        initializedChannel.getReference().addListener(listenerCallback);
View Full Code Here

Examples of org.cometd.bayeux.ChannelId

                        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())
                        {
                            List<String> parameters = channelId.getParameters();
                            if (parameters.size() != paramNames.size())
                                throw new IllegalArgumentException("Wrong number of template parameters in annotation @" +
                                        Subscription.class.getSimpleName() + " on method: " + method.getName() + "(...).");
                            if (!parameters.equals(paramNames))
                                throw new IllegalArgumentException("Wrong parameter names in annotation @" +
                                        Subscription.class.getSimpleName() + " on method: " + method.getName() + "(...).");
                            channel = channelId.getRegularPart() + "/" + (parameters.size() < 2 ? ChannelId.WILD : ChannelId.DEEPWILD);
                        }

                        SubscriptionCallback subscriptionCallback = new SubscriptionCallback(localSession, bean, method, paramNames, channelId, channel);
                        localSession.getChannel(channel).subscribe(subscriptionCallback);
View Full Code Here

Examples of org.cometd.bayeux.ChannelId

                    {
                        if (!target.startsWith("/"))
                            target = "/" + target;
                        String channel = Channel.SERVICE + target;

                        ChannelId channelId = new ChannelId(channel);
                        if (channelId.isWild())
                            throw new IllegalArgumentException("Annotation @" + RemoteCall.class.getSimpleName() +
                                    " on method: " + method.getName() + "(...) cannot specify wild channels.");

                        if (channelId.isTemplate())
                        {
                            List<String> parameters = channelId.getParameters();
                            if (parameters.size() != paramNames.size())
                                throw new IllegalArgumentException("Wrong number of template parameters in annotation @" +
                                        RemoteCall.class.getSimpleName() + " on method: " + method.getName() + "(...).");
                            if (!parameters.equals(paramNames))
                                throw new IllegalArgumentException("Wrong parameter names in annotation @" +
                                        RemoteCall.class.getSimpleName() + " on method: " + method.getName() + "(...).");
                            channel = channelId.getRegularPart() + "/" + (parameters.size() < 2 ? ChannelId.WILD : ChannelId.DEEPWILD);
                        }

                        MarkedReference<ServerChannel> initializedChannel = bayeuxServer.createChannelIfAbsent(channel);
                        RemoteCallCallback remoteCallCallback = new RemoteCallCallback(bayeuxServer, localSession, bean, method, paramNames, channelId, channel);
                        initializedChannel.getReference().addListener(remoteCallCallback);
View Full Code Here

Examples of org.cometd.bayeux.ChannelId

    protected ChannelId newChannelId(String channelId)
    {
        // Save some parsing by checking if there is already one
        AbstractSessionChannel channel = getChannels().get(channelId);
        return channel == null ? new ChannelId(channelId) : channel.getChannelId();
    }
View Full Code Here

Examples of org.cometd.bayeux.ChannelId

        AbstractSessionChannel channel = channelRef.getReference();
        channel.notifyMessageListeners(message);
        if (channelRef.isMarked())
            channel.release();

        ChannelId channelId = channel.getChannelId();
        for (String wildChannelName : channelId.getWilds())
        {
            MarkedReference<AbstractSessionChannel> wildChannelRef = getReleasableChannel(wildChannelName);
            AbstractSessionChannel wildChannel = wildChannelRef.getReference();
            wildChannel.notifyMessageListeners(message);
            if (wildChannelRef.isMarked())
View Full Code Here

Examples of org.cometd.bayeux.ChannelId

        bayeuxClient.handshake();
        assertTrue(bayeuxClient.waitFor(1000, BayeuxClient.State.CONNECTED));

        String channel = "/a/" + value1 + "/" + value2 + "/d";
        assertFalse(new ChannelId(SubscriberWithParametersService.CHANNEL).bind(new ChannelId(channel)).isEmpty());

        bayeuxClient.getChannel(channel).publish("data");
        assertTrue(latch.await(5, TimeUnit.SECONDS));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.