Creates a new JSON Text Sequences from the specified {@link Publisher}.

@param contentPublisher the {@link Publisher} which publishes the objects supposed to send as contents
350462
public static HttpResponse fromPublisher(Publisher<?> contentPublisher) {
        return fromPublisher(defaultHttpHeaders, contentPublisher, HttpHeaders.EMPTY_HEADERS, defaultMapper);
    }
35925
public static JsonContent createJsonContent(HttpResponse httpResponse,
                                                JsonFactory jsonFactory) {
        byte[] rawJsonContent = null;
        try {
            if (httpResponse.getContent() != null) {
                rawJsonContent = IOUtils.toByteArray(httpResponse.getContent());
            }
        } catch (Exception e) {
            LOG.debug("Unable to read HTTP response content", e);
        }
        return new JsonContent(rawJsonContent, new ObjectMapper(jsonFactory)
                .configure(JsonParser.Feature.ALLOW_COMMENTS, true));
    }
883363
public static <T> JacksonParser<T> json(Class<T> contentType) {
        return new JacksonParser<>(null, contentType);
    }
182441
public static JsonDocument create(String id, JsonObject content) {
        return new JsonDocument(id, 0, content, 0, null);
    }
700262
@Override
	public TopicPublisher createPublisher(Topic topic) throws JMSException
    {
    	externalAccessLock.readLock().lock();
    	try
		{
	        checkNotClosed();
	        
	        RemoteTopicPublisher publisher =  new RemoteTopicPublisher(this,
	                                                                   DestinationTools.asRef(topic),
	                                                                   idProvider.createID());
	        registerProducer(publisher);
	        return publisher;
		}
    	finally
    	{
    		externalAccessLock.readLock().unlock();
    	}
    }
1347565
public <T> Iterator<T> iterator( Publisher<T> pub ) {
        return iterator(pub, batchSize);
    }
579525
@Override
	public JacksonWrapperParser createParser(String content) {
		try {
			return new JacksonWrapperParser(innerFactory.createParser(content), getSupportedFormat());
		} catch (IOException e) {
			e.printStackTrace();
			throw new KriptonRuntimeException(e);
		}
	}
777880
public JSON with(PrettyPrinter pp)
    {
        if (_prettyPrinter == pp) {
            return this;
        }
        return _with(_features, _streamFactory, _treeCodec,
                _reader, _writer, pp);
    }
172161
public static PublishRequest createPublishReq(PublishElement el) {
		if (el == null) {
			throw new NullPointerException("el is not allowed to be null");
		}

		PublishRequest ret = createPublishReq();
		ret.addPublishElement(el);
		return ret;
	}
437338
public static Function<String, String> createStringTemplateSource(
        I_CmsFormatterBean formatter,
        Supplier<CmsXmlContent> contentSupplier) {

        return key -> {
            String result = null;
            if (formatter != null) {
                result = formatter.getAttributes().get(key);
            }
            if (result == null) {
                CmsXmlContent content = contentSupplier.get();
                if (content != null) {
                    result = content.getHandler().getParameter(key);
                }
            }
            return result;
        };
    }
377467
public static <T extends Message> Marshaller<T> jsonMarshaller(
      final T defaultInstance, final Parser parser, final Printer printer) {

    final Charset charset = Charset.forName("UTF-8");

    return new Marshaller<T>() {
      @Override
      public InputStream stream(T value) {
        try {
          return new ByteArrayInputStream(printer.print(value).getBytes(charset));
        } catch (InvalidProtocolBufferException e) {
          throw Status.INTERNAL
              .withCause(e)
              .withDescription("Unable to print json proto")
              .asRuntimeException();
        }
      }

      @SuppressWarnings("unchecked")
      @Override
      public T parse(InputStream stream) {
        Builder builder = defaultInstance.newBuilderForType();
        Reader reader = new InputStreamReader(stream, charset);
        T proto;
        try {
          parser.merge(reader, builder);
          proto = (T) builder.build();
          reader.close();
        } catch (InvalidProtocolBufferException e) {
          throw Status.INTERNAL.withDescription("Invalid protobuf byte sequence")
              .withCause(e).asRuntimeException();
        } catch (IOException e) {
          // Same for now, might be unavailable
          throw Status.INTERNAL.withDescription("Invalid protobuf byte sequence")
              .withCause(e).asRuntimeException();
        }
        return proto;
      }
    };
  }
352331
@Bean
	public RemoteServiceCaller remoteServiceCaller(Optional<EasyTransRpcConsumer> optionalConsumer,
			@Lazy Optional<EasyTransMsgPublisher> optionalPublisher, ObjectSerializer serializer,
			QueueTopicMapper queueTopicMapper) {

		EasyTransRpcConsumer consumer = optionalConsumer.orElseGet(() -> new EasyTransRpcConsumer() {

			@Override
			public <P extends EasyTransRequest<R, ?>, R extends Serializable> R call(String appId, String busCode,
					String innerMethod, Map<String, Object> header, P params) {
				throw new RuntimeException("can not find EasyTransRpcConsumer implement but try handle rpc request");
			}

			@Override
			public <P extends EasyTransRequest<R, ?>, R extends Serializable> void callWithNoReturn(String appId,
					String busCode, String innerMethod, Map<String, Object> header, P params) {
				throw new RuntimeException("can not find EasyTransRpcConsumer implement but try handle rpc request");
			}
		});

		EasyTransMsgPublisher publisher = optionalPublisher.orElseGet(() -> new EasyTransMsgPublisher() {

			@Override
			public EasyTransMsgPublishResult publish(String topic, String tag, String key, Map<String, Object> header,
					byte[] msgByte) {
				throw new RuntimeException("can not find EasyTransMsgPublisher implement but try to publish a message");
			}
		});

		return new RemoteServiceCaller(consumer, publisher, serializer, queueTopicMapper);
	}
488205
public static PUBLISH copy(final PUBLISH original) {
        final PUBLISH publish = new PUBLISH();
        publish.setQoS(original.getQoS());
        publish.setRetain(original.isRetain());
        publish.setPayload(original.getPayload());
        publish.setTopic(original.getTopic());
        publish.setDuplicateDelivery(original.isDuplicateDelivery());
        publish.setMessageId(original.getMessageId());
        publish.setTTL(original.getTTL());
        return publish;
    }
497565
final PublishResponse publish(String topic, List<PubsubMessage> messages) {

    PublishRequest request =
        PublishRequest.newBuilder().setTopic(topic).addAllMessages(messages).build();
    return publish(request);
  }
970789
public static Completable toCompletable(Publisher<?> publisher) {
        if (publisher == null) {
            throw new NullPointerException("publisher");
        }
        return Completable.create(new PublisherAsCompletable(publisher));
    }
909119
public ListenableFuture<SegmentsAndMetadata> publishAll(final TransactionalSegmentPublisher publisher)
  {
    final Map<String, SegmentsForSequence> snapshot;
    synchronized (segments) {
      snapshot = ImmutableMap.copyOf(segments);
    }

    return publishInBackground(
        new SegmentsAndMetadata(
            snapshot
                .values()
                .stream()
                .flatMap(SegmentsForSequence::allSegmentStateStream)
                .map(segmentWithState -> Preconditions
                    .checkNotNull(
                        segmentWithState.getDataSegment(),
                        "dataSegment for segmentId[%s]",
                        segmentWithState.getSegmentIdentifier()
                    )
                )
                .collect(Collectors.toList()),
            null
        ),
        publisher
    );
  }
1066472
public MessageProtocol withContentType(String contentType) {
        return new MessageProtocol(Optional.ofNullable(contentType), charset, version);
    }