javax.enterprise.event.ObservesAsync Java Examples
The following examples show how to use
javax.enterprise.event.ObservesAsync.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CdiPlugin.java From tomee with Apache License 2.0 | 6 votes |
private static void validateObserverMethods(final CdiEjbBean<?> bean, final Map<ObserverMethod<?>, AnnotatedMethod<?>> methods) { final BeanContext beanContext = bean.getBeanContext(); if (beanContext.isLocalbean()) { return; } for (final Map.Entry<ObserverMethod<?>, AnnotatedMethod<?>> m : methods.entrySet()) { final Method method = m.getValue().getJavaMember(); if (!Modifier.isStatic(method.getModifiers())) { final Method viewMethod = doResolveViewMethod(bean, method); if (viewMethod == null) { throw new WebBeansConfigurationException( "@Observes " + method + " neither in the ejb view of ejb " + bean.getBeanContext().getEjbName() + " nor static"); } else if (beanContext.getBusinessRemoteInterfaces().contains(viewMethod.getDeclaringClass())) { throw new WebBeansConfigurationException(viewMethod + " observer is defined in a @Remote interface"); } } if (m.getValue().getParameters().stream().anyMatch(p -> p.isAnnotationPresent(ObservesAsync.class))) { throw new WebBeansConfigurationException("@ObservesAsync " + method + " not supported on EJB in CDI 2"); } } }
Example #2
Source File: AssignabilityWithGenericsTest.java From quarkus with Apache License 2.0 | 4 votes |
public void observeSomethingElse(@ObservesAsync String event, K injectedInstance) { // inject-ability is verified at bootstrap }
Example #3
Source File: AsyncObserverExceptionTest.java From quarkus with Apache License 2.0 | 4 votes |
void observeAsync1(@ObservesAsync @Priority(1) String value) { events.add("async1::" + value); throw new RuntimeException("nok"); }
Example #4
Source File: AsyncObserverExceptionTest.java From quarkus with Apache License 2.0 | 4 votes |
void observeAsync2(@ObservesAsync @Priority(2) String value) { events.add("async2::" + value); }
Example #5
Source File: AsyncObserverTest.java From quarkus with Apache License 2.0 | 4 votes |
void observeAsync(@ObservesAsync String value) { events.add("async::" + value + "::" + threadNameProvider.get()); }
Example #6
Source File: AsyncObserverTest.java From quarkus with Apache License 2.0 | 4 votes |
void observeAsync(@ObservesAsync String value) { events.add("async::" + value + "::" + threadNameProvider.get()); }
Example #7
Source File: AsyncService.java From javaee8-cookbook with Apache License 2.0 | 4 votes |
public void onFireEvent(@ObservesAsync User user){ response.resume(Response.ok(user).build()); }
Example #8
Source File: UserService.java From javaee8-cookbook with Apache License 2.0 | 4 votes |
public void sendUserNotificationAsync(@ObservesAsync User user){ System.out.println("sendUserNotificationAsync: " + user); }
Example #9
Source File: AuditEventReciever4.java From Java-EE-8-Sampler with MIT License | 4 votes |
public void receive(@ObservesAsync @Priority(1) AuditEvent auditEvent) { System.out.println("Priority: no (ObservesAsync) " + auditEvent.getPriority() + " " + auditEvent.getMessage()); }
Example #10
Source File: CreatedCarListener.java From Architecting-Modern-Java-EE-Applications with MIT License | 4 votes |
public void onCarCreated(@ObservesAsync CarCreated event) { // handle event asynchronously }
Example #11
Source File: EventCollector.java From trellis with Apache License 2.0 | 4 votes |
public void sink(@ObservesAsync final Event event) { events.add(event); }
Example #12
Source File: EventHandler.java From ee8-sandbox with Apache License 2.0 | 4 votes |
public void onMessage(@ObservesAsync Message message) { LOG.log(Level.INFO, "observes event:{0}", message); }
Example #13
Source File: AuditEventReciever.java From Java-EE-8-Sampler with MIT License | 3 votes |
public void receiveAsync(@ObservesAsync AuditEvent auditEvent) { System.out.println(auditEvent.getPriority() + " " + auditEvent.getMessage()); try { // Simulate some amount of work Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } }