当前位置: 首页>>代码示例>>Java>>正文


Java BeanProvider.getContextualReference方法代码示例

本文整理汇总了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();
}
 
开发者ID:gpein,项目名称:jcache-jee7,代码行数:18,代码来源:JCacheTest.java

示例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();
}
 
开发者ID:gpein,项目名称:jcache-jee7,代码行数:21,代码来源:JCacheTest.java

示例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);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:19,代码来源:MockAwareInjectionTargetWrapper.java

示例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());

}
 
开发者ID:apache,项目名称:deltaspike,代码行数:21,代码来源:ServletObjectInjectionServlet.java

示例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);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:24,代码来源:ScopedPartialBeanTest.java

示例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());
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:17,代码来源:SecuredAnnotationTest.java

示例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;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:25,代码来源:CdiQueryInvocationContext.java

示例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);
    }
}
 
开发者ID:adminfaces,项目名称:admin-persistence,代码行数:8,代码来源:CrudMB.java

示例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();
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:10,代码来源:Worker.java

示例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();
    }
}
 
开发者ID:guhilling,项目名称:cdi-test,代码行数:14,代码来源:CallRedirectionInterceptor.java

示例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);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:38,代码来源:SecurityUtils.java

示例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);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:11,代码来源:ExcludeTestProjectStageDevelopment.java

示例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());
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:9,代码来源:InjectableConfigPropertyTest.java

示例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
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:12,代码来源:SecurityBindingTest.java

示例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);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:33,代码来源:DeltaSpikeContextExtension.java


注:本文中的org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。