本文整理汇总了Java中org.glassfish.jersey.media.sse.EventOutput类的典型用法代码示例。如果您正苦于以下问题:Java EventOutput类的具体用法?Java EventOutput怎么用?Java EventOutput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventOutput类属于org.glassfish.jersey.media.sse包,在下文中一共展示了EventOutput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listenToBroadcast
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的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;
}
示例2: listenToBroadcast
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的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;
}
示例3: listenToBroadcast
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的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;
}
示例4: listenToBroadcast
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的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;
}
示例5: events
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的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;
}
示例6: subscribeToParameterValueChange
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的package包/类
@Override
public EventOutput subscribeToParameterValueChange(String serviceName,
String parameterName) {
try {
RestService restService = restServiceRegistry
.getService(serviceName);
RestParameter restParameter = restService
.getParameter(parameterName);
EventOutput eventOutput = new EventOutput();
Observable obs = valueUpdateHandler.getObservable(restParameter
.getSubscriptionParameter());
EventOutputWrapper eventOutputWrapper = new EventOutputWrapper(obs,
eventOutput);
return eventOutputWrapper.getEventOutput();
} catch (NoSuchParameterException nspe) {
throw new NotFoundException("Parameter " + serviceName + "/"
+ parameterName + " does not exist!");
} catch (NoSuchServiceException e) {
throw new NotFoundException("Service " + serviceName
+ " does not exist!");
}
}
示例7: listenToEvents
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的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;
}
示例8: getServerSentEvents
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的package包/类
@GET
@Path("/{stopCode}")
public EventOutput getServerSentEvents(@PathParam("stopCode") final String stopCode) {
final EventOutput eventOutput = new EventOutput();
new Thread(() -> new MqttClient(DisplayConfiguration.getSystemParameters().getConnectionString(), UUID.randomUUID().toString(), new OnMessageCallback(eventOutput))).start();
return eventOutput;
}
示例9: getServerSentEvents
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的package包/类
@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
@NoCache
@Path("id-only")
public EventOutput getServerSentEvents(
@NotNull @Valid @BeanParam SubscriptionRequestParams subscriptionRequestParams) {
return createEventOutput(subscriptionRequestParams, false);
}
示例10: getServerSentEventsFull
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的package包/类
@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
@NoCache
public EventOutput getServerSentEventsFull(
@NotNull @Valid @BeanParam SubscriptionRequestParams subscriptionRequestParams) {
return createEventOutput(subscriptionRequestParams, true);
}
示例11: createEventOutput
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的package包/类
private EventOutput createEventOutput(SubscriptionRequestParams subscriptionRequestParams,
boolean fullOutput) {
final EventOutput eventOutput = new EventOutput();
SubscriptionRequestTO req = subscriptionRequestParams.toRequest(!fullOutput);
AtomicReference<Subscription> subscription = new AtomicReference<Subscription>(null);
FactObserver observer = factsObserverFactory.createFor(eventOutput, linkFactoryContext
.getBaseUri(), subscription, fullOutput);
Subscription sub = factStore.subscribe(req, observer);
subscription.set(sub);
return eventOutput;
}
示例12: FactsObserver
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的package包/类
public FactsObserver(@NonNull EventOutput eventOutput,
@NonNull LinkFactory<FactsResource> linkFatory,
@NonNull HyperSchemaCreator hyperSchemaCreator, @NonNull URI baseURI,
@NonNull AtomicReference<Subscription> subcription,
@NonNull FactTransformer factTransformer, boolean fullOutputMode) {
super();
this.fullOutputMode = fullOutputMode;
this.eventOutput = eventOutput;
this.linkFatory = linkFatory;
this.hyperSchemaCreator = hyperSchemaCreator;
this.subcription = subcription;
this.factTransformer = factTransformer;
// this is need, because we are nor in requestscope anymore
this.linkFactoryContext = new LinkFactoryContext() {
@Override
public MethodCheckerForLink getMethodCheckerForLink() {
return m -> true;
}
@Override
public FieldCheckerForSchema getFieldCheckerForSchema() {
return (f, c) -> true;
}
@Override
public URI getBaseUri() {
return baseURI;
}
};
}
示例13: createFor
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的package包/类
FactsObserver createFor(@NonNull EventOutput eventOutput, @NonNull URI baseURI,
@NonNull AtomicReference<Subscription> subscription, boolean fullOutputMode) {
FactsObserver factsObserver = new FactsObserver(eventOutput, factsResourceLinkFactory,
hyperSchemaCreator, baseURI, subscription, factTransformer, fullOutputMode);
scheduleCleanUp(new CompletableFuture<>(), factsObserver);
return factsObserver;
}
示例14: testNullContracts
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testNullContracts() throws Exception {
TestHelper.expectNPE(() -> new FactsObserverFactory(null, hyperSchemaCreator,
factTransformer, executorService, 0));
TestHelper.expectNPE(() -> new FactsObserverFactory(factsResourceLinkFactory, null,
factTransformer, executorService, 0));
TestHelper.expectNPE(() -> new FactsObserverFactory(factsResourceLinkFactory,
hyperSchemaCreator, null, executorService, 0));
TestHelper.expectNPE(() -> new FactsObserverFactory(factsResourceLinkFactory,
hyperSchemaCreator, factTransformer, null, 0));
FactsObserverFactory uut = new FactsObserverFactory(factsResourceLinkFactory,
hyperSchemaCreator, factTransformer, executorService, 0);
TestHelper.expectNPE(() -> uut.createFor(null, new URI("http://ibm.com"),
new AtomicReference<>(), false));
TestHelper.expectNPE(() -> uut.createFor(mock(EventOutput.class), null,
new AtomicReference<>(), false));
TestHelper.expectNPE(() -> uut.createFor(mock(EventOutput.class), new URI("http://ibm.com"),
null, false));
}
示例15: testGetServerSentEvents
import org.glassfish.jersey.media.sse.EventOutput; //导入依赖的package包/类
@Test
public void testGetServerSentEvents() throws Exception {
SubscriptionRequestParams subscriptionRequestParams = mock(SubscriptionRequestParams.class);
SubscriptionRequestTO subTo = mock(SubscriptionRequestTO.class);
when(subscriptionRequestParams.toRequest(anyBoolean())).thenReturn(subTo);
FactsObserver value = mock(FactsObserver.class);
when(eventObserverFactory.createFor(any(), any(), any(), anyBoolean())).thenReturn(value);
URI baseUri = new URI("http://localhost:8080");
when(linkFactoryContext.getBaseUri()).thenReturn(baseUri);
EventOutput returnValue = uut.getServerSentEvents(subscriptionRequestParams);
verify(eventObserverFactory).createFor(eq(returnValue), eq(baseUri), any(), eq(false));
verify(factStore).subscribe(subTo, value);
}