Package javax.enterprise.context.spi

Examples of javax.enterprise.context.spi.Context


     */
    @Test(groups = { EVENTS, INTEGRATION })
    @SpecAssertions({ @SpecAssertion(section = "10.4", id = "c"), @SpecAssertion(section = "5.5.6", id = "a") })
    public void testStaticObserverMethodInvoked() {

        Context requestContext = getCurrentConfiguration().getContexts().getRequestContext();

        try {
            // Deactivate request context so that we're sure the contextual instance is not obtained
            getCurrentConfiguration().getContexts().setInactive(requestContext);

View Full Code Here


    @SpecAssertion(section = "6.4", id = "e")
    public void testContextGetWithCreationalContextReturnsNewInstance() {
        Set<Bean<Fox>> foxBeans = getBeans(Fox.class);
        assert foxBeans.size() == 1;
        Bean<Fox> foxBean = foxBeans.iterator().next();
        Context context = getCurrentManager().getContext(Dependent.class);
        assert context.get(foxBean, new MockCreationalContext<Fox>()) != null;
        assert context.get(foxBean, new MockCreationalContext<Fox>()) instanceof Fox;
    }
View Full Code Here

        if (logger.isLoggable(Level.FINE))
        {
            logger.log(Level.FINE, ">lazyStartSessionContext");
        }

        Context webContext = null;
        Context context = getCurrentContext(RequestScoped.class);
        if (context instanceof ServletRequestContext)
        {
            ServletRequestContext requestContext = (ServletRequestContext) context;
            HttpServletRequest servletRequest = requestContext.getServletRequest();
            if (null != servletRequest)
View Full Code Here

      if (scope.equals(Unknown.class) || scope.equals(Singleton.class) || scope.equals(Dependent.class)
         || scope.equals(ApplicationScoped.class))
      {
         return create();
      }
      final Context ctx = manager.getContext(scope);
      if (ctx == null)
      {
         if (LOG.isTraceEnabled())
         {
            LOG.trace("The scope {} is unknown, thus we will create the component {} out of a scope context.",
View Full Code Here

                observerMethod.invoke(object, args);
            }
            else
            {
                BeanManagerImpl manager = bean.getWebBeansContext().getBeanManagerImpl();
                Context context;
                try
                {
                    context = manager.getContext(component.getScope());
                }
                catch (ContextNotActiveException cnae)
                {
                    // this may happen if we try to e.g. send an event to a @ConversationScoped bean from a ServletListener
                    logger.log(Level.INFO, OWBLogConst.INFO_0010, bean);
                    return;
                }
               

                // on Reception.IF_EXISTS: ignore this bean if a the contextual instance doesn't already exist
                object = context.get(component);

                if (ifExist && object == null)
                {
                    return;
                }

                creationalContext = manager.createCreationalContext(component);

                if (isPrivateMethod)
                {
                    // since private methods cannot be intercepted, we can just call them directly
                    // so we get the contextual instance directly from the context because we do not
                    // proxy private methods (thus the invocation on the contextual reference would fail)
                    if (object == null)
                    {
                        object = context.get(component, creationalContext);
                    }
                }
                else
                {
                    // on Reception.ALWAYS we must get a contextual reference if we didn't find the contextual instance
View Full Code Here

   
    public void activateContext(Class<? extends Annotation> scopeType)
    {
        if(supportsContext(scopeType))
        {
            Context context = getCurrentContext(scopeType);
            if(context instanceof AbstractContext)
            {
                ((AbstractContext)context).setActive(true);
            }
        }
View Full Code Here

   
    public void deActivateContext(Class<? extends Annotation> scopeType)
    {
        if(supportsContext(scopeType))
        {
            Context context = getCurrentContext(scopeType);
            if(context instanceof AbstractContext)
            {
                ((AbstractContext)context).setActive(false);
            }
        }       
View Full Code Here

   
    private void initiateBeanBag(OwbBean<Object> bean, CreationalContext<Object> creationalContext)
    {
        try
        {
            Context webbeansContext = getBeanManager().getContext(bean.getScope());
            if (webbeansContext instanceof AbstractContext)
            {
                AbstractContext owbContext = (AbstractContext)webbeansContext;
                owbContext.initContextualBag(bean, creationalContext);
            }           
View Full Code Here

    protected Object getContextualInstance()
    {
        Object webbeansInstance;

        //Context of the bean
        Context webbeansContext = getBeanManager().getContext(bean.getScope());
       
        //Already saved in context?
        webbeansInstance = webbeansContext.get(bean);
        if (webbeansInstance != null)
        {
            // voila, we are finished if we found an existing contextual instance
            return webbeansInstance;
        }

        // finally, we create a new contextual instance
        webbeansInstance = webbeansContext.get((Contextual<Object>) bean, getContextualCreationalContext());

        if (webbeansInstance == null)
        {
            throw new UnproxyableResolutionException("Cannot find a contextual instance of bean " + bean.toString());
        }
View Full Code Here

    {
        CreationalContext<Object> creationalContext = null;
       
        OwbBean<Object> contextual = (OwbBean<Object>) bean;
        //Context of the bean
        Context webbeansContext = getBeanManager().getContext(bean.getScope());
        CreationalContextFactory contextFactory = bean.getWebBeansContext().getCreationalContextFactory();
        if (webbeansContext instanceof AbstractContext)
        {
            AbstractContext owbContext = (AbstractContext)webbeansContext;
            creationalContext = owbContext.getCreationalContext(contextual);
View Full Code Here

TOP

Related Classes of javax.enterprise.context.spi.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.