CDI event qualifiers
The Errai CDI integration module (see a previous blog post) has support for event qualifiers now, both for event producers and observers. Multiple qualifiers can be specified for an event and of course custom qualifiers can be used.
CDI conversations
The simple use of @Conversational allows a server to directly address a single client in response to an event.
BusReadyEvent
Clients can observe a BusReadyEvent to be notified when the CDI event system has been initialized and the message bus is ready to be used.
The example code below shows how to use these new features. Notice again the use of a uniform API on both the client and server. For more details on Errai's CDI support see the online documentation. Any feedback is appreciated!
@EntryPoint
public class SimpleDocumentClient extends LayoutPanel {
@Inject
private Event<DocumentSubscription> documentSubscriptionEvent;
@Inject @Published
private Event<Document> publishedDocumentEvent;
public void buildUI(@Observes BusReadyEvent busReadyEvent) {
documentSubscriptionEvent.fire(new DocumentSubscription());
// ...
new Button().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
publishedDocumentEvent.fire(new Document());
}
});
}
public void onDocumentsReceived(@Observes Documents document) {
// this event is received as a direct response to the subscription event
// ...
}
public void onDocumentCreated(@Observes @New Document document) {
// ...
}
public void onDocumentUpdated(@Observes @Updated Document document) {
// ...
}
public void onDocumentDeleted(@Observes @Deleted Document document) {
// ...
}
}
@ApplicationScoped
public class SimpleDocumentService {
@Inject
private Event<Documents> subscriptionResponseEvent;
@Inject @New
private Event<Document> documentCreatedEvent;
@Inject @Updated
private Event<Document> documentUpdatedEvent;
@Inject @Deleted
private Event<Document> documentDeletedEvent;
@Conversational
public void onDocumentSubscription(@Observes DocumentSubscription subscription) {
Documents documents = new Documents();
//...
// respond to the client directly
subscriptionResponseEvent.fire(documents);
}
public void onDocumentPublished(@Observes @Published Document document) {
// receive document published events from the clients
//...
}
private void createDocument(Document document) {
// ...
documentCreatedEvent.fire(document);
}
private void updateDocument(Document document) {
// ...
documentUpdatedEvent.fire(document);
}
private void deleteDocument(Document document) {
// ...
documentDeletedEvent.fire(document);
}
}
I'm very happy being Herpes free now. It was a sad incident that was announced to me after the check up in the hospital and I was diagnosed of HSV 2. I thank God now for using Dr.odey Abang to cure my virus. I'm not ashamed to say this because no virus of such can be detected in me. I'm Charlotte from Columbia. I thought about it many Times when I heard about this Herbal cures for Herpes. I was really happy when I came across blogs of comments of Doctors who run cures sicknesses and was comfortable to try Dr. Abang from patients testimony I came across here on my online page. I knew now they are real Africa herbalists who run cures for Herpes. There's every opportunity to be cure with natural herbs, because all medical prescriptions are derived from herbs and roots. Its really hard time living with Herpes on drugs which can't get you cure. I tried this and I can boost of myself now as a woman. I need to be loved not to lost, get your instant cure to all sicknesses from Dr, Odey Abang.
ReplyDeleteHe cures HSV,HPV,Cancer,low spam count and much more from the evidence I saw 💯 % sure no site effects with active immune booster
Email him for you cure
Odeyabangherbalhome@gmail.com
WhatsApp/calls
+2349015049094