Java Examples for javax.enterprise.inject.spi.CDI

The following java examples will help you to understand the usage of javax.enterprise.inject.spi.CDI. These source code samples are taken from different open source projects.

Example 1
Project: nowellpoint-sdk-oauth-master  File: BeanManagerLookup.java View source code
public static BeanManager getBeanManager() {
    try {
        return CDI.current().getBeanManager();
    } catch (Exception ignore) {
    }
    try {
        return (BeanManager) InitialContext.doLookup("java:comp/BeanManager");
    } catch (Exception ignore) {
    }
    try {
        return (BeanManager) InitialContext.doLookup("java:comp/env/BeanManager");
    } catch (Exception ignore) {
    }
    return null;
}
Example 2
Project: trimou-master  File: BeanManagerLocator.java View source code
private static BeanManager locateCDI11() {
    BeanManager beanManager = null;
    ClassLoader classLoader = SecurityActions.getContextClassLoader();
    Class<?> cdiClass = null;
    try {
        cdiClass = classLoader.loadClass(CDI_CLASS_NAME);
        LOGGER.info("CDI 1.1 - using javax.enterprise.inject.spi.CDI to obtain BeanManager instance");
    } catch (ClassNotFoundExceptionNoClassDefFoundError |  ignored) {
    }
    if (cdiClass != null) {
        try {
            Object cdi = SecurityActions.getMethod(cdiClass, "current").invoke(null);
            beanManager = (BeanManager) SecurityActions.getMethod(cdiClass, "getBeanManager").invoke(cdi);
        } catch (Exception e) {
            LOGGER.warn("Unable to invoke CDI.current().getBeanManager()", e);
        }
    }
    return beanManager;
}
Example 3
Project: narayana-master  File: BeanManagerUtil.java View source code
@SuppressWarnings("unchecked")
public static <T> T createBeanInstance(Class<T> clazz, BeanManager beanManager) {
    BeanManager classBeanManager = getClassBeanManager(clazz, beanManager);
    Bean<T> bean = (Bean<T>) classBeanManager.resolve(classBeanManager.getBeans(clazz));
    if (bean == null) {
        throw new IllegalStateException("CDI BeanManager cannot find an instance of requested type " + clazz.getName());
    }
    CreationalContext<T> context = classBeanManager.createCreationalContext(bean);
    return (T) classBeanManager.getReference(bean, clazz, context);
}
Example 4
Project: Resteasy-master  File: CdiInjectorFactory.java View source code
public static BeanManager lookupBeanManagerCDIUtil() {
    BeanManager bm = null;
    try {
        bm = CDI.current().getBeanManager();
    } catch (NoClassDefFoundError e) {
        LogMessages.LOGGER.debug(Messages.MESSAGES.unableToFindCDIClass(), e);
    } catch (Exception e) {
        LogMessages.LOGGER.debug(Messages.MESSAGES.errorOccurredLookingUpViaCDIUtil(), e);
    }
    return bm;
}
Example 5
Project: confit-master  File: ConfigCdiContext.java View source code
@Override
public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) {
    Bean<T> bean = (Bean<T>) contextual;
    cctx = creationalContext;
    if (ctx == null) {
        ctx = CDI.current().select(ConfigContext.class).get();
    }
    final Object object;
    if (cache.containsKey(bean.getBeanClass())) {
        object = cache.get(bean.getBeanClass());
    } else {
        object = ctx.get(bean.getBeanClass());
        cache.put(bean.getBeanClass(), object);
    }
    return (T) object;
}
Example 6
Project: aries-master  File: CdiContainerTests.java View source code
public void testGetBeanManagerFromCDI() throws Exception {
    Thread currentThread = Thread.currentThread();
    ClassLoader contextClassLoader = currentThread.getContextClassLoader();
    try {
        BundleWiring bundleWiring = cdiBundle.adapt(BundleWiring.class);
        currentThread.setContextClassLoader(bundleWiring.getClassLoader());
        BeanManager beanManager = CDI.current().getBeanManager();
        assertNotNull(beanManager);
        assertPojoExists(beanManager);
    } finally {
        currentThread.setContextClassLoader(contextClassLoader);
    }
}
Example 7
Project: core-master  File: DestroyingNormalScopedInstanceTest.java View source code
@Category(Integration.class)
@Test
public void testSFSessionBeanDependentDestroy() {
    SFSessionBean.DESTROYED.set(false);
    Instance<SFSessionBean> sessionBeanInstance = CDI.current().select(SFSessionBean.class);
    SFSessionBean sessionBean = sessionBeanInstance.get();
    sessionBean.ping();
    sessionBeanInstance.destroy(sessionBean);
    assertTrue(SFSessionBean.DESTROYED.get());
}
Example 8
Project: hammock-master  File: JettyWebServer.java View source code
private static ServletContextListener getOrCreateListener(Class<? extends ServletContextListener> clazz) {
    try {
        return CDI.current().select(clazz).get();
    } catch (Exception e) {
        try {
            return clazz.newInstance();
        } catch (ReflectiveOperationException e1) {
            throw new RuntimeException("Unable to instantiate listener " + clazz + " " + e1.getMessage() + " " + e.getMessage(), e);
        }
    }
}
Example 9
Project: idnadrev-master  File: AsciiDocEditor.java View source code
public static CompletableFuture<DefaultLoader<Node, AsciiDocEditor>> load(Consumer<StackPane> viewConsumer, Consumer<AsciiDocEditor> controllerConsumer) {
    ActivityInitialization initialization = CDI.current().select(ActivityInitialization.class).get();
    return //
    initialization.loadAdditionalControllerWithFuture(AsciiDocEditor.class).thenApply( loader -> {
        viewConsumer.accept((StackPane) loader.getView());
        controllerConsumer.accept(loader.getController());
        return loader;
    });
}
Example 10
Project: resteasy-netty-cdi-master  File: CdiInjectorFactory.java View source code
@Override
public ConstructorInjector createConstructor(ResourceConstructor constructor, ResteasyProviderFactory providerFactory) {
    Class<?> clazz = constructor.getConstructor().getDeclaringClass();
    ConstructorInjector injector = cdiConstructor(clazz);
    if (injector != null)
        return injector;
    log.debug("No CDI beans found for " + clazz + ". Using default ConstructorInjector.");
    return delegate.createConstructor(constructor, providerFactory);
}
Example 11
Project: restful-and-beyond-tut2184-master  File: UndertowComponent.java View source code
public UndertowComponent start(Map<String, Object> servletContextAttributes) {
    List<ListenerInfo> listenerInfoList = listeners.stream().map(Servlets::listener).collect(Collectors.toList());
    List<ServletInfo> servletInfoList = servlets.entrySet().stream().map(servletInfoFunction).collect(Collectors.toList());
    List<FilterInfo> filterInfoList = filters.entrySet().stream().map(filterInfoFunction).collect(Collectors.toList());
    CDIClassIntrospecter introspecter = CDI.current().select(CDIClassIntrospecter.class).get();
    DeploymentInfo di = new DeploymentInfo().setClassIntrospecter(introspecter).addListeners(listenerInfoList).addFilters(filterInfoList).addServlets(servletInfoList).setContextPath(contextPath).setDeploymentName(name).setClassLoader(ClassLoader.getSystemClassLoader());
    XnioWorker worker = null;
    try {
        worker = Xnio.getInstance().createWorker(OptionMap.create(Options.THREAD_DAEMON, true));
    } catch (IOException e) {
        throw new RuntimeException("Unable to create XNIO", e);
    }
    Pool<ByteBuffer> buffers = new ByteBufferSlicePool(1024, 10240);
    WebSocketContainer container = new ServerWebSocketContainer(introspecter, UndertowContainerProvider.class.getClassLoader(), worker, buffers, new CompositeThreadSetupAction(Collections.<ThreadSetupAction>emptyList()), false);
    UndertowContainerProvider.addContainer(ClassLoader.getSystemClassLoader(), container);
    if (this.websocketEndpointClass != null) {
        di.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo().addEndpoint(websocketEndpointClass).setWorker(worker).setBuffers(buffers));
    }
    if (servletContextAttributes != null) {
        servletContextAttributes.forEach(di::addServletContextAttribute);
    }
    DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(di);
    deploymentManager.deploy();
    try {
        server = Undertow.builder().addHttpListener(port, this.bindAddress).setHandler(deploymentManager.start()).build();
        server.start();
        return this;
    } catch (ServletException e) {
        throw new RuntimeException("Unable to start container", e);
    }
}
Example 12
Project: cdi-tck-master  File: ConversationTestPhaseListener.java View source code
public void beforePhase(PhaseEvent event) {
    BeanManager beanManager = CDI.current().getBeanManager();
    if (event.getPhaseId().equals(PhaseId.APPLY_REQUEST_VALUES)) {
        try {
            beanManager.getContext(ConversationScoped.class);
            activeBeforeApplyRequestValues = true;
        } catch (ContextNotActiveException e) {
            activeBeforeApplyRequestValues = false;
        }
    }
    if (event.getPhaseId().equals(PhaseId.RENDER_RESPONSE)) {
        Conversation conversation = CDI.current().select(Conversation.class).get();
        HttpServletResponse response = (HttpServletResponse) event.getFacesContext().getExternalContext().getResponse();
        response.addHeader(AbstractConversationTest.CID_HEADER_NAME, conversation.getId() == null ? " null" : conversation.getId());
        response.addHeader(AbstractConversationTest.LONG_RUNNING_HEADER_NAME, String.valueOf(!conversation.isTransient()));
        response.addHeader(Cloud.RAINED_HEADER_NAME, new Boolean(BeanLookupUtils.getContextualReference(beanManager, Cloud.class).isRained()).toString());
        response.addHeader(ACTIVE_BEFORE_APPLY_REQUEST_VALUES_HEADER_NAME, new Boolean(activeBeforeApplyRequestValues).toString());
    }
}
Example 13
Project: cxf-master  File: CXFCdiServlet.java View source code
@Override
protected void loadBus(ServletConfig servletConfig) {
    Bus bus = null;
    final BeanManager beanManager = CDI.current().getBeanManager();
    if (beanManager != null) {
        final Set<Bean<?>> candidates = beanManager.getBeans(CdiBusBean.CXF);
        if (!candidates.isEmpty()) {
            final Bean<?> candidate = beanManager.resolve(candidates);
            bus = (Bus) beanManager.getReference(candidate, Bus.class, beanManager.createCreationalContext(candidate));
        }
    }
    if (bus != null) {
        setBus(bus);
    } else {
        busCreated = true;
        setBus(BusFactory.newInstance().createBus());
    }
}
Example 14
Project: undertow.js-master  File: CDIInjectionProvider.java View source code
private synchronized void lookupBeanManager() {
    if (beanManager == null) {
        try {
            beanManager = (BeanManager) new InitialContext().lookup("java:comp/BeanManager");
        } catch (NamingException ignored) {
        }
        if (beanManager == null) {
            beanManager = CDI.current().getBeanManager();
        }
        if (beanManager == null) {
            throw UndertowScriptLogger.ROOT_LOGGER.unableToLookupBeanManager();
        }
    }
}
Example 15
Project: javaee7-samples-master  File: TestServerAuthModule.java View source code
private void callCDIBean(HttpServletRequest request, HttpServletResponse response, String phase) {
    try {
        CDIBean cdiBean = CDI.current().select(CDIBean.class).get();
        response.getWriter().write(phase + ": " + cdiBean.getText() + "\n");
        cdiBean.setTextViaInjectedRequest();
        response.getWriter().write(phase + ": " + request.getAttribute("text") + "\n");
    } catch (Exception e) {
        logger.log(SEVERE, "", e);
    }
}
Example 16
Project: jersey-master  File: DefaultBeanManagerProvider.java View source code
@Override
public BeanManager getBeanManager() {
    InitialContext initialContext = null;
    try {
        initialContext = new InitialContext();
        return (BeanManager) initialContext.lookup("java:comp/BeanManager");
    } catch (final Exception ex) {
        try {
            return CDI.current().getBeanManager();
        } catch (final Exception e) {
            LOGGER.config(LocalizationMessages.CDI_BEAN_MANAGER_JNDI_LOOKUP_FAILED());
            return null;
        }
    } finally {
        if (initialContext != null) {
            try {
                initialContext.close();
            } catch (final NamingException ignored) {
            }
        }
    }
}
Example 17
Project: jetty.project-master  File: WebSocketCdiListener.java View source code
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> ScopedInstance<T> newInstance(Class<T> clazz) {
    BeanManager bm = CDI.current().getBeanManager();
    ScopedInstance sbean = new ScopedInstance();
    Set<Bean<?>> beans = bm.getBeans(clazz, AnyLiteral.INSTANCE);
    if (beans.size() > 0) {
        sbean.bean = beans.iterator().next();
        sbean.creationalContext = bm.createCreationalContext(sbean.bean);
        sbean.instance = bm.getReference(sbean.bean, clazz, sbean.creationalContext);
        return sbean;
    } else {
        throw new RuntimeException(String.format("Can't find class %s", clazz));
    }
}
Example 18
Project: omnisecurity-master  File: Beans.java View source code
public static BeanManager getBeanManager() {
    InitialContext context = null;
    try {
        context = new InitialContext();
        return (BeanManager) context.lookup("java:comp/BeanManager");
    } catch (NamingException e) {
        return CDI.current().getBeanManager();
    } finally {
        closeContext(context);
    }
}
Example 19
Project: ovirt-engine-master  File: Injector.java View source code
/**
     * This method will take an instance and will fulfill all its dependencies, which are members
     * annotated with <code>@Inject</code>.
     * @param instance unmanaged CDI bean, essentially a regular object which is not managed by
     *                  the CDI container.
     * @param <T> an unmanaged CDI instance with some members containing <code>@Inject</code> annotated
     *           members
     */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T> T injectMembers(T instance) {
    AnnotatedType type = CDI.current().getBeanManager().createAnnotatedType(instance.getClass());
    InjectionTarget injectionTarget = CDI.current().getBeanManager().createInjectionTarget(type);
    injectionTarget.inject(instance, CDI.current().getBeanManager().createCreationalContext(null));
    injectionTarget.postConstruct(instance);
    return instance;
}
Example 20
Project: tomee-master  File: InterceptorBase.java View source code
protected Object intercept(final InvocationContext ic) throws Exception {
    TransactionPolicy policy = null;
    final boolean forbidsUt = doesForbidUtUsage();
    final RuntimeException oldEx;
    final IllegalStateException illegalStateException;
    if (forbidsUt) {
        illegalStateException = ILLEGAL_STATE_EXCEPTION;
        oldEx = CoreUserTransaction.error(illegalStateException);
    } else {
        illegalStateException = null;
        oldEx = null;
    }
    try {
        policy = getPolicy();
        final Object proceed = ic.proceed();
        // force commit there to ensure we can catch synchro exceptions
        policy.commit();
        return proceed;
    } catch (final Exception e) {
        if (illegalStateException == e) {
            throw e;
        }
        Exception error = unwrap(e);
        if (error != null && (!HANDLE_EXCEPTION_ONLY_FOR_CLIENT || policy.isNewTransaction())) {
            final Method method = ic.getMethod();
            if (rollback == null) {
                synchronized (this) {
                    if (rollback == null) {
                        rollback = new ConcurrentHashMap<>();
                    }
                }
            }
            Boolean doRollback = rollback.get(method);
            if (doRollback != null) {
                if (doRollback && policy != null && policy.isTransactionActive()) {
                    policy.setRollbackOnly();
                }
            } else {
                final AnnotatedType<?> annotatedType = CDI.current().getBeanManager().createAnnotatedType(method.getDeclaringClass());
                Transactional tx = null;
                for (final AnnotatedMethod<?> m : annotatedType.getMethods()) {
                    if (method.equals(m.getJavaMember())) {
                        tx = m.getAnnotation(Transactional.class);
                        break;
                    }
                }
                if (tx == null) {
                    tx = annotatedType.getAnnotation(Transactional.class);
                }
                if (tx != null) {
                    doRollback = new ExceptionPriotiryRules(tx.rollbackOn(), tx.dontRollbackOn()).accept(error, method.getExceptionTypes());
                    rollback.putIfAbsent(method, doRollback);
                    if (doRollback && policy != null && policy.isTransactionActive()) {
                        policy.setRollbackOnly();
                    }
                }
            }
        }
        if (policy != null) {
            try {
                policy.commit();
            } catch (final Exception ex) {
                final Logger logger = Logger.getLogger(getClass().getName());
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("Swallowing: " + ex.getMessage());
                }
            }
        }
        throw new TransactionalException(e.getMessage(), error);
    } finally {
        if (forbidsUt) {
            CoreUserTransaction.resetError(oldEx);
        }
    }
}
Example 21
Project: wicket-master  File: BeanManagerLookup.java View source code
public static BeanManager lookup() {
    BeanManager ret = lastSuccessful.lookup();
    if (ret != null)
        return ret;
    for (BeanManagerLookupStrategy curStrategy : BeanManagerLookupStrategy.values()) {
        ret = curStrategy.lookup();
        if (ret != null) {
            lastSuccessful = curStrategy;
            return ret;
        }
    }
    throw new IllegalStateException("No BeanManager found via the CDI provider and no fallback specified. Check your " + "CDI setup or specify a fallback BeanManager in the CdiConfiguration.");
}
Example 22
Project: javamoney-lib-master  File: CDIAccessor.java View source code
private static BeanManager getBeanManager() {
    // 1 try JNDI
    try {
        InitialContext ctx = new InitialContext();
        BeanManager man = (BeanManager) ctx.lookup("comp:/env/BeanManager");
        if (man != null) {
            return man;
        }
    } catch (Exception e) {
        LoggerFactory.getLogger(CDIAccessor.class).debug("Unable to locate BeanManager from JNDI...", e);
    }
    try {
        Class.forName("javax.enterprise.inject.spi.CDI");
        // OK CDI 1.1 is loaded
        return CDI.current().getBeanManager();
    } catch (ClassNotFoundException e) {
        LoggerFactory.getLogger(CDIAccessor.class).debug("CDI accessor not available (CDI 1.0).");
    } catch (Exception e) {
        LoggerFactory.getLogger(CDIAccessor.class).debug("Unable to locate BeanManager from CDI providers...", e);
    }
    // 3 error, CDI not loaded...
    throw new IllegalStateException("CDI is not available.");
}
Example 23
Project: cdi-master  File: CDITest.java View source code
@Test
public void testWithThreeCDIProviderOneWithNullCDIAndOthersGood() throws Exception {
    FileWriter fw = new FileWriter(SERVICE_FILE_NAME);
    fw.write(DummyCDIProviderWithNullCDI.class.getName());
    fw.write('\n');
    fw.write(DummyCDIProvider2.class.getName());
    fw.write('\n');
    fw.write(DummyCDIProvider.class.getName());
    fw.close();
    Assert.assertTrue(CDI.current().getClass().equals(DummyCDIProvider.DummyCDI.class));
}
Example 24
Project: JavaIncrementalParser-master  File: TestServletCurrent.java View source code
/**
     * Processes requests for both HTTP
     * <code>GET</code> and
     * <code>POST</code> methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {
        out.println("<!DOCTYPE html>");
        out.println("<html>");
        out.println("<head>");
        out.println("<title>BeanManager using CDI.current</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>BeanManager using CDI.current</h1>");
        // Second way to get BeanManager
        BeanManager bm = CDI.current().getBeanManager();
        Set<Bean<?>> beans = bm.getBeans(Greeting.class);
        for (Bean<?> b : beans) {
            out.println(b.getBeanClass().getName() + "<br>");
        }
        out.println("</body>");
        out.println("</html>");
    }
}
Example 25
Project: HotswapAgent-master  File: BeanClassRefreshAgent.java View source code
/**
     * Reload bean in existing bean manager.
     *
     * @param appClassLoader the class loader
     * @param beanClass the bean class
     * @param oldSignatureByStrategy the old signature by strategy
     * @param reloadStrategy the reload strategy
     */
@SuppressWarnings("rawtypes")
private static void doReloadBean(ClassLoader appClassLoader, Class<?> beanClass, String oldSignatureByStrategy, BeanReloadStrategy reloadStrategy) {
    ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(appClassLoader);
        // check if it is Object descendant
        if (Object.class.isAssignableFrom(beanClass)) {
            BeanManagerImpl beanManager = null;
            BeanManager bm = CDI.current().getBeanManager();
            if (bm instanceof BeanManagerImpl) {
                beanManager = (BeanManagerImpl) bm;
            } else if (bm instanceof InjectableBeanManager) {
                beanManager = (BeanManagerImpl) ReflectionHelper.get(bm, "bm");
            }
            Set<Bean<?>> beans = beanManager.getBeans(beanClass);
            if (beans != null && !beans.isEmpty()) {
                for (Bean<?> bean : beans) {
                    // just now only managed beans
                    if (bean instanceof InjectionTargetBean) {
                        doReloadInjectionTargetBean(beanManager, beanClass, (InjectionTargetBean) bean, oldSignatureByStrategy, reloadStrategy);
                    } else {
                        LOGGER.warning("reloadBean() : class '{}' reloading is not implemented ({}).", bean.getClass().getName(), bean.getBeanClass());
                    }
                }
                LOGGER.debug("Bean reloaded '{}'", beanClass.getName());
            } else {
                // Create new bean
                HaBeanDeployer.doDefineManagedBean(beanManager, beanClass);
            }
        }
    } finally {
        Thread.currentThread().setContextClassLoader(oldContextClassLoader);
    }
}
Example 26
Project: org.ops4j.pax.cdi-master  File: CdiExtender.java View source code
synchronized void start() {
    CDI.setCDIProvider(cdiProvider);
    log.info("starting CDI extender {}", context.getBundle().getSymbolicName());
    this.listenerTracker = new ServiceTracker<>(context, CdiWebAdapter.class, this);
    this.listenerTracker.open();
    this.bundleWatcher = new BundleTracker<>(context, Bundle.ACTIVE, this);
    this.bundleWatcher.open();
}
Example 27
Project: omnifaces-master  File: ApplicationListener.java View source code
private void checkCDI11Available() {
    try {
        checkCDIAPIAvailable();
        checkCDI11Compatible();
        checkCDIImplAvailable();
    } catch (ExceptionLinkageError |  e) {
        logger.severe("" + "\n████████████████████████████████████████████████████████████████████████████████" + "\n▌                         �█     �                                             �" + "\n▌    ▄                  ▄█▓█▌    � OmniFaces failed to initialize!             �" + "\n▌   �██▄               ▄▓░░▓▓    �                                             �" + "\n▌   �█░██▓            ▓▓░░░▓▌    � This OmniFaces version requires CDI 1.1,    �" + "\n▌   �█▌░▓██          █▓░░░░▓     � but none was found on this environment.     �" + "\n▌    ▓█▌░░▓█▄███████▄███▓░▓█     �                                             �" + "\n▌    ▓██▌░▓██░░░░░░░░░░▓█░▓▌     � OmniFaces 2.x requires a minimum of JSF 2.2.�" + "\n▌     ▓█████░░░░░░░░░░░░▓██      � Since this JSF version, the JSF managed bean�" + "\n▌     ▓██▓░░░░░░░░░░░░░░░▓█      � facility @ManagedBean is semi-official      �" + "\n▌     �█▓░░░░░░█▓░░▓█░░░░▓█▌     � deprecated in favour of CDI. JSF 2.2 users  �" + "\n▌     ▓█▌░▓█▓▓██▓░█▓▓▓▓▓░▓█▌     � are strongly encouraged to move to CDI.     �" + "\n▌     ▓▓░▓██████▓░▓███▓▓▌░█▓     �                                             �" + "\n▌    �▓▓░█▄�▓▌█▓░░▓█�▓▌▄▓░██     � OmniFaces goes a step further by making CDI �" + "\n▌    ▓█▓░▓█▄▄▄█▓░░▓█▄▄▄█▓░██▌    � a REQUIRED dependency next to JSF 2.2. This �" + "\n▌    ▓█▌░▓█████▓░░░▓███▓▀░▓█▓    � not only ensures that your web application  �" + "\n▌   �▓█░░░▀▓██▀░░░░░ ▀▓▀░░▓█▓    � represents the state of art, but this also  �" + "\n▌   ▓██░░░░░░░░▀▄▄▄▄▀░░░░░░▓▓    � makes for us easier to develop OmniFaces,   �" + "\n▌   ▓█▌░░░░░░░░░░�▌░░░░░░░░▓▓▌   � without the need for all sorts of hacks in  �" + "\n▌   ▓█░░░░░░░░░▄▀▀▀▀▄░░░░░░░█▓   � in order to get OmniFaces to deploy on      �" + "\n▌  �█▌░░░░░░░░▀░░░░░░▀░░░░░░█▓▌  � environments without CDI.                   �" + "\n▌  ▓█░░░░░░░░░░░░░░░░░░░░░░░██▓  �                                             �" + "\n▌  ▓█░░░░░░░░░░░░░░░░░░░░░░░▓█▓  � You have 3 options:                         �" + "\n██████████████████████████████████ 1. Downgrade to OmniFaces 1.x.              �" + "\n█░▀░░░░▀█▀░░░░░░▀█░░░░░░▀█▀░░░░░▀█ 2. Install CDI in this environment.         �" + "\n█░░�█▌░░█░░░██░░░█░░██░░░█░░░██░░█ 3. Switch to a CDI capable environment.     �" + "\n█░░�█▌░░█░░░██░░░█░░██░░░█░░░██░░█                                             �" + "\n█░░�█▌░░█░░░██░░░█░░░░░░▄█░░▄▄▄▄▄█ For additional instructions, check          �" + "\n█░░�█▌░░█░░░██░░░█░░░░████░░░░░░░█ http://omnifaces.org/cdi                    �" + "\n█░░░█░░░█▄░░░░░░▄█░░░░████▄░░░░░▄█                                             �" + "\n████████████████████████████████████████████████████████████████████████████████");
        throw e;
    }
}
Example 28
Project: deltaspike-master  File: BeanManagerProvider.java View source code
/**
     * Returns the current provider instance which provides access to the current {@link BeanManager}.
     *
     * @throws IllegalStateException if the {@link BeanManagerProvider} isn't ready to be used. That's the case if the
     *                               environment isn't configured properly and therefore the {@link AfterBeanDiscovery}
     *                               hasn't been called before this method gets called.
     * @return the singleton BeanManagerProvider
     */
public static BeanManagerProvider getInstance() {
    if (bmpSingleton == null) {
        throw new IllegalStateException("No " + BeanManagerProvider.class.getName() + " in place! " + "Please ensure that you configured the CDI implementation of your choice properly. " + "If your setup is correct, please clear all caches and compiled artifacts.");
    }
    return bmpSingleton;
}
Example 29
Project: mojarra-master  File: UIData.java View source code
private DataModel<?> createDataModel(final Class<?> forClass) {
    List<DataModel<?>> dataModel = new ArrayList<DataModel<?>>(1);
    CDI<Object> cdi = CDI.current();
    // Scan the map in order, the first class that is a super class or equal to the class for which
    // we're looking for a DataModel is the closest match, since the Map is sorted on inheritance relation
    getDataModelClassesMap(cdi).entrySet().stream().filter( e -> e.getKey().isAssignableFrom(forClass)).findFirst().ifPresent( e -> dataModel.add(cdi.select(e.getValue(), new FacesDataModelAnnotationLiteral(e.getKey())).get()));
    return dataModel.isEmpty() ? null : dataModel.get(0);
}
Example 30
Project: furnace-cdi-master  File: WeldFurnaceProvider.java View source code
@Override
public Furnace getFurnace(ClassLoader loader) {
    return CDI.current().select(Furnace.class).get();
}
Example 31
Project: fabric8-master  File: KubernetesHolder.java View source code
private static BeanManager getBeanManager() {
    try {
        return CDI.current().getBeanManager();
    } catch (Throwable t) {
        return BEAN_MANAGER.get();
    }
}
Example 32
Project: fx-inject-master  File: CdiFXMLComponentBuilder.java View source code
@Override
protected T getInstance(Class<T> clazz) {
    return CDI.current().select(clazz).get();
}
Example 33
Project: vraptor4-master  File: WeldJunitRunner.java View source code
/**
	 * With this, your test class is a CDI bean, so you can use DI
	 */
@Override
protected Object createTest() throws Exception {
    return CDI.current().select(clazz).get();
}
Example 34
Project: wildfly-swarm-master  File: CDIArquillianTest.java View source code
@Test
public void testCDIContainerPresence() throws Exception {
    assertNotNull(CDI.current());
}
Example 35
Project: arquillian-container-weld-master  File: ContainerCDIProvider.java View source code
@Override
public CDI<Object> getCDI() {
    return new EnvironmentCDI();
}
Example 36
Project: controle-financeiro-master  File: CustomRelationshipManager.java View source code
/**
     * @return a instancia do gerenciador de permissoes do usuario
     */
private UserSessionBean getUserSessionBean() {
    if (this.userSessionBean == null) {
        this.userSessionBean = CDI.current().select(UserSessionBean.class).get();
    }
    return this.userSessionBean;
}
Example 37
Project: web-budget-master  File: CustomRelationshipManager.java View source code
/**
     * @return a instancia do gerenciador de permissoes do usuario
     */
private UserSessionBean getUserSessionBean() {
    if (this.userSessionBean == null) {
        this.userSessionBean = CDI.current().select(UserSessionBean.class).get();
    }
    return this.userSessionBean;
}
Example 38
Project: wildfly-master  File: WeldProvider.java View source code
@Override
public CDI<Object> getCDI() {
    final Container container = Container.instance();
    checkContainerState(container);
    return containers.get(container);
}
Example 39
Project: glassfish-master  File: GlassFishWeldProvider.java View source code
@Override
public CDI<Object> getCDI() {
    try {
        return new GlassFishEnhancedWeld();
    } catch (Throwable throwable) {
        Throwable cause = throwable.getCause();
        if (cause instanceof IllegalStateException) {
            return null;
        }
        throw throwable;
    }
}
Example 40
Project: Payara-master  File: GlassFishWeldProvider.java View source code
@Override
public CDI<Object> getCDI() {
    try {
        return new GlassFishEnhancedWeld();
    } catch (Throwable throwable) {
        Throwable cause = throwable.getCause();
        if (cause instanceof IllegalStateException) {
            return null;
        }
        throw throwable;
    }
}