本文整理汇总了Java中org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference方法的典型用法代码示例。如果您正苦于以下问题:Java BeanProvider.getContextualReference方法的具体用法?Java BeanProvider.getContextualReference怎么用?Java BeanProvider.getContextualReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.deltaspike.core.api.provider.BeanProvider
的用法示例。
在下文中一共展示了BeanProvider.getContextualReference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: should_hit_cache
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
@Test
public void should_hit_cache() {
CacheableService service = BeanProvider.getContextualReference(CacheableService.class);
assertThat(service.get(1L, "1st call")).isEqualTo("1 1st call");
assertThat(service.get(2L, "1st call")).isEqualTo("2 1st call");
assertThat(service.get(1L, "2nd call")).isEqualTo("1 1st call");
assertThat(service.get(1L, "3rd call")).isEqualTo("1 1st call");
assertThat(service.get(2L, "2nd call")).isEqualTo("2 1st call");
CallCounter callCounter = BeanProvider.getContextualReference(CallCounter.class);
assertThat(callCounter.calls()).isEqualTo(2);
service.removeAll();
callCounter.reset();
}
示例2: should_evict_cache
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
@Test
public void should_evict_cache() {
CacheableService service = BeanProvider.getContextualReference(CacheableService.class);
assertThat(service.get(1L, "1st call")).isEqualTo("1 1st call");
assertThat(service.get(1L, "2nd call")).isEqualTo("1 1st call");
assertThat(service.get(2L, "1st call")).isEqualTo("2 1st call");
service.update(1L, "update");
assertThat(service.get(1L, "3rd call")).isEqualTo("1 3rd call");
assertThat(service.get(2L, "2nd call")).isEqualTo("2 1st call");
CallCounter callCounter = BeanProvider.getContextualReference(CallCounter.class);
assertThat(callCounter.calls()).isEqualTo(3);
service.removeAll();
callCounter.reset();
}
示例3: produce
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
@Override
public T produce(CreationalContext<T> creationalContext)
{
DynamicMockManager mockManager =
BeanProvider.getContextualReference(this.beanManager, DynamicMockManager.class, false);
for (Type beanType : this.beanTypes)
{
Object mockInstance = mockManager.getMock(
(Class)beanType, this.qualifiers.toArray(new Annotation[this.qualifiers.size()]));
if (mockInstance != null)
{
return (T)mockInstance;
}
}
return wrapped.produce(creationalContext);
}
示例4: doGet
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
/*
* The ServletObjectInjectionBean is manually looked up using BeanProvider because not all containers may
* support injection into servlets.
*/
ServletObjectInjectionBean bean =
BeanProvider.getContextualReference(ServletObjectInjectionBean.class);
ServletOutputStream stream = resp.getOutputStream();
logDetails(stream, "ServletRequest", bean.getServletRequest());
logDetails(stream, "HttpServletRequest", bean.getHttpServletRequest());
logDetails(stream, "ServletResponse", bean.getServletResponse());
logDetails(stream, "HttpServletResponse", bean.getHttpServletResponse());
logDetails(stream, "HttpSession", bean.getHttpSession());
logDetails(stream, "Principal", bean.getPrincipal());
}
示例5: testPartialBeanWithApplicationScope
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
@Test
public void testPartialBeanWithApplicationScope() throws Exception
{
// this test is known to not work under OWB 1.2.0 till 1.2.7 - see OWB #1036
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_OWB_1_2_x_BEFORE_1_2_8)
&& !CdiContainerUnderTest.is(CONTAINER_TOMEE_1_7_x));
ApplicationScopedPartialBean bean = BeanProvider.getContextualReference(ApplicationScopedPartialBean.class);
String result = bean.willFail();
Assert.assertEquals("partial-test-false", result);
String result2 = bean.willFail2();
Assert.assertEquals("partial-test-false", result2);
int count = bean.getManualResult();
Assert.assertEquals(0, count);
count = bean.getManualResult();
Assert.assertEquals(1, count);
}
示例6: invocationOfMultipleSecuredStereotypes
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
@Test
public void invocationOfMultipleSecuredStereotypes()
{
SecuredBean4 testBean = BeanProvider.getContextualReference(SecuredBean4.class, false);
TestAccessDecisionVoter1 voter1 = BeanProvider.getContextualReference(TestAccessDecisionVoter1.class, false);
TestAccessDecisionVoter2 voter2 = BeanProvider.getContextualReference(TestAccessDecisionVoter2.class, false);
Assert.assertFalse(voter1.isCalled());
Assert.assertFalse(voter2.isCalled());
Assert.assertEquals("result", testBean.getResult());
Assert.assertTrue(voter1.isCalled());
Assert.assertTrue(voter2.isCalled());
}
示例7: getQueryInOutMapper
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
public QueryInOutMapper<?> getQueryInOutMapper()
{
if (repositoryMethodMetadata.getQueryInOutMapperClass() == null)
{
return null;
}
QueryInOutMapper<?> result = null;
if (repositoryMethodMetadata.isQueryInOutMapperIsNormalScope())
{
result = BeanProvider.getContextualReference(repositoryMethodMetadata.getQueryInOutMapperClass());
}
else
{
DependentProvider<? extends QueryInOutMapper<?>> mappedProvider =
BeanProvider.getDependent(repositoryMethodMetadata.getQueryInOutMapperClass());
result = mappedProvider.get();
this.addDestroyable(new DependentProviderDestroyable(mappedProvider));
}
return result;
}
示例8: initServiceViaAnnotation
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
private void initServiceViaAnnotation() {
if(getClass().isAnnotationPresent(BeanService.class)) {
BeanService beanService = getClass().getAnnotation(BeanService.class);
Class<? extends CrudService> serviceClass = beanService.value();
crudService = BeanProvider.getContextualReference(serviceClass);
}
}
示例9: startCamel
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
private void startCamel() {
camelActivator = BeanProvider.getContextualReference(CamelActivator.class, false);
// Register a route for each tool on the class path
List<Tool> tools = BeanProvider.getContextualReferences(Tool.class, true);
camelActivator.registerRoutes(tools);
camelActivator.start();
}
示例10: callAlternative
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
private Object callAlternative(InvocationContext ctx, Class<?> javaClass) throws Throwable {
try {
Object alternative = BeanProvider
.getContextualReference(invocationTargetManager.get().alternativeFor(javaClass));
Method method = ctx.getMethod();
Method alternativeMethod = alternative.getClass().getMethod(method.getName(), method.getParameterTypes());
return alternativeMethod.invoke(alternative, ctx.getParameters());
} catch (NoSuchMethodException nme) {
return callMock(ctx, javaClass);
} catch (InvocationTargetException ite) {
throw ite.getCause();
}
}
示例11: tryToHandleSecurityViolation
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
private static void tryToHandleSecurityViolation(RuntimeException runtimeException,
boolean allowNavigation)
{
ErrorViewAwareAccessDeniedException exception = extractException(runtimeException);
if (exception == null)
{
throw runtimeException;
}
Class<? extends ViewConfig> errorView = null;
Class<? extends ViewConfig> inlineErrorView = exception.getErrorView();
if (inlineErrorView != null && !DefaultErrorView.class.getName().equals(inlineErrorView.getName()))
{
errorView = inlineErrorView;
}
if (errorView == null)
{
ViewConfigResolver viewConfigResolver = BeanProvider.getContextualReference(ViewConfigResolver.class);
ViewConfigDescriptor errorPageDescriptor = viewConfigResolver.getDefaultErrorViewConfigDescriptor();
if (errorPageDescriptor != null)
{
errorView = errorPageDescriptor.getConfigClass();
}
}
if (errorView == null && allowNavigation)
{
throw exception;
}
processApplicationSecurityException(exception, errorView, allowNavigation);
}
示例12: includeInCaseOfProjectStageDevelopment
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
/**
* bean included in case of project-stage development
*/
@Test
public void includeInCaseOfProjectStageDevelopment()
{
DevBean devBean = BeanProvider.getContextualReference(DevBean.class, true);
Assert.assertNotNull(devBean);
}
示例13: testNmberConfigInjection
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
@Test
public void testNmberConfigInjection()
{
NumberConfiguredBean numberBean = BeanProvider.getContextualReference(NumberConfiguredBean.class, false);
assertNull(numberBean.getPropertyNonexisting());
assertEquals(Float.valueOf(123.45f), numberBean.getPropertyFromConfig());
assertEquals(Float.valueOf(42.42f), numberBean.getPropertyNonexistingDefaulted());
}
示例14: simpleInterceptorTestParentDenied
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
@Test
public void simpleInterceptorTestParentDenied()
{
SecuredBean1 testBean = BeanProvider.getContextualReference(SecuredBean1.class, false);
try {
testBean.someBlockedMethodFromParent();
Assert.fail();
} catch (AccessDeniedException e) {
//expected
}
}
示例15: initializeDeltaSpikeContexts
import org.apache.deltaspike.core.api.provider.BeanProvider; //导入方法依赖的package包/类
/**
* We can only initialize our contexts in AfterDeploymentValidation because
* getBeans must not be invoked earlier than this phase to reduce randomness
* caused by Beans no being fully registered yet.
*/
public void initializeDeltaSpikeContexts(@Observes AfterDeploymentValidation adv, BeanManager beanManager)
{
if (!isActivated)
{
return;
}
WindowBeanHolder windowBeanHolder =
BeanProvider.getContextualReference(beanManager, WindowBeanHolder.class, false);
WindowIdHolder windowIdHolder =
BeanProvider.getContextualReference(beanManager, WindowIdHolder.class, false);
windowContext.init(windowBeanHolder, windowIdHolder);
ConversationBeanHolder conversationBeanHolder =
BeanProvider.getContextualReference(beanManager, ConversationBeanHolder.class, false);
conversationContext.init(conversationBeanHolder);
ViewAccessBeanHolder viewAccessBeanHolder =
BeanProvider.getContextualReference(beanManager, ViewAccessBeanHolder.class, false);
ViewAccessBeanAccessHistory viewAccessBeanAccessHistory =
BeanProvider.getContextualReference(beanManager, ViewAccessBeanAccessHistory.class, false);
ViewAccessViewHistory viewAccessViewHistory =
BeanProvider.getContextualReference(beanManager, ViewAccessViewHistory.class, false);
viewAccessScopedContext.init(viewAccessBeanHolder, viewAccessBeanAccessHistory, viewAccessViewHistory);
}