use of org.jboss.weld.contexts.beanstore.BoundBeanStore in project core by weld.
the class HttpRequestContextImpl method associate.
public boolean associate(HttpServletRequest request) {
// At this point the bean store should never be set - see also HttpContextLifecycle#nestedInvocationGuard
BoundBeanStore beanStore = getBeanStore();
if (beanStore != null) {
ContextLogger.LOG.beanStoreLeakDuringAssociation(this.getClass().getName(), request);
if (ContextLogger.LOG.isDebugEnabled()) {
ContextLogger.LOG.beanStoreLeakAffectedBeanIdentifiers(this.getClass().getName(), Iterables.toMultiRowString(beanStore));
}
}
// We always associate a new bean store to avoid possible leaks (security threats)
beanStore = new RequestBeanStore(request, namingScheme);
setBeanStore(beanStore);
beanStore.attach();
return true;
}
use of org.jboss.weld.contexts.beanstore.BoundBeanStore in project core by weld.
the class HttpSessionContextImpl method destroy.
public boolean destroy(HttpSession session) {
final BoundBeanStore beanStore = getBeanStore();
if (beanStore == null) {
try {
HttpConversationContext conversationContext = getConversationContext();
setBeanStore(new EagerSessionBeanStore(namingScheme, session));
activate();
invalidate();
conversationContext.destroy(session);
deactivate();
setBeanStore(null);
return true;
} finally {
cleanup();
}
} else {
// We are in a request, invalidate it
invalidate();
if (beanStore instanceof AttributeBeanStore) {
AttributeBeanStore attributeBeanStore = ((AttributeBeanStore) beanStore);
if (attributeBeanStore.isAttributeLazyFetchingEnabled()) {
// At this moment we have to sync the local bean store and the backing store
attributeBeanStore.fetchUninitializedAttributes();
}
}
getConversationContext().destroy(session);
return false;
}
}
use of org.jboss.weld.contexts.beanstore.BoundBeanStore in project core by weld.
the class AbstractConversationContext method destroy.
public boolean destroy(S session) {
// the context may be active
// if it is, we need to re-attach the bean store once the other conversations are destroyed
final BoundBeanStore beanStore = getBeanStore();
final boolean active = isActive();
if (beanStore != null) {
beanStore.detach();
}
try {
Object conversationMap = getSessionAttributeFromSession(session, CONVERSATIONS_ATTRIBUTE_NAME);
if (conversationMap instanceof Map) {
Map<String, ManagedConversation> conversations = cast(conversationMap);
synchronized (conversations) {
if (!conversations.isEmpty()) {
// There are some conversations to destroy
setActive(true);
if (beanStore == null) {
// There is no request associated - destroy conversation contexts immediately
for (Entry<String, ManagedConversation> entry : conversations.entrySet()) {
destroyConversation(session, entry.getKey());
}
} else {
// All conversation contexts created during the current session should be destroyed after the servlet service() completes
// However, at that time the session will not be available - store all remaining contextual instances in the request
setDestructionQueue(conversations, session);
}
}
}
}
return true;
} finally {
setBeanStore(beanStore);
setActive(active);
if (beanStore != null) {
beanStore.attach();
} else if (!active) {
removeState();
cleanup();
}
}
}
Aggregations