• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BeanProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.deltaspike.core.api.provider.BeanProvider的典型用法代码示例。如果您正苦于以下问题:Java BeanProvider类的具体用法?Java BeanProvider怎么用?Java BeanProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BeanProvider类属于org.apache.deltaspike.core.api.provider包,在下文中一共展示了BeanProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: execute

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
/**
 * Executes the pipeline stage with the given pipeline context and returns the result.
 * <p>
 * Invokes the prepare method on the stage and returns the result. The stage is invoked in it's own transaction. If an exception is caught the transaction is rolled back and the stage is marked
 * as FAILED.
 * </p>
 *
 * @param pipelineContext
 *         the pipeline context
 * @param pipelineStage
 *         the pipeline stage class
 * @return a {@link PipelineStageResult}
 */
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public PipelineStageResult execute(PipelineContext pipelineContext, Class<PipelineStage> pipelineStage) {
    DependentProvider<PipelineStage> dependentProvider = null;
    try {
        logBefore(pipelineContext, pipelineStage, "preparing");
        dependentProvider = BeanProvider.getDependent(pipelineStage);
        PipelineStageResult result = dependentProvider.get().prepare(pipelineContext);
        logAfter(pipelineContext, pipelineStage, result);
        return result;
    } catch (Exception e) {
        ejbContext.setRollbackOnly();

        String message = "Pipeline execution failed at stage " + pipelineStage.getName() + ". Reason " + e.getMessage();
        LOGGER.error(message, e);
        return PipelineStageResult.builder(pipelineContext.getPipelineId(), PipelineStageStatus.FAILED).addMessages(ImmutableSet.of(message)).build();
    } finally {
        if (dependentProvider != null) {
            dependentProvider.destroy();
        }
    }
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:35,代码来源:PipelineStageExecutor.java


示例2: onCallback

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
/**
 * Executes the pipeline stage with the given pipeline context and callback event before returning the result.
 * <p>
 * Invoke the callback method on the stage and returns the result. The stage is invoked in it's own transaction. If an exception is caught the transaction is rolled back and the stage is marked
 * as FAILED.
 * </p>
 *
 * @param pipelineContext
 *         the pipeline context
 * @param pipelineStage
 *         the pipeline stage
 * @param callbackEvent
 *         the callback event
 * @return a {@link PipelineStageResult}
 */
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public PipelineStageResult onCallback(PipelineContext pipelineContext, Class<PipelineStage> pipelineStage, CallbackEvent callbackEvent) {
    DependentProvider<PipelineStage> dependentProvider = null;
    try {
        logBefore(pipelineContext, pipelineStage, "resuming");
        dependentProvider = BeanProvider.getDependent(pipelineStage);
        PipelineStageResult result = dependentProvider.get().onCallback(pipelineContext, callbackEvent);
        logAfter(pipelineContext, pipelineStage, result);
        return result;
    } catch (Exception e) {
        ejbContext.setRollbackOnly();

        String message = "Pipeline execution failed at stage " + pipelineStage.getName() + ". Reason " + e.getMessage();
        LOGGER.error(message, e);
        return PipelineStageResult.builder(pipelineContext.getPipelineId(), PipelineStageStatus.FAILED).addMessages(ImmutableSet.of(message)).build();
    } finally {
        if (dependentProvider != null) {
            dependentProvider.destroy();
        }
    }
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:37,代码来源:PipelineStageExecutor.java


示例3: onFailure

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void onFailure(PipelineContext pipelineContext, Class<PipelineFailureStage> pipelineFailureStage) {
    DependentProvider<PipelineFailureStage> dependentProvider = null;
    try {
        LOGGER.debug("executing pipeline failure stage " + pipelineFailureStage.getName());
        dependentProvider = BeanProvider.getDependent(pipelineFailureStage);
        dependentProvider.get().onFailure(pipelineContext);
        LOGGER.debug("executed pipeline failure stage " + pipelineFailureStage.getName());
    } catch (Exception e) {
        ejbContext.setRollbackOnly();
        String message = "Failed to execute pipeline failure stage " + pipelineFailureStage.getName() + ". Reason " + e.getMessage();
        LOGGER.error(message, e);

    } finally {
        if (dependentProvider != null) {
            dependentProvider.destroy();
        }
    }
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:20,代码来源:PipelineStageExecutor.java


示例4: 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


示例5: 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


示例6: setUp

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
@Before
public final void setUp() throws Exception {
    System.out.printf("AbstractCdiContainerTest#setUp() containerRefCount=%d, cdiContainer=%s\n", containerRefCount.get(), cdiContainer );

    if ( cdiContainer != null ) {
        containerRefCount.incrementAndGet();

        final ContextControl ctxCtrl = BeanProvider.getContextualReference(ContextControl.class);

        //stop the RequestContext to dispose of the @RequestScoped EntityManager
        ctxCtrl.stopContext(RequestScoped.class);

        //immediately restart the context again
        ctxCtrl.startContext(RequestScoped.class);

        // perform injection into the very own test class
        final BeanManager beanManager = cdiContainer.getBeanManager();
        final CreationalContext creationalContext = beanManager.createCreationalContext(null);

        final AnnotatedType annotatedType = beanManager.createAnnotatedType(this.getClass());
        final InjectionTarget injectionTarget = beanManager.createInjectionTarget(annotatedType);
        injectionTarget.inject(this, creationalContext);
    }
}
 
开发者ID:peterpilgrim,项目名称:javaee7-developer-handbook,代码行数:25,代码来源:AbstractCdiContainerTest.java


示例7: tearDown

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
@After
    public final void tearDown() throws Exception {
        System.out.printf("AbstractCdiContainerTest#tearDown() containerRefCount=%d, cdiContainer=%s\n", containerRefCount.get(), cdiContainer );
        if (cdiContainer != null) {
            final ContextControl ctxCtrl = BeanProvider.getContextualReference(ContextControl.class);

            //stop the RequestContext to dispose of the @RequestScoped EntityManager
            ctxCtrl.stopContext(RequestScoped.class);

            //immediately restart the context again
            ctxCtrl.startContext(RequestScoped.class);

//            cdiContainer.getContextControl().stopContext(RequestScoped.class);
//            cdiContainer.getContextControl().startContext(RequestScoped.class);
            containerRefCount.decrementAndGet();
        }
    }
 
开发者ID:peterpilgrim,项目名称:javaee7-developer-handbook,代码行数:18,代码来源:AbstractCdiContainerTest.java


示例8: createTest

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
@Override
protected Object createTest() throws Exception
{
    BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();

    Class<?> type = getTestClass().getJavaClass();
    Set<Bean<?>> beans = beanManager.getBeans(type);

    Object result;
    if (!USE_TEST_CLASS_AS_CDI_BEAN || beans == null || beans.isEmpty())
    {
        result = super.createTest();
        BeanProvider.injectFields(result); //fallback to simple injection
    }
    else
    {
        Bean<Object> bean = (Bean<Object>) beanManager.resolve(beans);
        CreationalContext<Object> creationalContext = beanManager.createCreationalContext(bean);
        result = beanManager.getReference(bean, type, creationalContext);
    }
    return result;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:23,代码来源:CdiTestRunner.java


示例9: 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,代码行数:20,代码来源:MockAwareProducerWrapper.java


示例10: finalCheck

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
@AfterClass
public static void finalCheck()
{
    int value = BeanProvider.getContextualReference(ApplicationScopedTestBean.class).getValue();
    int nextValue = BeanProvider.getContextualReference(ApplicationScopedTestBeanClient.class).getNextValue();

    if (value == 0)
    {
        throw new IllegalStateException("new application-scoped bean instance was created");
    }

    if (nextValue == 1)
    {
        throw new IllegalStateException("new application-scoped bean instance was created");
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:17,代码来源:ApplicationScopedBeanTest.java


示例11: injectionViaConfigProperty

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
@Test
public void injectionViaConfigProperty()
{
    SettingsBean settingsBean = BeanProvider.getContextualReference(SettingsBean.class, false);

    assertEquals(14, settingsBean.getProperty1());
    assertEquals(7L, settingsBean.getProperty2());
    assertEquals(-7L, settingsBean.getInverseProperty2());

    // also check the ones with defaultValue
    assertEquals("14", settingsBean.getProperty3Filled());
    assertEquals("myDefaultValue", settingsBean.getProperty3Defaulted());
    assertEquals(42, settingsBean.getProperty4Defaulted());

    assertEquals("some setting for prodDB", settingsBean.getDbConfig());
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:17,代码来源:InjectableConfigPropertyTest.java


示例12: finalCheckAndCleanup

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
@AfterClass
public static void finalCheckAndCleanup()
{
    int testCount = TestUtils.getTestMethodCount(SessionScopePerTestClassTest.class);

    if (RequestScopedBean.getInstanceCount() != testCount)
    {
        throw new IllegalStateException("unexpected instance count");
    }
    RequestScopedBean.resetInstanceCount();

    if (BeanProvider.getContextualReference(ApplicationScopedBean.class).getCount() != testCount)
    {
        throw new IllegalStateException("unexpected count");
    }

    if (BeanProvider.getContextualReference(SessionScopedBean.class).getCount() != testCount)
    {
        throw new IllegalStateException("unexpected count");
    }
    BeanProvider.getContextualReference(ApplicationScopedBean.class).resetCount();
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:23,代码来源:SessionScopePerTestClassTest.java


示例13: 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


示例14: 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


示例15: notify

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void notify(final ExceptionEvent<T> event, BeanManager beanManager) throws Exception
{
    CreationalContext<?> ctx = null;
    try
    {
        ctx = beanManager.createCreationalContext(null);
        @SuppressWarnings("unchecked")
        Object handlerInstance = BeanProvider.getContextualReference(declaringBeanClass);
        InjectableMethod<?> im = createInjectableMethod(handler, getDeclaringBean(), beanManager);
        im.invoke(handlerInstance, ctx, new OutboundParameterValueRedefiner(event, this));
    }
    finally
    {
        if (ctx != null)
        {
            ctx.release();
        }
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:24,代码来源:HandlerMethodImpl.java


示例16: resolveUserTransaction

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
protected UserTransaction resolveUserTransaction()
{
    //manual lookup needed because injecting UserTransactionResolver can fail (see the comment there)
    try
    {
        DependentProvider<UserTransactionResolver> provider =
            BeanProvider.getDependent(this.beanManager, UserTransactionResolver.class);

        UserTransaction userTransaction = provider.get().resolveUserTransaction();

        provider.destroy();
        return userTransaction;
    }
    catch (Exception e)
    {
        return null;
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:19,代码来源:BeanManagedUserTransactionStrategy.java


示例17: getContextualReference

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
private static <T> T getContextualReference(BeanManager beanManager, Class<T> type)
{
    Set<Bean<?>> beans = beanManager.getBeans(type);

    if (beans == null || beans.isEmpty())
    {
        return null;
    }

    Bean<?> bean = beanManager.resolve(beans);

    CreationalContext<?> creationalContext = beanManager.createCreationalContext(bean);

    @SuppressWarnings({ "unchecked", "UnnecessaryLocalVariable" })
    T result = (T) beanManager.getReference(bean, type, creationalContext);

    if (bean.getScope().equals(Dependent.class))
    {
        AbstractBeanStorage beanStorage = BeanProvider.getContextualReference(RequestDependentBeanStorage.class);

        //noinspection unchecked
        beanStorage.add(new DependentBeanEntry(result, bean, creationalContext));
    }

    return result;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:27,代码来源:ManagedArtifactResolver.java


示例18: init

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
private synchronized void init()
{
    // switch into paranoia mode
    if (this.initialized == null)
    {
        if (ClassDeactivationUtils.isActivated(getClass()))
        {
            this.securityAwareViewHandler = createSecurityAwareViewHandler();
        }
        else
        {
            this.securityAwareViewHandler = null;
        }

        this.clientWindow = BeanProvider.getContextualReference(ClientWindow.class, true);
        
        this.initialized = true;
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:20,代码来源:DeltaSpikeViewHandler.java


示例19: init

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
private synchronized void init()
{
    // switch into paranoia mode
    if (this.initialized == null)
    {
        if (ClassDeactivationUtils.isActivated(JsfRequestBroadcaster.class))
        {
            this.jsfRequestBroadcaster =
                    BeanProvider.getContextualReference(JsfRequestBroadcaster.class, true);
        }

        clientWindow = BeanProvider.getContextualReference(ClientWindow.class, true);
        windowContext = BeanProvider.getContextualReference(WindowContext.class, true);
        contextExtension = BeanProvider.getContextualReference(DeltaSpikeContextExtension.class, true);
        
        this.initialized = true;
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:19,代码来源:DeltaSpikeLifecycleWrapper.java


示例20: checkSecuredView

import org.apache.deltaspike.core.api.provider.BeanProvider; //导入依赖的package包/类
private void checkSecuredView(FacesContext facesContext)
{
    if (!this.securityModuleActivated)
    {
        return;
    }

    try
    {
        BeanProvider.getContextualReference(ViewRootAccessHandler.class).checkAccessTo(facesContext.getViewRoot());
    }
    catch (ErrorViewAwareAccessDeniedException accessDeniedException)
    {
        SecurityUtils.tryToHandleSecurityViolation(accessDeniedException);
        facesContext.renderResponse();
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:18,代码来源:DeltaSpikePhaseListener.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PaymentConfirmation类代码示例发布时间:2022-05-21
下一篇:
Java X509Data类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap