Examples of Channel


Examples of org.apache.cometd.bayeux.Channel

                Stock[] stocks = new Stock[] {
                        new Stock("GOOG", 435.43),
                        new Stock("YHOO", 27.88),
                        new Stock("SPRG", 1015.55), };
                for (Stock s : stocks) {
                    Channel ch = b.getChannel("/stock/"+s.getSymbol(), true);
                    ch.subscribe(c);
                   
                }
                Random r = new Random(System.currentTimeMillis());
                while (run) {
                    for (int j = 0; j < 1; j++) {
                        int i = r.nextInt() % 3;
                        if (i < 0)
                            i = i * (-1);
                        Stock stock = stocks[i];
                        double change = r.nextDouble();
                        boolean plus = r.nextBoolean();
                        if (plus) {
                            stock.setValue(stock.getValue() + change);
                        } else {
                            stock.setValue(stock.getValue() - change);
                        }
                        Channel ch = b.getChannel("/stock/"+stock.getSymbol(), true);
                        Message m = b.newMessage(c);
                        m.put("stock", stock.toString());
                        m.put("symbol", stock.getSymbol());
                        m.put("price", stock.getValueAsString());
                        m.put("change", stock.getLastChangeAsString());
                        ch.publish(m);
                        System.out.println("Stock: "+stock.getSymbol()+" Price: "+stock.getValueAsString()+" Change: "+stock.getLastChangeAsString());
                    }
                    Thread.sleep(850);
                }
            } catch (InterruptedException ix) {
View Full Code Here

Examples of org.apache.commons.betwixt.examples.rss.Channel

        StringWriter out = new StringWriter();
        out.write("<?xml version='1.0'?>");
        BeanWriter writer = new BeanWriter(out);
        writer.getBindingConfiguration().setMapIDs(false);
       
        Channel channel = new Channel();
        channel.setTitle("Betwixt News");
        channel.setLink("http://jakarta.apache.org/commons/betwixt");
        channel.setDescription("Example feed themed on Betwixt news.");
        channel.setRating("(PICS-1.1 'http://www.rsac.org/ratingsv01.html'" +
            " 2 gen true comment 'RSACi North America Server'" +
            " for 'http://www.rsac.org' on '1996.04.16T08:15-0500'" +
            " r (n 0 s 0 v 0 l 0))");
        channel.setLanguage("en-UK");
       
        Image image = new Image();
        image.setTitle("Apache Feather");
        image.setURL("http://www.apache.org/images/asf_logo_wide.gif");
        image.setLink("http://www.apache.org");
        image.setWidth(100);
        image.setHeight(30);
        image.setDescription("Example image");
        channel.setImage(image);

        Item itemOne = new Item();
        itemOne.setTitle("Betwixt now generates w3c schema!");
        itemOne.setLink("http://jakarta.apache.org/commons/betwixt");
        itemOne.setDescription("Example description");
        channel.addItem(itemOne);

        Item itemTwo = new Item();
        itemTwo.setTitle("Another News Item");
        itemTwo.setLink("http://jakarta.apache.org/commons/betwixt");
        itemTwo.setDescription("Blah Blah Blah");
        channel.addItem(itemTwo);       

        TextInput textInput = new TextInput();
        textInput.setTitle("Send");
        textInput.setDescription("Comments about Betwixt news");
        textInput.setName("Response text");
        textInput.setLink("http://jakarta.apache.org/commons/betwixt");
        channel.setTextInput(textInput);

        writer.write(channel);

        String xml = out.getBuffer().toString();
      
View Full Code Here

Examples of org.apache.commons.digester.rss.Channel

      }
    }
    //fetch from http directly
   
    try {
      Channel channel = fetchChannelViaHTTP(url);
      if(channels!=null && channel!=null){
        channels.put(new Element(url, channel));
      }
      return channel;
    } catch (Exception e) {
View Full Code Here

Examples of org.apache.flink.compiler.plan.Channel

       
        /* Test on the union output connections
         * It must be under the GroupOperator and the strategy should be forward
         */
        if (visitable instanceof SingleInputPlanNode && visitable.getPactContract() instanceof GroupReduceOperatorBase){
          final Channel inConn = ((SingleInputPlanNode) visitable).getInput();
          Assert.assertTrue("Union should just forward the Partitioning",
              inConn.getShipStrategy() == ShipStrategyType.FORWARD );
          Assert.assertTrue("Union Node should be under Group operator",
              inConn.getSource() instanceof NAryUnionPlanNode );
        }
       
        /* Test on the union input connections
         * Must be NUM_INPUTS input connections, all FlatMapOperators with a own partitioning strategy(propably hash)
         */
        if (visitable instanceof NAryUnionPlanNode) {
          int numberInputs = 0;
          for (Iterator<Channel> inputs = visitable.getInputs().iterator(); inputs.hasNext(); numberInputs++) {
            final Channel inConn = inputs.next();
            PlanNode inNode = inConn.getSource();
            Assert.assertTrue("Input of Union should be FlatMapOperators",
                inNode.getPactContract() instanceof FlatMapOperatorBase);
            Assert.assertTrue("Shipment strategy under union should partition the data",
                inConn.getShipStrategy() == ShipStrategyType.PARTITION_HASH);
          }
         
          Assert.assertTrue("NAryUnion should have " + NUM_INPUTS + " inputs", numberInputs == NUM_INPUTS);
          return false;
        }
View Full Code Here

Examples of org.apache.flink.runtime.io.network.channels.Channel

      return;
    }

    // destroy and remove OUTPUT channels from registered channels and cache
    for (ChannelID id : environment.getOutputChannelIDs()) {
      Channel channel = this.channels.remove(id);
      if (channel != null) {
        channel.destroy();
        this.receiverCache.remove(channel);
      }
    }

    // destroy and remove INPUT channels from registered channels and cache
    for (ChannelID id : environment.getInputChannelIDs()) {
      Channel channel = this.channels.remove(id);
      if (channel != null) {
        channel.destroy();
        this.receiverCache.remove(channel);
      }
    }

    // clear and remove INPUT side buffer pools
View Full Code Here

Examples of org.apache.flume.Channel

  }

  @Override
  public Status process() throws EventDeliveryException {
    Status status = Status.READY;
    Channel channel = getChannel();
    Transaction txn = channel.getTransaction();
    List<Row> actions = new LinkedList<Row>();
    List<Increment> incs = new LinkedList<Increment>();
    txn.begin();
    for(long i = 0; i < batchSize; i++) {
      Event event = channel.take();
      if(event == null){
        status = Status.BACKOFF;
        counterGroup.incrementAndGet("channel.underflow");
        break;
      } else {
View Full Code Here

Examples of org.apache.qpid.transport.Channel

    }
*/

    public void close() throws QpidException
    {
        Channel ch = _conn.getChannel(0);
        ch.connectionClose(ConnectionCloseCode.NORMAL, "client is closing");
        _lock.lock();
        try
        {
            try
            {
View Full Code Here

Examples of org.apache.servicemix.nmr.api.Channel

         *
         * @param message the message to be sent.
         */
        public void prepare(Message message) throws IOException {
            // setup the message to be send back
            Channel dc = channel;
            message.put(Exchange.class, inMessage.get(Exchange.class));
            message.setContent(OutputStream.class, new NMRDestinationOutputStream(inMessage, dc));
        }       
View Full Code Here

Examples of org.apache.sshd.common.Channel

            buf.putString("");
            writePacket(buf);
            return;
        }

        final Channel channel = NamedFactory.Utils.create(getFactoryManager().getChannelFactories(), type);
        if (channel == null) {
            Buffer buf = createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN_FAILURE, 0);
            buf.putInt(id);
            buf.putInt(SshConstants.SSH_OPEN_UNKNOWN_CHANNEL_TYPE);
            buf.putString("Unsupported channel type: " + type);
            buf.putString("");
            writePacket(buf);
            return;
        }

        final int channelId = getNextChannelId();
        channels.put(channelId, channel);
        channel.init(this, channelId);
        channel.open(id, rwsize, rmpsize, buffer).addListener(new SshFutureListener<OpenFuture>() {
            public void operationComplete(OpenFuture future) {
                try {
                    if (future.isOpened()) {
                        Buffer buf = createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN_CONFIRMATION, 0);
                        buf.putInt(id);
                        buf.putInt(channelId);
                        buf.putInt(channel.getLocalWindow().getSize());
                        buf.putInt(channel.getLocalWindow().getPacketSize());
                        writePacket(buf);
                    } else if (future.getException() != null) {
                        Buffer buf = createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN_FAILURE, 0);
                        buf.putInt(id);
                        if (future.getException() instanceof OpenChannelException) {
View Full Code Here

Examples of org.b3log.solo.model.feed.rss.Channel

    public void blogArticlesRSS(final HTTPRequestContext context) {
        final HttpServletResponse response = context.getResponse();
        final RssRenderer renderer = new RssRenderer();
        context.setRenderer(renderer);

        final Channel channel = new Channel();
        try {
            final JSONObject preference = preferenceQueryService.getPreference();
            if (null == preference) {
                response.sendError(HttpServletResponse.SC_NOT_FOUND);
                return;
            }

            final String blogTitle = preference.getString(Preference.BLOG_TITLE);
            final String blogSubtitle = preference.getString(Preference.BLOG_SUBTITLE);
            final String blogHost = preference.getString(Preference.BLOG_HOST);

            channel.setTitle(StringEscapeUtils.escapeXml(blogTitle));
            channel.setLastBuildDate(TimeZones.getTime(preference.getString(Preference.TIME_ZONE_ID)));
            channel.setLink("http://" + blogHost);
            channel.setAtomLink("http://" + blogHost + "/blog-articles-rss.do");
            channel.setGenerator("B3log Solo, ver " + SoloServletListener.VERSION);
            final String localeString = preference.getString(Preference.LOCALE_STRING);
            final String country = Locales.getCountry(localeString).toLowerCase();
            final String language = Locales.getLanguage(localeString).toLowerCase();
            channel.setLanguage(language + '-' + country);
            channel.setDescription(blogSubtitle);

            final Query query = new Query().setCurrentPageNum(1).
                    setPageSize(ENTRY_OUTPUT_CNT).
                    addFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true).
                    addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING).
                    setPageCount(1);

            final JSONObject articleResult = articleRepository.get(query);
            final JSONArray articles = articleResult.getJSONArray(Keys.RESULTS);

            final boolean hasMultipleUsers = Users.getInstance().hasMultipleUsers();
            String authorName = "";

            if (!hasMultipleUsers && 0 != articles.length()) {
                authorName = articleUtils.getAuthor(articles.getJSONObject(0)).getString(User.USER_NAME);
            }

            final boolean isFullContent = "fullContent".equals(preference.getString(Preference.FEED_OUTPUT_MODE));

            for (int i = 0; i < articles.length(); i++) {
                final JSONObject article = articles.getJSONObject(i);
                final Item item = new Item();
                channel.addItem(item);
                final String title = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE));
                item.setTitle(title);
                final String description = isFullContent ? StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_CONTENT))
                                           : StringEscapeUtils.escapeXml(article.optString(Article.ARTICLE_ABSTRACT));
                item.setDescription(description);
                final Date pubDate = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
                item.setPubDate(pubDate);
                final String link = "http://" + blogHost + article.getString(Article.ARTICLE_PERMALINK);
                item.setLink(link);
                item.setGUID(link);

                final String authorEmail = article.getString(Article.ARTICLE_AUTHOR_EMAIL);
                if (hasMultipleUsers) {
                    authorName = StringEscapeUtils.escapeXml(articleUtils.getAuthor(article).getString(User.USER_NAME));
                }

                item.setAuthor(authorEmail + "(" + authorName + ")");

                final String tagsString = article.getString(Article.ARTICLE_TAGS_REF);
                final String[] tagStrings = tagsString.split(",");
                for (int j = 0; j < tagStrings.length; j++) {
                    final org.b3log.solo.model.feed.rss.Category catetory = new org.b3log.solo.model.feed.rss.Category();
                    item.addCatetory(catetory);
                    final String tag = tagStrings[j];
                    catetory.setTerm(tag);
                }
            }

            renderer.setContent(channel.toString());
        } catch (final Exception e) {
            LOGGER.log(Level.SEVERE, "Get blog article rss error", e);

            try {
                context.getResponse().sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
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.