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


Java Contextual.destroy方法代码示例

本文整理汇总了Java中javax.enterprise.context.spi.Contextual.destroy方法的典型用法代码示例。如果您正苦于以下问题:Java Contextual.destroy方法的具体用法?Java Contextual.destroy怎么用?Java Contextual.destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.enterprise.context.spi.Contextual的用法示例。


在下文中一共展示了Contextual.destroy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: destroy

import javax.enterprise.context.spi.Contextual; //导入方法依赖的package包/类
/**
 * Destroy the instance.
 *
 * @param contextual the contextual.
 */
public void destroy(Contextual contextual) {
    String scopeId = (String) request.getAttribute(SCOPE_ID);
    if (null != scopeId) {
        HttpSession session = request.getSession();
        if (contextual instanceof PassivationCapable == false) {
            throw new RuntimeException("Unexpected type for contextual");
        }
        PassivationCapable pc = (PassivationCapable) contextual;
        final String sessionKey = SCOPE_ID + "-" + scopeId;
        Map<String, Object> scopeMap = (Map<String, Object>) session.getAttribute(sessionKey);
        if (null != scopeMap) {
            Object instance = scopeMap.get(INSTANCE + pc.getId());
            CreationalContext<?> creational = (CreationalContext<?>) scopeMap.get(CREATIONAL + pc.getId());
            if (null != instance && null != creational) {
                contextual.destroy(instance, creational);
                creational.release();
            }
        }
    }
}
 
开发者ID:mvc-spec,项目名称:ozark,代码行数:26,代码来源:RedirectScopeManager.java

示例2: processEvent

import javax.enterprise.context.spi.Contextual; //导入方法依赖的package包/类
/**
 * We get PreDestroyViewMapEvent events from the JSF servlet and destroy our
 * contextual instances. This should (theoretically!) also get fired if the
 * webapp closes, so there should be no need to manually track all view
 * scopes and destroy them at a shutdown.
 * 
 * @see javax.faces.event.SystemEventListener#processEvent(javax.faces.event.SystemEvent)
 */
@SuppressWarnings("unchecked")
@Override
public void processEvent(final SystemEvent event) {
	if (event instanceof PreDestroyViewMapEvent) {
		Map<Contextual<?>, Object> componentInstanceMap = getComponentInstanceMap();
		Map<Contextual<?>, CreationalContext<?>> creationalContextMap = getCreationalInstanceMap();

		if (componentInstanceMap != null) {
			for (Map.Entry<Contextual<?>, Object> componentEntry : componentInstanceMap.entrySet()) {
				/*
				 * No way to inform the compiler of type <T> information, so
				 * it has to be abandoned here :(
				 */
				Contextual contextual = componentEntry.getKey();
				Object instance = componentEntry.getValue();
				CreationalContext creational = creationalContextMap.get(contextual);

				contextual.destroy(instance, creational);
			}
		}
	}
}
 
开发者ID:fabiohxcx,项目名称:PedidoVenda,代码行数:31,代码来源:ViewScopedContext.java

示例3: processEvent

import javax.enterprise.context.spi.Contextual; //导入方法依赖的package包/类
/**
 * We get PreDestroyViewMapEvent events from the JSF servlet and destroy our
 * contextual instances. This should (theoretically!) also get fired if the
 * webapp closes, so there should be no need to manually track all view
 * scopes and destroy them at a shutdown.
 * 
 * @see javax.faces.event.SystemEventListener#processEvent(javax.faces.event.SystemEvent)
 */
@Override
public void processEvent(final SystemEvent event) {
	if (event instanceof PreDestroyViewMapEvent) {
		Map<Contextual<?>, Object> componentInstanceMap = getComponentInstanceMap();
		Map<Contextual<?>, CreationalContext<?>> creationalContextMap = getCreationalInstanceMap();

		if (componentInstanceMap != null) {
			for (Map.Entry<Contextual<?>, Object> componentEntry : componentInstanceMap.entrySet()) {
				/*
				 * No way to inform the compiler of type <T> information, so
				 * it has to be abandoned here :(
				 */
				Contextual contextual = componentEntry.getKey();
				Object instance = componentEntry.getValue();
				CreationalContext creational = creationalContextMap.get(contextual);

				contextual.destroy(instance, creational);
			}
		}
	}
}
 
开发者ID:brenoemelo,项目名称:goFitOne,代码行数:30,代码来源:ViewScopedContext.java

示例4: remove

import javax.enterprise.context.spi.Contextual; //导入方法依赖的package包/类
/**
 * Removes & destroys the given bean from the given bean map
 * @param bean
 */
@SuppressWarnings("unchecked")
private <T> void remove(String id, Map<Contextual<?>, BeanInstance<?>> beanMap, Contextual<T> bean) {
   BeanInstance<?> bi = beanMap.get(bean);
   
   if (isDebug) {
      StringBuilder txt = new StringBuilder(80);
      txt.append("Removing bean: ");
      if (bean instanceof Bean<?>) {
         Bean<?> b = (Bean<?>) bean;
         txt.append(b.getBeanClass().getSimpleName());
      }
      txt.append(", window ID: ").append(id);
      if (bi == null) {
         txt.append(", instance is null.");
      }
      LOG.debug(txt.toString());
   }

   if (bi != null) {
      beans.remove(bean);
      bi.crco.release();
      bean.destroy((T)bi.instance, (CreationalContext<T>)bi.crco);
   }
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:29,代码来源:PortletSessionScopedBeanMap.java

示例5: remove

import javax.enterprise.context.spi.Contextual; //导入方法依赖的package包/类
/**
 * Removes & destroys the given bean
 * @param bean
 */
@SuppressWarnings("unchecked")
protected <T> void remove(Contextual<T> bean) {
   BeanInstance<?> bi = beans.get(bean);
   
   if (isTrace) {
      StringBuilder txt = new StringBuilder(80);
      txt.append("Removing render state scoped bean: ");
      if (bean instanceof Bean<?>) {
         Bean<?> b = (Bean<?>) bean;
         txt.append(b.getBeanClass().getSimpleName());
      }
      if (bi == null) {
         txt.append(", instance is null.");
      }
      LOG.trace(txt.toString());
   }

   if (bi != null) {
      beans.remove(bean);
      bi.crco.release();
      bean.destroy((T)bi.instance, (CreationalContext<T>)bi.crco);
   }
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:28,代码来源:PortletStateScopedBeanHolder.java

示例6: remove

import javax.enterprise.context.spi.Contextual; //导入方法依赖的package包/类
/**
 * Removes & destroys the given bean
 * @param bean
 */
@SuppressWarnings("unchecked")
protected <T> void remove(Contextual<T> bean) {
   BeanInstance<?> bi = beans.get(bean);
   
   if (isTrace) {
      StringBuilder txt = new StringBuilder(80);
      txt.append("Removing portlet request scoped bean: ");
      if (bean instanceof Bean<?>) {
         Bean<?> b = (Bean<?>) bean;
         txt.append(b.getBeanClass().getSimpleName());
      }
      if (bi == null) {
         txt.append(", instance is null.");
      }
      LOG.trace(txt.toString());
   }

   if (bi != null) {
      beans.remove(bean);
      bi.crco.release();
      bean.destroy((T)bi.instance, (CreationalContext<T>)bi.crco);
   }
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:28,代码来源:PortletRequestScopedBeanHolder.java

示例7: destroy

import javax.enterprise.context.spi.Contextual; //导入方法依赖的package包/类
/**
 * Destroys the bean.
 *
 * @param contextual a {@link Contextual}.
 */
void destroy(
        Contextual<T> contextual) {
    if (log.isDebugEnabled()) {
        log.debug("Destroying transaction scoped bean instance "
                + this);
    }

    contextual.destroy(instance, creationalContext);
    creationalContext.release();
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:16,代码来源:TransactionalContext.java

示例8: remove

import javax.enterprise.context.spi.Contextual; //导入方法依赖的package包/类
/**
 * Remove a bean from the cache and call the listeners for removal
 * 
 * @param bean The bean to remove
 */
void remove(Contextual<?> bean) {
    @SuppressWarnings("unchecked")
    Contextual<Object> thisOne = (Contextual<Object>) bean;
    CacheEntry entry;
    synchronized (cache) {
        entry = cache.remove(bean);
    }
    if (entry != null) {
        listener.instanceRemoved(bean, entry.context, entry.instance);
        thisOne.destroy(entry.instance, entry.context);
    }
}
 
开发者ID:arievanwi,项目名称:osgi.ee,代码行数:18,代码来源:ContextBeansHolder.java

示例9: destroy

import javax.enterprise.context.spi.Contextual; //导入方法依赖的package包/类
/**
 * Destroys the bean.
 *
 * @param contextual a {@link Contextual}.
 */
void destroy(
    Contextual<T> contextual)
{
    if (log.isDebugEnabled())
    {
        log.debug("Destroying transaction scoped bean instance "
            + this);
    }

    contextual.destroy(instance, creationalContext);
    creationalContext.release();
}
 
开发者ID:arkhipov,项目名称:transaction-cdi,代码行数:18,代码来源:TransactionalContext.java

示例10: destroyBean

import javax.enterprise.context.spi.Contextual; //导入方法依赖的package包/类
public static void destroyBean(Contextual bean, ContextualInstanceInfo<?> contextualInstanceInfo)
{
    bean.destroy(contextualInstanceInfo.getContextualInstance(), contextualInstanceInfo.getCreationalContext());
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:5,代码来源:AbstractContext.java


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