Skip to content

Commit

Permalink
Conversation Manager API
Browse files Browse the repository at this point in the history
Integration of lifecycle and JSF to CM API
Session invalidation survival (load + save of BeanStores)
Sync + asynch conversation manager
  • Loading branch information
nickarls committed Feb 27, 2010
1 parent a41e2bc commit e81ad7d
Show file tree
Hide file tree
Showing 18 changed files with 676 additions and 490 deletions.
15 changes: 15 additions & 0 deletions impl/src/main/java/org/jboss/weld/context/ContextLifecycle.java
Expand Up @@ -35,6 +35,7 @@
import org.jboss.weld.bootstrap.api.Service;
import org.jboss.weld.context.api.BeanStore;
import org.jboss.weld.context.api.helpers.ConcurrentHashMapBeanStore;
import org.jboss.weld.context.beanstore.HashMapBeanStore;
import org.slf4j.cal10n.LocLogger;

/**
Expand Down Expand Up @@ -88,6 +89,7 @@ public void beginRequest(String id, BeanStore requestBeanStore)
requestContext.setBeanStore(requestBeanStore);
requestContext.setActive(true);
dependentContext.setActive(true);
activateConversationContext();
}

public void endRequest(String id, BeanStore requestBeanStore)
Expand All @@ -98,6 +100,7 @@ public void endRequest(String id, BeanStore requestBeanStore)
requestContext.destroy();
requestContext.setActive(false);
requestContext.setBeanStore(null);
deactivateConversationContext();
}

public boolean isRequestActive()
Expand Down Expand Up @@ -181,4 +184,16 @@ public DependentContext getDependentContext()
return dependentContext;
}

public void activateConversationContext()
{
conversationContext.setActive(true);
conversationContext.setBeanStore(new HashMapBeanStore());
}

public void deactivateConversationContext()
{
conversationContext.setActive(false);
conversationContext.setBeanStore(null);
}

}
24 changes: 20 additions & 4 deletions impl/src/main/java/org/jboss/weld/context/ConversationContext.java
Expand Up @@ -24,22 +24,38 @@

import javax.enterprise.context.ConversationScoped;

import org.jboss.weld.context.api.BeanStore;

/**
* The conversation context
*
* @author Nicklas Karlsson
*/
public class ConversationContext extends AbstractThreadLocalMapContext
{

/**
* Constructor
*/
public ConversationContext()
{
super(ConversationScoped.class);
}

private void mergeBeanStores(BeanStore from, BeanStore to)
{
for (String id : from.getContextualIds())
{
to.put(id, from.get(id));
}
}

public void loadTransientBeanStore(BeanStore sourceBeanStore)
{
mergeBeanStores(sourceBeanStore, getBeanStore());
}

public void saveTransientBeanStore(BeanStore targetBeanStore)
{
mergeBeanStores(getBeanStore(), targetBeanStore);
}

@Override
public String toString()
{
Expand Down
Expand Up @@ -29,7 +29,6 @@

import org.jboss.weld.context.api.BeanStore;
import org.jboss.weld.context.api.ContextualInstance;
import org.jboss.weld.util.Names;
import org.jboss.weld.util.collections.EnumerationList;
import org.slf4j.cal10n.LocLogger;

Expand Down
Expand Up @@ -21,8 +21,6 @@
import java.util.HashMap;
import java.util.Map;

import javax.enterprise.context.spi.Contextual;

import org.jboss.weld.context.api.ContextualInstance;
import org.jboss.weld.context.api.helpers.AbstractMapBackedBeanStore;

Expand Down

0 comments on commit e81ad7d

Please sign in to comment.