当前位置: 首页>>代码示例>>Java>>正文


Java SseFeature.SERVER_SENT_EVENTS属性代码示例

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


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

示例1: listenToBroadcast

@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,代码行数:21,代码来源:OrderEndpointShopStaffPFS.java

示例2: listenToBroadcast

@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,代码行数:20,代码来源:OrderResourcePFS.java

示例3: listenToBroadcast

@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,代码行数:21,代码来源:EndUserResourceNew.java

示例4: listenToBroadcast

@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,代码行数:19,代码来源:SSEEndpoint.java

示例5: events

@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,代码行数:19,代码来源:SpaceObjectResource.java

示例6: listenToEvents

@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,代码行数:14,代码来源:EventsSseService.java

示例7: getServerSentEvents

@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,代码行数:8,代码来源:FactsResource.java

示例8: getServerSentEventsFull

@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
@NoCache
public EventOutput getServerSentEventsFull(
        @NotNull @Valid @BeanParam SubscriptionRequestParams subscriptionRequestParams) {
    return createEventOutput(subscriptionRequestParams, true);
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:7,代码来源:FactsResource.java

示例9: errors

@GET
@Path("/events.stream")
@Produces(SseFeature.SERVER_SENT_EVENTS)
@ApiOperation(value = "Get Event Stream of Application Events", notes = "Returns a continuous stream of application events using Server-Sent Events.")
public EventOutput errors() {
    final EventOutput eventOutput = new EventOutput();
    BROADCASTER.add(eventOutput);

    return eventOutput;
}
 
开发者ID:vgoldin,项目名称:cqrs-eventsourcing-kafka,代码行数:10,代码来源:InventoryItemResource.java

示例10: fetch

@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput fetch() {
    final EventOutput eventOutput = new EventOutput();
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                for (int i = 0; i < 10; i++) {
                    final OutboundEvent.Builder eventBuilder = new OutboundEvent.Builder();
                    eventBuilder.name("message-to-client");
                    eventBuilder.data(String.class,
                            "Hello world " + i + "!");
                    final OutboundEvent event = eventBuilder.build();
                    eventOutput.write(event);
                }
            } catch (IOException e) {
                throw new RuntimeException(
                        "Error when writing the event.", e);
            } finally {
                try {
                    eventOutput.close();
                } catch (IOException ioClose) {
                    throw new RuntimeException(
                            "Error when closing the event output.",
                            ioClose);
                }
            }
        }
    }).start();
    return eventOutput;
}
 
开发者ID:smoketurner,项目名称:pipeline,代码行数:33,代码来源:PipelineClientTest.java

示例11: fetch

@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput fetch(
        @HeaderParam(SseFeature.LAST_EVENT_ID_HEADER) String lastEventId) {
    if (!Strings.isNullOrEmpty(lastEventId)) {
        LOGGER.debug("Found Last-Event-ID header: {}", lastEventId);
    }

    final EventOutput output = new EventOutput();
    if (!broadcaster.add(output)) {
        throw new ServiceUnavailableException(RETRY_AFTER.toSeconds());
    }
    return output;
}
 
开发者ID:smoketurner,项目名称:pipeline,代码行数:14,代码来源:EventResource.java

示例12: emitEvents

@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput emitEvents() {
    final EventOutput eventOutput = new EventOutput();
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                for (int i = 0; i < 25; i++) {
                    final OutboundEvent.Builder eventBuilder
                            = new OutboundEvent.Builder();
                    eventBuilder.name("message-to-client");
                    eventBuilder.data(String.class,
                            "Hello world " + i + "!");
                    final OutboundEvent event = eventBuilder.build();
                    eventOutput.write(event);
                }
            } catch (IOException e) {
                throw new RuntimeException(
                        "Error when writing the event.", e);
            } finally {
                try {
                    eventOutput.close();
                } catch (IOException ioClose) {
                    throw new RuntimeException(
                            "Error when closing the event output.", ioClose);
                }
            }
        }
    }).start();

    return eventOutput;
}
 
开发者ID:cloudskol,项目名称:restskol,代码行数:34,代码来源:RestSkolSSEResource.java

示例13: listenToBroadcast

@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput listenToBroadcast() {
	
	
    final EventOutput eventOutput = new EventOutput();
    boolean val=this.broadcaster.add(eventOutput);
    System.out.println("brcd2:"+val);
    return eventOutput;
}
 
开发者ID:FTSRG,项目名称:mondo-collab-framework,代码行数:10,代码来源:BroadcasterResource.java

示例14: itemEvents

@GET
@Path("events")
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput itemEvents() {
    final EventOutput eventOutput = new EventOutput();
    BROADCASTER.add(eventOutput);
    return eventOutput;
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:8,代码来源:MyResource.java

示例15: listenToBroadcast

@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput listenToBroadcast() {
    final EventOutput eventOutput = new EventOutput();
    this.broadcaster.add(eventOutput);
    return eventOutput;
}
 
开发者ID:csrinaldi,项目名称:powercode,代码行数:7,代码来源:SseResource.java


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