本文整理汇总了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();
}
}
}
}
示例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);
}
}
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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();
}
示例10: destroyBean
import javax.enterprise.context.spi.Contextual; //导入方法依赖的package包/类
public static void destroyBean(Contextual bean, ContextualInstanceInfo<?> contextualInstanceInfo)
{
bean.destroy(contextualInstanceInfo.getContextualInstance(), contextualInstanceInfo.getCreationalContext());
}