This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
//starts the container once and one session + request per test-method | |
@RunWith(CdiTestRunner.class) | |
public class ContainerAndInjectionControl | |
{ | |
@Inject | |
private ApplicationScopedBean applicationScopedBean; | |
@Inject | |
private SessionScopedBean sessionScopedBean; |
This file contains hidden or 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 MyActor extends UntypedActor | |
{ | |
@Inject | |
private MyService myService; | |
@Override | |
public void onReceive(Object o) throws Exception | |
{ | |
myService.process(/*...*/); | |
} |
This file contains hidden or 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
/* | |
* Licensed to the Apache Software Foundation (ASF) under one | |
* or more contributor license agreements. See the NOTICE file | |
* distributed with this work for additional information | |
* regarding copyright ownership. The ASF licenses this file | |
* to you under the Apache License, Version 2.0 (the | |
* "License"); you may not use this file except in compliance | |
* with the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |