@antoine_sd#CDIUni
CDI University
@antoine_sd
Red Hat, http://cdi-spec.org
CDI specification leader
@antoine_sd#CDIUni
Antoine Sabot-Durand
•Senior Software Developer @Red Hat
!
•Java & OSS :
•CDI co-spec lead
•CDI eco-sys...
@YourTwitterHandle#DVXFR14{session hashtag} @antoine_sd#CDIUni
CDI basics
@antoine_sd#CDIUni
•CDI is a lot of things
•Java EE IoC standard also working on Java SE
•Context management
•Observer pat...
@antoine_sd#CDIUni
CDI history & actual state
•Main milestone :
•December 2009 : CDI 1.0
•June 2013 : CDI 1.1
•April 2014 ...
@antoine_sd#CDIUni
CDI activated by default in Java EE 7
•In Java EE 6, you must add a beans.xml file to your
archive
•No ...
@antoine_sd#CDIUni
Bean
•In Java EE 6 everything is a Managed Bean
•Managed beans are basic components
•They are managed b...
@antoine_sd#CDIUni
Dependency Injection
@Inject
@antoine_sd#CDIUni
public class HelloService {!
    public String hello() {!
        return "Hello World!";!
    }!
}
Depe...
@antoine_sd#CDIUni
public class MyBean {!
!
    private HelloService service;!
!
    @Inject!
    public MyBean(HelloServi...
@antoine_sd#CDIUni
public class MyBean {!
!
    private HelloService service;!
!
    @Inject!
    public void setService(H...
@antoine_sd#CDIUni
public class MyBean {!
!
    @Inject HelloService service;!
!
    public void displayHello() {!
       ...
@antoine_sd#CDIUni
public interface HelloService {!
    public String hello();!
}!
public class FrenchHelloService impleme...
@antoine_sd#CDIUni
@Qualifier!
@Retention(RUNTIME)!
@Target({FIELD, TYPE, METHOD, PARAMETER}) !
public @interface French {...
@antoine_sd#CDIUni
@French!
public class FrenchHelloService implements HelloService {!
    public String hello() {!
      ...
@antoine_sd#CDIUni
public class MyBean {!
    @Inject @French HelloService service;!
    public void displayHello() {!
   ...
@antoine_sd#CDIUni
@Qualifier!
@Retention(RUNTIME)!
@Target({FIELD, TYPE, METHOD, PARAMETER}) !
public @interface Language...
@antoine_sd#CDIUni
@Language(FRENCH)!
public class FrenchHelloService implements HelloService {!
    public String hello()...
@antoine_sd#CDIUni
public class MyBean {!
    @Inject @Language(ENGLISH) HelloService service;!
    public void displayHel...
@antoine_sd#CDIUni
public class MyBean {!
    @Inject @French !
HelloService service;!
}!
!
@French @Console @Secured!
pub...
@antoine_sd#CDIUni
public class MyBean {!
    @Inject @French @Console!
HelloService service;!
}!
!
@French @Console @Secu...
@antoine_sd#CDIUni
public class MyBean {!
    @Inject @French @Console @Secured !
HelloService service;!
}!
!
@French @Con...
@antoine_sd#CDIUni
public class MyBean {!
    @Inject @French @Console @Secured !
HelloService service;!
}!
!
@French @Sec...
@antoine_sd#CDIUni
Reserved Qualifiers
@Default!
@Any!
@Named
@antoine_sd#CDIUni
public class MyBean {!
!
    @Inject Instance<HelloService> service;!
!
    public void displayHello() ...
@antoine_sd#CDIUni
public class MyBean {!
!
    @Inject Instance<HelloService> service;!
!
    public void displayHello() ...
@antoine_sd#CDIUni
public class MyBean {!
!
    @Inject @Any Instance<HelloService> services;!
!
    public void displayHe...
@antoine_sd#CDIUni
public class MyBean {!
!
    @Inject @Any Instance<HelloService> services;!
!
    public void displayHe...
@antoine_sd#CDIUni
Contexts
•Manage bean lifecycle
•context helps container to choose when a bean should be generated and
...
@antoine_sd#CDIUni
@SessionScoped!
public class CartBean {!
!
    public void addItem(Item item) {!
...!
    } !
}
Contexts
@antoine_sd#CDIUni
@ApplicationScoped!
public class CartBean {!
!
    public void addItem(Item item) {!
...!
    } !
}
Con...
@antoine_sd#CDIUni
@ConversationScoped!
public class CartBean {!
!
    public void addItem(Item item) {!
...!
    } !
}
Co...
@antoine_sd#CDIUni
@ThreadScoped!
public class CartBean {!
!
    public void addItem(Item item) {!
...!
    } !
}
Contexts
@antoine_sd#CDIUni
@HourScoped!
public class CartBean {!
!
    public void addItem(Item item) {!
...!
    } !
}
Contexts
@antoine_sd#CDIUni
@RandomScoped!
public class CartBean {!
!
    public void addItem(Item item) {!
...!
    } !
}
Contexts
@antoine_sd#CDIUni
@Produces!
public MyNonCDIClass myProducer() {!
return new MyNonCdiClass();!
}!
...!
@Inject!
MyNonCDIC...
@antoine_sd#CDIUni
@Produces!
@RequestScoped!
public FacesContext produceFacesContext() {!
return FacesContext.getCurrentI...
@antoine_sd#CDIUni
@Produces!
public Logger produceLog(InjectionPoint injectionPoint) {!
return
Logger.getLogger(injection...
@antoine_sd#CDIUni
@Decorator!
@Priority(Interceptor.Priority.APPLICATION)!
public class HelloDecorator implements HelloSe...
@antoine_sd#CDIUni
@InterceptorBinding!
@Target({METHOD, TYPE}) !
@Retention(RUNTIME)!
public @interface Loggable {}
Inter...
@antoine_sd#CDIUni
@Interceptor @Loggable !
public class LogInterceptor {!
  @AroundInvoke!
  public Object log(Invocation...
@antoine_sd#CDIUni
@Loggable!
public class MyBean {!
!
    @Inject HelloService service;!
!
    public void displayHello()...
@antoine_sd#CDIUni
@Inject Event<Post> evt;!
!
…!
!
evt.fire(new Post("John Doe ", "Hello", ));!
!
…!
!
public void receiv...
@YourTwitterHandle#DVXFR14{session hashtag} @antoine_sd#CDIUni
CDI
extension
@antoine_sd#CDIUni
Extension for what use ?
•To change CDI container meta-data:
•AnnotatedType
•InjectionPoint / Injection...
@antoine_sd#CDIUni
How to build a CDI extension
•Create a class implementing
javax.enterprise.inject.spi.Extension
!
•Add ...
@antoine_sd#CDIUni
public interface ProcessAnnotatedType<X> {

!
public AnnotatedType<X> getAnnotatedType();



public voi...
@antoine_sd#CDIUni
public class VetoEntity implements Extension {

/**

* Version CDI 1.0

*/

public void vetoEntityLegac...
@antoine_sd#CDIUni
Things to know
•Once application is bootstrapped, the Bean Manager is
in read only mode (no dynamic bea...
@antoine_sd#CDIUni
Example 2 : Add a Bean to CDI container
•There are many ways to add a bean to those
automatically disco...
@antoine_sd#CDIUni
public class HashMapAsBeanExtension implements Extension{



public void addHashMapAsAnnotatedType(@Obs...
@antoine_sd#CDIUni
@Decorator

@Priority(Interceptor.Priority.APPLICATION)

public abstract class MapDecorator implements ...
@antoine_sd#CDIUni
CDI 1.1 Lifecycle
Before Bean
Discovery
Process Bean
Process
Annotated
Type
Scan	

Archive
Application	...
@antoine_sd#CDIUni
Scheduler Extension1/4
•This extension example comes from Apache Deltaspike
project. It’s a simplified ...
@antoine_sd#CDIUni
public class SchedulerExtension implements Extension {

private List<Class> foundManagedJobClasses = ne...
@antoine_sd#CDIUni
Steps used in the extension
Before Bean
Discovery
Process Bean
Process
Annotated
Type
Scan	

Archive
Ap...
@antoine_sd#CDIUni
public interface Scheduler<T>

{

void start();



void stop();



void pauseJob(Class<? extends T> job...
@antoine_sd#CDIUni
@ApplicationScoped

public class SchedulerProducer

{

@Inject

private SchedulerExtension schedulerExt...
Prochain SlideShare
Chargement dans... 5
×

CDI 1.1 university

978

Published on

English version of my Devoxx France 2014 univeristy on CDI 1.1.

Published in: Technologies
0 commentaires
5 mentions J'aime
Statistiques
Remarques
  • Soyez le premier à commenter

Aucun téléchargement
Vues
Total des vues
978
Sur Slideshare
0
À partir des ajouts
0
Nombre d'ajouts
2
Actions
Partages
0
Téléchargements
28
Commentaires
0
J'aime
5
Ajouts 0
No embeds

No notes for slide

CDI 1.1 university

  1. 1. @antoine_sd#CDIUni CDI University @antoine_sd Red Hat, http://cdi-spec.org CDI specification leader
  2. 2. @antoine_sd#CDIUni Antoine Sabot-Durand •Senior Software Developer @Red Hat ! •Java & OSS : •CDI co-spec lead •CDI eco-system development •Tech Lead on Agorava ! •@antoine_sd •@cdispec
  3. 3. @YourTwitterHandle#DVXFR14{session hashtag} @antoine_sd#CDIUni CDI basics
  4. 4. @antoine_sd#CDIUni •CDI is a lot of things •Java EE IoC standard also working on Java SE •Context management •Observer pattern included •The « cement » between most Java EE spec •An evolution engine for Java EE thanks to portable extensions •All of this based on java strong typing Context & Dependency Injection
  5. 5. @antoine_sd#CDIUni CDI history & actual state •Main milestone : •December 2009 : CDI 1.0 •June 2013 : CDI 1.1 •April 2014 : CDI 1.2 •Summer 2014 : CDI 2.0 development starting •Implementations : •JBoss Weld (RI) : WildFly, JBoss EAP, Glassfish, Weblogic •Apache OpenWebBeans : TomEE, Websphere •Check http://cdi-spec.org
  6. 6. @antoine_sd#CDIUni CDI activated by default in Java EE 7 •In Java EE 6, you must add a beans.xml file to your archive •No need to in Java EE 7 but you can still to have an explicit activation (behave differently) beans.xml
  7. 7. @antoine_sd#CDIUni Bean •In Java EE 6 everything is a Managed Bean •Managed beans are basic components •They are managed by the container •They all have a lifecycle •They can be intercepted (AOP) •They can be injected •Accessible from outside CDI code.
  8. 8. @antoine_sd#CDIUni Dependency Injection @Inject
  9. 9. @antoine_sd#CDIUni public class HelloService {!     public String hello() {!         return "Hello World!";!     }! } Dependency Injection
  10. 10. @antoine_sd#CDIUni public class MyBean {! !     private HelloService service;! !     @Inject!     public MyBean(HelloService service) {!         this.service = service;!     }!     public void displayHello() {!         display( service.hello();!     }! } Dependency Injection in constructor
  11. 11. @antoine_sd#CDIUni public class MyBean {! !     private HelloService service;! !     @Inject!     public void setService(HelloService service) {!         this.service = service;!     }!     public void displayHello() {!         display( service.hello();!     }! } Dependency Injection in setter
  12. 12. @antoine_sd#CDIUni public class MyBean {! !     @Inject HelloService service;! !     public void displayHello() {!         display( service.hello();!     }! } Dependency Injection in field
  13. 13. @antoine_sd#CDIUni public interface HelloService {!     public String hello();! }! public class FrenchHelloService implements HelloService {!     public String hello() {!         return "Bonjour tout le monde!";!     }! }! public class EnglishHelloService implements HelloService {!     public String hello() {!         return "Hello World!";!     }! } Qualifiers
  14. 14. @antoine_sd#CDIUni @Qualifier! @Retention(RUNTIME)! @Target({FIELD, TYPE, METHOD, PARAMETER}) ! public @interface French {}! ! @Qualifier! @Retention(RUNTIME)! @Target({FIELD, TYPE, METHOD, PARAMETER}) ! public @interface English {} Qualifiers
  15. 15. @antoine_sd#CDIUni @French! public class FrenchHelloService implements HelloService {!     public String hello() {!         return "Bonjour tout le monde!";!     }! }! ! @English! public class EnglishHelloService implements HelloService {!     public String hello() {!         return "Hello World!";!     }! } Qualifiers
  16. 16. @antoine_sd#CDIUni public class MyBean {!     @Inject @French HelloService service;!     public void displayHello() {!         display( service.hello();!     }! }! public class MyBean {!     @Inject @English HelloService service;!     public void displayHello() {!         display( service.hello();!     }! } Qualifiers
  17. 17. @antoine_sd#CDIUni @Qualifier! @Retention(RUNTIME)! @Target({FIELD, TYPE, METHOD, PARAMETER}) ! public @interface Language {! !     Languages value();! ! @Nonbinding String description() default "";! !     public enum Languages { !         FRENCH, ENGLISH!     }! } Qualifiers with members
  18. 18. @antoine_sd#CDIUni @Language(FRENCH)! public class FrenchHelloService implements HelloService {!     public String hello() {!         return "Bonjour tout le monde!";!     }! }! @Language(ENGLISH)! public class EnglishHelloService implements HelloService {!     public String hello() {!         return "Hello World!";!     }! } Qualifiers
  19. 19. @antoine_sd#CDIUni public class MyBean {!     @Inject @Language(ENGLISH) HelloService service;!     public void displayHello() {!         display( service.hello();!     }! }! ! public class MyBean {!     @Inject @Language(FRENCH) HelloService service;!     public void displayHello() {!         display( service.hello();!     }! } Qualifiers
  20. 20. @antoine_sd#CDIUni public class MyBean {!     @Inject @French ! HelloService service;! }! ! @French @Console @Secured! public class FrenchHelloService implements HelloService {! ! } Qualifiers
  21. 21. @antoine_sd#CDIUni public class MyBean {!     @Inject @French @Console! HelloService service;! }! ! @French @Console @Secured! public class FrenchHelloService implements HelloService {! ! } Qualifiers
  22. 22. @antoine_sd#CDIUni public class MyBean {!     @Inject @French @Console @Secured ! HelloService service;! }! ! @French @Console @Secured! public class FrenchHelloService implements HelloService {! ! } Qualifiers
  23. 23. @antoine_sd#CDIUni public class MyBean {!     @Inject @French @Console @Secured ! HelloService service;! }! ! @French @Secured! public class FrenchHelloService implements HelloService {! ! } Qualifiers
  24. 24. @antoine_sd#CDIUni Reserved Qualifiers @Default! @Any! @Named
  25. 25. @antoine_sd#CDIUni public class MyBean {! !     @Inject Instance<HelloService> service;! !     public void displayHello() {!         display( service.get().hello() );!     }! } Programmatic lookup
  26. 26. @antoine_sd#CDIUni public class MyBean {! !     @Inject Instance<HelloService> service;! !     public void displayHello() {!         if (!service.isUnsatisfied()) {!             display( service.get().hello() );!         }!     }! } Programmatic lookup
  27. 27. @antoine_sd#CDIUni public class MyBean {! !     @Inject @Any Instance<HelloService> services;! !     public void displayHello() {!         for (HelloService service : services) {!             display( service.hello() );!         }!     }! } Programmatic lookup
  28. 28. @antoine_sd#CDIUni public class MyBean {! !     @Inject @Any Instance<HelloService> services;! !     public void displayHello() {!         display( !             service.select(! new AnnotationLiteral()<French> {})!                 .get() );!     }! } Programmatic lookup
  29. 29. @antoine_sd#CDIUni Contexts •Manage bean lifecycle •context helps container to choose when a bean should be generated and destroyed •it enforces the fact that a given bean is a singleton for a given context •Built-in CDI contexts : •@Dependent (default) •@RequestScoped •@SessionScoped •@ConversationScoped •@ApplicationScoped •@Singleton •You can create your own scope
  30. 30. @antoine_sd#CDIUni @SessionScoped! public class CartBean {! !     public void addItem(Item item) {! ...!     } ! } Contexts
  31. 31. @antoine_sd#CDIUni @ApplicationScoped! public class CartBean {! !     public void addItem(Item item) {! ...!     } ! } Contexts FAIL !!!
  32. 32. @antoine_sd#CDIUni @ConversationScoped! public class CartBean {! !     public void addItem(Item item) {! ...!     } ! } Contexts
  33. 33. @antoine_sd#CDIUni @ThreadScoped! public class CartBean {! !     public void addItem(Item item) {! ...!     } ! } Contexts
  34. 34. @antoine_sd#CDIUni @HourScoped! public class CartBean {! !     public void addItem(Item item) {! ...!     } ! } Contexts
  35. 35. @antoine_sd#CDIUni @RandomScoped! public class CartBean {! !     public void addItem(Item item) {! ...!     } ! } Contexts
  36. 36. @antoine_sd#CDIUni @Produces! public MyNonCDIClass myProducer() {! return new MyNonCdiClass();! }! ...! @Inject! MyNonCDIClass bean;! Producers
  37. 37. @antoine_sd#CDIUni @Produces! @RequestScoped! public FacesContext produceFacesContext() {! return FacesContext.getCurrentInstance();! } Producers
  38. 38. @antoine_sd#CDIUni @Produces! public Logger produceLog(InjectionPoint injectionPoint) {! return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());! } Producers
  39. 39. @antoine_sd#CDIUni @Decorator! @Priority(Interceptor.Priority.APPLICATION)! public class HelloDecorator implements HelloService {! !     @Inject @Delegate HelloService service;! !     public String hello() {!         return service.hello() + "-decorated";!     }! } Decorators
  40. 40. @antoine_sd#CDIUni @InterceptorBinding! @Target({METHOD, TYPE}) ! @Retention(RUNTIME)! public @interface Loggable {} Interceptors
  41. 41. @antoine_sd#CDIUni @Interceptor @Loggable ! public class LogInterceptor {!   @AroundInvoke!   public Object log(InvocationContext ic) throws Exception {!    System.out.println("Entering " + ic.getMethod().getName());!         try {!             return ic.proceed(); !         } finally {!             System.out.println("Exiting " + ic.getMethod().getName());!         }!     } ! } Interceptors
  42. 42. @antoine_sd#CDIUni @Loggable! public class MyBean {! !     @Inject HelloService service;! !     public void displayHello() {!         display( service.hello();!     }! } Interceptors
  43. 43. @antoine_sd#CDIUni @Inject Event<Post> evt;! ! …! ! evt.fire(new Post("John Doe ", "Hello", ));! ! …! ! public void receiveEvt(@Observes Post evt) {!     System.out.println("Received : " + evt.message());! } Events
  44. 44. @YourTwitterHandle#DVXFR14{session hashtag} @antoine_sd#CDIUni CDI extension
  45. 45. @antoine_sd#CDIUni Extension for what use ? •To change CDI container meta-data: •AnnotatedType •InjectionPoint / InjectionTarget •BeanAttributes/Beans •Producer •Observer ! •By observing the events triggered by CDI at boot time
  46. 46. @antoine_sd#CDIUni How to build a CDI extension •Create a class implementing javax.enterprise.inject.spi.Extension ! •Add some method that observes CDI lifecycle events to modify Bean Manager meta data ! •Add file :
 META-INF/services/javax.enterprise.inject.spi.Extension
 containing extension classname
  47. 47. @antoine_sd#CDIUni public interface ProcessAnnotatedType<X> {
 ! public AnnotatedType<X> getAnnotatedType();
 
 public void setAnnotatedType(AnnotatedType<X> type);
 
 public void veto();
 } ! public interface AnnotatedType<X> extends Annotated {
 
 public Class<X> getJavaClass();
 
 public Set<AnnotatedConstructor<X>> getConstructors();
 
 public Set<AnnotatedMethod<? super X>> getMethods();
 
 public Set<AnnotatedField<? super X>> getFields();
 For Instance •We can observe ProcessAnnotatedType event to change a type information or force the container to ignore it.
  48. 48. @antoine_sd#CDIUni public class VetoEntity implements Extension {
 /**
 * Version CDI 1.0
 */
 public void vetoEntityLegacy(@Observes ProcessAnnotatedType<?> pat) {
 AnnotatedType at = pat.getAnnotatedType();
 if (at.isAnnotationPresent(Entity.class))
 pat.veto(); 
 } /**
 * Version CDI 1.1+
 */
 public void vetoEntity(@Observes @WithAnnotations({Entity.class})ProcessAnnotatedType<?> pat) {
 pat.veto(); 
 } } Example 1 : Ignoring JPA entities •A commonly admitted good practice is to avoid using JPA entities as CDI beans. •This extension excludes entities from the set of types discovered by CDI.
  49. 49. @antoine_sd#CDIUni Things to know •Once application is bootstrapped, the Bean Manager is in read only mode (no dynamic bean registration) ! •Extensions are launched during bootstrap and are based on CDI events ! •You only have to @Observes built-in CDI event to create your extensions
  50. 50. @antoine_sd#CDIUni Example 2 : Add a Bean to CDI container •There are many ways to add a bean to those automatically discovered at boot time ! •The easier method is to add an AnnotatedType to those discovered by CDI.
  51. 51. @antoine_sd#CDIUni public class HashMapAsBeanExtension implements Extension{
 
 public void addHashMapAsAnnotatedType(@Observes BeforeBeanDiscovery bbd, BeanManager beanManager)
 {
 bbd.addAnnotatedType(beanManager.createAnnotatedType(HashMap.class));
 } 
 } Adding a HashMap Bean 1/2 •Observing BeforeBeanDiscovery event we can add a new AnnotatedType based on HashMap classe.
  52. 52. @antoine_sd#CDIUni @Decorator
 @Priority(Interceptor.Priority.APPLICATION)
 public abstract class MapDecorator implements Map{
 
 @Inject
 @Delegate
 Map delegate;
 
 @Override
 public Object put(Object key, Object value) {
 System.out.println("------- Putting Something in the Map -----------");
 if ("key".equals(key)) {
 System.out.println("==== Not adding key key ======");
 return null;
 } 
 return delegate.put(key,value);
 }
 } Adding a HashMap Bean 2/2 •Once created we can add CDI service on this HashMap bean. See that Decorator.
  53. 53. @antoine_sd#CDIUni CDI 1.1 Lifecycle Before Bean Discovery Process Bean Process Annotated Type Scan Archive Application Running After Deployment Validation Before Shutdown Undeploy Application Process Producer After Bean Discovery Process Injection Target Process Observer Method Process Injection Point Process Bean Attributes After Type Discovery événement unique événements multiples étape interne Deployment starts Bean eligibility check
  54. 54. @antoine_sd#CDIUni Scheduler Extension1/4 •This extension example comes from Apache Deltaspike project. It’s a simplified version. ! •We want to be able to schedule jobs from by using annotation @Schedule.
  55. 55. @antoine_sd#CDIUni public class SchedulerExtension implements Extension {
 private List<Class> foundManagedJobClasses = new ArrayList<Class>();
 private Scheduler scheduler;
 
 public <X> void findScheduledJobs(@Observes @WithAnnotations({ Scheduled.class }) ProcessAnnotatedType<X> pat) {
 Class<X> beanClass = pat.getAnnotatedType().getJavaClass();
 this.foundManagedJobClasses.add(beanClass);
 }
 
 public <X> void scheduleJobs(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager) {
 initScheduler(afterBeanDiscovery)
 List<String> foundJobNames = new ArrayList<String>();
 for (Class jobClass : this.foundManagedJobClasses) {
 foundJobNames.add(jobClass.getSimpleName());
 this.scheduler.registerNewJob(jobClass);
 }
 }
 
 public <X> void stopScheduler(@Observes BeforeShutdown beforeShutdown) {
 if (this.scheduler != null) {
 this.scheduler.stop();
 this.scheduler = null;
 }
 } private void initScheduler(AfterBeanDiscovery afterBeanDiscovery) {
 this.scheduler = new QuartzScheduler();
 this.scheduler.start();
 } } Scheduler extension 2/4 (extension code)
  56. 56. @antoine_sd#CDIUni Steps used in the extension Before Bean Discovery Process Bean Process Annotated Type Scan Archive Application Running After Deployment Validation Before Shutdown Undeploy Application Process Producer After Bean Discovery Process Injection Target Process Observer Method Process Injection Point Process Bean Attributes After Type Discovery occurs once occurs on each elt Internal step w/o hook Deployment starts Bean eligibility check
  57. 57. @antoine_sd#CDIUni public interface Scheduler<T>
 {
 void start();
 
 void stop();
 
 void pauseJob(Class<? extends T> jobClass);
 
 void resumeJob(Class<? extends T> jobClass);
 
 void interruptJob(Class<? extends T> jobClass);
 
 boolean isExecutingJob(Class<? extends T> jobClass);
 
 void registerNewJob(Class<? extends T> jobClass);
 
 void startJobManually(Class<? extends T> jobClass);
 
 <S> S unwrap(Class<? extends S> schedulerClass);
 } Scheduler Extension 3/4 (scheduler interface)
  58. 58. @antoine_sd#CDIUni @ApplicationScoped
 public class SchedulerProducer
 {
 @Inject
 private SchedulerExtension schedulerExtension;
 
 @Produces
 @ApplicationScoped
 protected Scheduler produceScheduler()
 {
 return this.schedulerExtension.getScheduler();
 }
 } Scheduler extension 4/4 (scheduler producer)
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×