24 Kasım 2022 Perşembe

Jakarta EE Concurrency ContextService Arayüzü

Giriş
Açıklaması şöyle
Used when you need an object to run on a non managed thread using a Jakarta EE Context.
Key for maintaining Security Context that can be propagated to other threads
One example is a JMX Notification Listener
Örnek
Şöyle yaparız
@Resource
ContextService contextSvc;

@GET
@Path("runnableproxy")
@Produces(MediaType.TEXT_PLAIN)
public String useProxy() {
  Runnable instance = 
    () -> System.out.println("Running in context");

  Runnable proxy = contextSvc.createContextualProxy(instance,Runnable.class);
  Thread thread = new Thread(proxy);
  thread.start();
  return "Started new thread";
}





Hiç yorum yok:

Yorum Gönder

Bean Validation @GroupSequence Anotasyonu

Örnek Elimizde şöyle bir kod olsun public class SampleRequest {   @NotNull   LocalDate startDate;   @NotNull   LocalDate endDate;   @AssertT...