• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SseFeature类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.glassfish.jersey.media.sse.SseFeature的典型用法代码示例。如果您正苦于以下问题:Java SseFeature类的具体用法?Java SseFeature怎么用?Java SseFeature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SseFeature类属于org.glassfish.jersey.media.sse包,在下文中一共展示了SseFeature类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: startServer

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
protected void startServer() {
        WifiManager wifiMgr = (WifiManager) getApplicationContext()
                .getSystemService(Service.WIFI_SERVICE);
        if (wifiMgr.isWifiEnabled()) {
            // Deprecated. Does not support ipv6. *shrug* :)
            String ipAddress = Formatter.formatIpAddress(wifiMgr.getConnectionInfo()
                    .getIpAddress());

            URI baseUri = UriBuilder.fromUri("http://" + ipAddress)
                    .port(49152)
                    .build();
            ResourceConfig config = new ResourceConfig(SseFeature.class)
                    .register(JacksonFeature.class);
            config.registerInstances(new SecureFilter(this));
            config.registerInstances(new DeskDroidResource(this));
//            server = JettyHttpContainerFactory.createServer(baseUri, config);
            server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config);
        }
    }
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:20,代码来源:DeskDroidService.java


示例2: run

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
@Override
public void run(InventoryItemApiConfiguration configuration, Environment environment) throws Exception {
    configureObjectMapper(environment);

    CommandDispatcher commandDispatcher = configuration.getCommandDispatcherFactory().build(environment);

    environment.jersey().register(new ApiListingResource());
    environment.jersey().register(SseFeature.class);

    InventoryItemResource resource = new InventoryItemResource(new InventoryItemsQuery(), commandDispatcher);
    environment.jersey().register(resource);
    environment.lifecycle().manage(new KafkaDenormalizer());
    environment.lifecycle().manage(new HazelcastManaged());

    StreamBroadcaster broadcaster = configuration.getStreamBroadcasterFactory().build(environment);
    broadcaster.addObserver(resource);

    configureSwagger(environment);
}
 
开发者ID:vgoldin,项目名称:cqrs-eventsourcing-kafka,代码行数:20,代码来源:InventoryItemApi.java


示例3: listenToBroadcast

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
@GET
@Path("/Notifications/{ShopID}")
@Produces(SseFeature.SERVER_SENT_EVENTS)
@RolesAllowed({GlobalConstants.ROLE_SHOP_ADMIN})
public EventOutput listenToBroadcast(@PathParam("ShopID")int shopID) {
	final EventOutput eventOutput = new EventOutput();

	if(Globals.broadcasterMap.get(shopID)!=null)
	{
		SseBroadcaster broadcasterOne = Globals.broadcasterMap.get(shopID);
		broadcasterOne.add(eventOutput);
	}
	else
	{
		SseBroadcaster broadcasterTwo = new SseBroadcaster();
		broadcasterTwo.add(eventOutput);
		Globals.broadcasterMap.put(shopID,broadcasterTwo);
	}

	return eventOutput;
}
 
开发者ID:SumeetMoray,项目名称:Nearby-Shops-API,代码行数:22,代码来源:OrderEndpointShopStaffPFS.java


示例4: listenToBroadcast

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
@GET
@Path("/Notifications/{ShopID}")
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput listenToBroadcast(@PathParam("ShopID")int shopID) {
	final EventOutput eventOutput = new EventOutput();

	if(Globals.broadcasterMap.get(shopID)!=null)
	{
		SseBroadcaster broadcasterOne = Globals.broadcasterMap.get(shopID);
		broadcasterOne.add(eventOutput);
	}
	else
	{
		SseBroadcaster broadcasterTwo = new SseBroadcaster();
		broadcasterTwo.add(eventOutput);
		Globals.broadcasterMap.put(shopID,broadcasterTwo);
	}

	return eventOutput;
}
 
开发者ID:SumeetMoray,项目名称:Nearby-Shops-API,代码行数:21,代码来源:OrderResourcePFS.java


示例5: listenToBroadcast

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
@GET
@Path("/Notifications/{EndUserID}")
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput listenToBroadcast(@PathParam("EndUserID")int endUserID) {

	final EventOutput eventOutput = new EventOutput();

	if(Globals.broadcasterMapEndUser.get(endUserID)!=null)
	{
		SseBroadcaster broadcasterOne = Globals.broadcasterMapEndUser.get(endUserID);
		broadcasterOne.add(eventOutput);
	}
	else
	{
		SseBroadcaster broadcasterTwo = new SseBroadcaster();
		broadcasterTwo.add(eventOutput);
		Globals.broadcasterMapEndUser.put(endUserID,broadcasterTwo);
	}

	return eventOutput;
}
 
开发者ID:SumeetMoray,项目名称:Nearby-Shops-API,代码行数:22,代码来源:EndUserResourceNew.java


示例6: listenToBroadcast

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
@GET
@Path("/{ShopID}")
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput listenToBroadcast(@PathParam("ShopID")int shopID) {
    final EventOutput eventOutput = new EventOutput();

    if(Globals.broadcasterMap.get(shopID)!=null)
    {
        SseBroadcaster broadcasterOne = Globals.broadcasterMap.get(shopID);
        broadcasterOne.add(eventOutput);
    }
    else
    {
        SseBroadcaster broadcasterTwo = new SseBroadcaster();
        broadcasterTwo.add(eventOutput);
        Globals.broadcasterMap.put(shopID,broadcasterTwo);
    }
    return eventOutput;
}
 
开发者ID:SumeetMoray,项目名称:Nearby-Shops-API,代码行数:20,代码来源:SSEEndpoint.java


示例7: create

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
public <RootResponse> Response<RootResponse> create(@NonNull String url, @NonNull Class<RootResponse> clazz,
		ClientConfiguration clientConfigurationOrNull) {
	Optional<ClientConfiguration> clientConfiguration = Optional.ofNullable(clientConfigurationOrNull);
	JerseyClient newClient = jerseyClientBuilder.register(SseFeature.class).withConfig(clientConfig).build();
	newClient.register(LastEventIdHeaderFilter.class);

	if (clientConfigurationOrNull != null && !Strings.isNullOrEmpty(clientConfigurationOrNull.getAuthorization())) {
		newClient.register(new AuthHeaderFilter(clientConfigurationOrNull.getAuthorization()));
	}

	MediaType mediaType = clientConfiguration.map(c -> c.getMediaType()).orElse(MediaType.APPLICATION_JSON_TYPE);

	ResponseBuilder responseBuilder = new ResponseBuilder(newClient, objectMapper, mediaType);
	JerseyWebTarget webTarget = newClient.target(url);
	Builder requestBuilder = webTarget.request(mediaType);
	String readEntity = requestBuilder.get().readEntity(String.class);
	return responseBuilder.buildResponse(readEntity, clazz, URI.create(url)).get();
}
 
开发者ID:Mercateo,项目名称:rest-hateoas-client,代码行数:19,代码来源:ClientStarter.java


示例8: testCreate

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
@Test
public void testCreate() throws Exception {
	when(jerseyClientBuilder.build()).thenReturn(client);
	when(jerseyClientBuilder.register(SseFeature.class)).thenReturn(jerseyClientBuilder);
	when(jerseyClientBuilder.withConfig(any())).thenReturn(jerseyClientBuilder);
	when(client.target(anyString())).thenReturn(webTarget);
	when(webTarget.request(any(MediaType.class))).thenReturn(builder);
	when(builder.get()).thenReturn(response);
	when(response.readEntity(String.class)).thenReturn("");

	uut.create("http://mercateo.com/test", Object.class);
	verify(jerseyClientBuilder).build();
	verify(client).target(anyString());
	verify(webTarget).request(any(MediaType.class));
	verify(builder).get();
	verify(response).readEntity(String.class);
}
 
开发者ID:Mercateo,项目名称:rest-hateoas-client,代码行数:18,代码来源:ClientStarter0Test.java


示例9: testCreateWithConfig

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
@Test
public void testCreateWithConfig() throws Exception {
	when(jerseyClientBuilder.build()).thenReturn(client);
	when(jerseyClientBuilder.register(SseFeature.class)).thenReturn(jerseyClientBuilder);
	when(jerseyClientBuilder.withConfig(any())).thenReturn(jerseyClientBuilder);
	when(client.target(anyString())).thenReturn(webTarget);
	when(webTarget.request(any(MediaType.class))).thenReturn(builder);
	when(builder.get()).thenReturn(response);
	when(response.readEntity(String.class)).thenReturn("");

	ClientConfiguration clientConfiguration = new ClientConfiguration("test", null);

	uut.create("http://mercateo.com/test", Object.class, clientConfiguration);
	verify(jerseyClientBuilder).build();
	verify(client).target(anyString());
	verify(webTarget).request(any(MediaType.class));
	verify(builder).get();
	verify(response).readEntity(String.class);
	verify(client).register(eq(new AuthHeaderFilter("test")));
}
 
开发者ID:Mercateo,项目名称:rest-hateoas-client,代码行数:21,代码来源:ClientStarter0Test.java


示例10: events

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
@GET
@Path("events")
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput events() {
    final EventOutput eventOutput = new EventOutput();

    if (!broadcaster.add(eventOutput)) {
        // 503 -> 5s delayed client reconnect attempt.
        throw new ServiceUnavailableException(5L);
    }

    try {
        eventOutput.write(event());
    } catch (final IOException ioe) {
        // NO-OP.
    }

    return eventOutput;
}
 
开发者ID:martinjmares,项目名称:javaone2015-cloudone,代码行数:20,代码来源:SpaceObjectResource.java


示例11: testSse

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
@Ignore
@Test
public void testSse() {
    Client client = ClientBuilder.newBuilder()
            .register(SseFeature.class).build();
    WebTarget target = client.target("http://localhost:8080/restskol/api")
            .path("events");

    EventInput eventInput = target.request().get(EventInput.class);
    while (!eventInput.isClosed()) {
        final InboundEvent inboundEvent = eventInput.read();
        if (inboundEvent == null) {
            break;
        }

        System.out.println(inboundEvent.getName() + "; "
                + inboundEvent.readData(String.class));
    }
}
 
开发者ID:cloudskol,项目名称:restskol,代码行数:20,代码来源:RestSkolSSEResourceTest.java


示例12: stream

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
/**
 * Allows to stream SSE events from horizon.
 * Certain endpoints in Horizon can be called in streaming mode using Server-Sent Events.
 * This mode will keep the connection to horizon open and horizon will continue to return
 * responses as ledgers close.
 * @see <a href="http://www.w3.org/TR/eventsource/" target="_blank">Server-Sent Events</a>
 * @see <a href="https://www.stellar.org/developers/horizon/learn/responses.html" target="_blank">Response Format documentation</a>
 * @param listener {@link EventListener} implementation with {@link AccountResponse} type
 * @return EventSource object, so you can <code>close()</code> connection when not needed anymore
 */
public EventSource stream(final EventListener<AccountResponse> listener) {
  Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
  WebTarget target = client.target(this.buildUri());
  EventSource eventSource = new EventSource(target) {
    @Override
    public void onEvent(InboundEvent inboundEvent) {
      String data = inboundEvent.readData(String.class);
      if (data.equals("\"hello\"")) {
        return;
      }
      AccountResponse account = GsonSingleton.getInstance().fromJson(data, AccountResponse.class);
      listener.onEvent(account);
    }
  };
  return eventSource;
}
 
开发者ID:stellar,项目名称:java-stellar-sdk,代码行数:27,代码来源:AccountsRequestBuilder.java


示例13: stream

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
/**
 * Allows to stream SSE events from horizon.
 * Certain endpoints in Horizon can be called in streaming mode using Server-Sent Events.
 * This mode will keep the connection to horizon open and horizon will continue to return
 * responses as ledgers close.
 * @see <a href="http://www.w3.org/TR/eventsource/" target="_blank">Server-Sent Events</a>
 * @see <a href="https://www.stellar.org/developers/horizon/learn/responses.html" target="_blank">Response Format documentation</a>
 * @param listener {@link EventListener} implementation with {@link OperationResponse} type
 * @return EventSource object, so you can <code>close()</code> connection when not needed anymore
 */
public EventSource stream(final EventListener<OperationResponse> listener) {
  Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
  WebTarget target = client.target(this.buildUri());
  EventSource eventSource = new EventSource(target) {
    @Override
    public void onEvent(InboundEvent inboundEvent) {
      String data = inboundEvent.readData(String.class);
      if (data.equals("\"hello\"")) {
        return;
      }
      OperationResponse payment = GsonSingleton.getInstance().fromJson(data, OperationResponse.class);
      listener.onEvent(payment);
    }
  };
  return eventSource;
}
 
开发者ID:stellar,项目名称:java-stellar-sdk,代码行数:27,代码来源:PaymentsRequestBuilder.java


示例14: stream

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
/**
 * Allows to stream SSE events from horizon.
 * Certain endpoints in Horizon can be called in streaming mode using Server-Sent Events.
 * This mode will keep the connection to horizon open and horizon will continue to return
 * responses as ledgers close.
 * @see <a href="http://www.w3.org/TR/eventsource/" target="_blank">Server-Sent Events</a>
 * @see <a href="https://www.stellar.org/developers/horizon/learn/responses.html" target="_blank">Response Format documentation</a>
 * @param listener {@link EventListener} implementation with {@link EffectResponse} type
 * @return EventSource object, so you can <code>close()</code> connection when not needed anymore
 */
public EventSource stream(final EventListener<EffectResponse> listener) {
  Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
  WebTarget target = client.target(this.buildUri());
  EventSource eventSource = new EventSource(target) {
    @Override
    public void onEvent(InboundEvent inboundEvent) {
      String data = inboundEvent.readData(String.class);
      if (data.equals("\"hello\"")) {
        return;
      }
      EffectResponse effect = GsonSingleton.getInstance().fromJson(data, EffectResponse.class);
      listener.onEvent(effect);
    }
  };
  return eventSource;
}
 
开发者ID:stellar,项目名称:java-stellar-sdk,代码行数:27,代码来源:EffectsRequestBuilder.java


示例15: stream

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
/**
 * Allows to stream SSE events from horizon.
 * Certain endpoints in Horizon can be called in streaming mode using Server-Sent Events.
 * This mode will keep the connection to horizon open and horizon will continue to return
 * responses as ledgers close.
 * @see <a href="http://www.w3.org/TR/eventsource/" target="_blank">Server-Sent Events</a>
 * @see <a href="https://www.stellar.org/developers/horizon/learn/responses.html" target="_blank">Response Format documentation</a>
 * @param listener {@link EventListener} implementation with {@link TransactionResponse} type
 * @return EventSource object, so you can <code>close()</code> connection when not needed anymore
 */
public EventSource stream(final EventListener<TransactionResponse> listener) {
  Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
  WebTarget target = client.target(this.buildUri());
  EventSource eventSource = new EventSource(target) {
    @Override
    public void onEvent(InboundEvent inboundEvent) {
      String data = inboundEvent.readData(String.class);
      if (data.equals("\"hello\"")) {
        return;
      }
      TransactionResponse transaction = GsonSingleton.getInstance().fromJson(data, TransactionResponse.class);
      listener.onEvent(transaction);
    }
  };
  return eventSource;
}
 
开发者ID:stellar,项目名称:java-stellar-sdk,代码行数:27,代码来源:TransactionsRequestBuilder.java


示例16: stream

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
/**
 * Allows to stream SSE events from horizon.
 * Certain endpoints in Horizon can be called in streaming mode using Server-Sent Events.
 * This mode will keep the connection to horizon open and horizon will continue to return
 * responses as ledgers close.
 * @see <a href="http://www.w3.org/TR/eventsource/" target="_blank">Server-Sent Events</a>
 * @see <a href="https://www.stellar.org/developers/horizon/learn/responses.html" target="_blank">Response Format documentation</a>
 * @param listener {@link EventListener} implementation with {@link LedgerResponse} type
 * @return EventSource object, so you can <code>close()</code> connection when not needed anymore
 */
public EventSource stream(final EventListener<LedgerResponse> listener) {
  Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
  WebTarget target = client.target(this.buildUri());
  EventSource eventSource = new EventSource(target) {
    @Override
    public void onEvent(InboundEvent inboundEvent) {
      String data = inboundEvent.readData(String.class);
      if (data.equals("\"hello\"")) {
        return;
      }
      LedgerResponse ledger = GsonSingleton.getInstance().fromJson(data, LedgerResponse.class);
      listener.onEvent(ledger);
    }
  };
  return eventSource;
}
 
开发者ID:stellar,项目名称:java-stellar-sdk,代码行数:27,代码来源:LedgersRequestBuilder.java


示例17: test

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
@Test
public void test() throws Exception {
    Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
    WebTarget target = client.target(uri("/events"));

    List<InboundEvent> events = new ArrayList<>();
    CountDownLatch latch = new CountDownLatch(3);

    EventSource eventSource = EventSource.target(target).build();
    EventListener listener = inboundEvent -> {
        events.add(inboundEvent);
        latch.countDown();
    };
    eventSource.register(listener);
    eventSource.open();

    sse.send(event("Hello 1\nLine 1").withId("1").withName("hello1"));
    sse.send(event("Hello 2\nLine 2").withId("2").withName("hello2"));
    sse.send(event("Hello 3\nLine 3").withId("3").withName("hello3"));

    assertTrue(latch.await(500, TimeUnit.MILLISECONDS));

    assertThat(events.get(1).getId(), equalTo("2"));
    assertThat(events.get(1).getName(), equalTo("hello2"));
    assertThat(events.get(1).readData(), equalTo("Hello 2\nLine 2"));
}
 
开发者ID:nosceon,项目名称:titanite,代码行数:27,代码来源:ServerSentEventsE2ETest.java


示例18: WebApp

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
@Inject
public WebApp(Injector injector, ServiceLocator serviceLocator) {
    log.info("Setting up Web Application");

    register(SseFeature.class);
    register(MultiPartFeature.class);
    register(ExposrExceptionMapper.class);

    // Resources.
    register(BuildResource.class);
    register(ExposrResource.class);
    register(ProjectResource.class);
    register(SyncResource.class);
    register(TaskResource.class);

    GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);

    final GuiceIntoHK2Bridge bridge = serviceLocator
            .getService(GuiceIntoHK2Bridge.class);

    bridge.bridgeGuiceInjector(injector);
}
 
开发者ID:udoprog,项目名称:exposr,代码行数:23,代码来源:WebApp.java


示例19: listenToEvents

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
@GET
@PermitAll
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput listenToEvents(@QueryParam("token") String token) {
  String removedToken = SLTRegister.remove(token);

  if (removedToken == null) {
    return null;
  }

  final EventOutput eventOutput = new EventOutput();
  sseBroadcaster.add(eventOutput);
  return eventOutput;
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:15,代码来源:EventsSseService.java


示例20: getServerSentEvents

import org.glassfish.jersey.media.sse.SseFeature; //导入依赖的package包/类
@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
@NoCache
@Path("id-only")
public EventOutput getServerSentEvents(
        @NotNull @Valid @BeanParam SubscriptionRequestParams subscriptionRequestParams) {
    return createEventOutput(subscriptionRequestParams, false);
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:9,代码来源:FactsResource.java



注:本文中的org.glassfish.jersey.media.sse.SseFeature类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IGenerator2类代码示例发布时间:2022-05-21
下一篇:
Java MarshallingException类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap