This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Scheduled(cronExpression = "0 0/10 * * * ?") | |
public class CdiAwareQuartzJob implements org.quartz.Job | |
{ | |
@Inject | |
private MyService service; | |
@Override | |
public void execute(JobExecutionContext context) | |
throws JobExecutionException | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ApplicationScoped | |
public class SchedulerController | |
{ | |
@Inject | |
private Scheduler<Job> jobScheduler; | |
public void onPause(@Observes PauseJobEvent /*custom event*/ jobEvent) | |
{ | |
//using it with events is optional | |
this.jobScheduler.pauseJob(jobEvent.getJobClass()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ApplicationScoped | |
public class ProjectStageAwareSchedulerController | |
{ | |
@Inject | |
private Scheduler<Job> jobScheduler; | |
@Inject | |
private ProjectStage projectStage; | |
public void registerJobs() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ViewConfigValidator implements ServletContextListener | |
{ | |
@Override | |
public void contextInitialized(ServletContextEvent sce) | |
{ | |
ViewConfigResolver viewConfigResolver = | |
BeanProvider.getContextualReference(ViewConfigResolver.class); | |
for (ConfigDescriptor configDescriptor : | |
viewConfigResolver.getConfigDescriptors()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(CdiTestRunner.class) | |
public class InjectionTest | |
{ | |
@Inject | |
private MyCdiBean bean1; | |
@EJB //or @Inject | |
private MyEjb bean2; | |
@Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MonitoredMethodInvocationProcessor | |
{ | |
//... | |
public void onMonitoredMethodInvocations(@Observes MonitoredMethodInvocationsEvent methodInvocationsEvent) | |
{ | |
String userId = this.userHolder.getCurrentUserId(); | |
for (MethodInvocationDescriptor methodInvocation : methodInvocationsEvent.getMethodInvocationDescriptors()) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(CdiTestRunner.class) | |
public class ManuallyMockedCdiBeanTest | |
{ | |
@Inject | |
private MyCdiBean myCdiBean; | |
@Inject | |
private DynamicMockContext mockContext; | |
@Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestScoped | |
public class MyCdiBean | |
{ | |
private int count = 0; | |
public int getCount() | |
{ | |
return count; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(CdiTestRunner.class) | |
public class MockitoMockedCdiBeanTest | |
{ | |
@Inject | |
private MyCdiBean myCdiBean; | |
@Inject | |
private DynamicMockContext mockContext; | |
@Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ApplicationScoped | |
public class AsyncObserver | |
{ | |
public void onEvent(@ObservesAsynchronous MyEvent event) | |
{ | |
//... | |
} | |
} |