Examples of ConversationContext


Examples of br.gov.frameworkdemoiselle.context.ConversationContext

    Exception failure = null;
   
    RequestContext tempRequestContext = Beans.getReference(RequestContext.class);
    SessionContext tempSessionContext = Beans.getReference(SessionContext.class);
    ViewContext tempViewContext = Beans.getReference(ViewContext.class);
    ConversationContext tempConversationContext = Beans.getReference(ConversationContext.class);

    boolean requestActivatedHere = !tempRequestContext.isActive();
    boolean sessionActivatedHere = !tempSessionContext.isActive();
    boolean viewActivatedHere = !tempViewContext.isActive();
    boolean conversationActivatedHere = !tempConversationContext.isActive();
   
    if (!registered) {
      if (!tempRequestContext.isActive())
        tempRequestContext.activate();
     
      if (!tempSessionContext.isActive())
        tempSessionContext.activate();
     
      if (!tempViewContext.isActive())
        tempViewContext.activate();
     
      if (!tempConversationContext.isActive())
        tempConversationContext.activate();

      registered = true;
    }

    for (Iterator<AnnotatedMethodProcessor> iter = processors.iterator(); iter.hasNext();) {
      AnnotatedMethodProcessor<?> processor = iter.next();

      try {
        ClassLoader classLoader = Reflections.getClassLoaderForClass(processor.getAnnotatedMethod()
            .getDeclaringType().getJavaClass().getCanonicalName());

        if (Thread.currentThread().getContextClassLoader().equals(classLoader)) {
          processor.process();
          iter.remove();
        }

      } catch (Exception cause) {
        failure = cause;
      }
    }

    if (processors.isEmpty()) {
      if (requestActivatedHere){
        tempRequestContext.deactivate();
      }
     
      if (sessionActivatedHere){
        tempSessionContext.deactivate();
      }
     
      if (viewActivatedHere){
        tempViewContext.deactivate();
      }
     
      if (conversationActivatedHere){
        tempConversationContext.deactivate();
      }
    }

    if (failure != null) {
      throw new DemoiselleException(failure);
View Full Code Here

Examples of com.github.overengineer.scope.conversation.context.ConversationContext

     * @param adapter
     * @param maxIdleTimeMillis
     * @return
     */
    public static ConversationContext begin(String name, ConversationAdapter adapter, long maxIdleTimeMillis, int maxInstances) {
        ConversationContext context = adapter.beginConversation(name, maxIdleTimeMillis, maxInstances);
        String id = context.getId();
        adapter.getViewContext().put(name, id);
        adapter.getRequestContext().put(name, id);
        return context;
    }
View Full Code Here

Examples of com.github.overengineer.scope.conversation.context.ConversationContext

public class DefaultConversationContextTest extends SerializableObjectTest<DefaultConversationContext> {

    @Test
    public void testDefaultConversationContext() throws IOException, ClassNotFoundException {

        ConversationContext context = new DefaultConversationContext("testName", "testId", 5L);
        assertTrue(5L == context.getRemainingTime() || 4L == context.getRemainingTime());
        assertEquals("testName", context.getConversationName());
        assertEquals("testId", context.getId());
        context.put("bean", "beanValue");
        assertEquals("beanValue", context.get("bean"));
        context = SerializationTestingUtil.getSerializedCopy(context);
        assertEquals("testName", context.getConversationName());
        assertEquals("testId", context.getId());
        assertEquals("beanValue", context.get("bean"));
        assertEquals(5L, context.getRemainingTime());

        context.put("bean", null);
        assertNull(context.get("bean"));
    }
View Full Code Here

Examples of com.github.overengineer.scope.conversation.context.ConversationContext

public class ProgrammaticModelDrivenConversationUtil {

    public static <T extends ProgrammaticModelDrivenConversation<?>> void begin(T controller, long maxIdleTime, int maxInstances) {
        Object model = controller.getModel();
        for (String conversationName : controller.getConversations()) {
            ConversationContext conversationContext = ConversationUtil.begin(conversationName, maxIdleTime, maxInstances);
            conversationContext.put(conversationName, model);
        }
    }
View Full Code Here

Examples of com.google.code.rees.scope.conversation.context.ConversationContext

           
            if (LOG.isDebugEnabled()) {
                LOG.debug("Beginning new " + conversationName+ " with max idle time of " + maxIdleTime / 1000 + " seconds for action " + actionId);
            }
           
            ConversationContext newConversationContext = ConversationUtil.begin(conversationName, conversationAdapter, maxIdleTime);
            conversationId = newConversationContext.getId();
            conversationAdapter.addPostProcessor(this, conversationConfig, conversationId);
           
        }
    }
View Full Code Here

Examples of com.google.code.rees.scope.conversation.context.ConversationContext

    HttpConversationContextManagerProvider managerProvider = new DefaultHttpConversationContextManagerProvider();
    managerProvider.setConversationContextFactory(new DefaultConversationContextFactory());
    managerProvider.setMonitoringFrequency(1L);
    managerProvider.init();
    MockConversationAdapter.init(request, managerProvider);
    ConversationContext context = ConversationUtil.begin(mockConversationName, 50L);
    context.addTimeoutListener(this);
    context.setMaxIdleTime(50L);
    try {
      Thread.sleep(2000L);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
View Full Code Here

Examples of com.google.code.rees.scope.conversation.context.ConversationContext

    public static <T extends ProgrammaticModelDrivenConversation<?>> void begin(
            T controller) {
        Object model = controller.getModel();
        for (String conversationName : controller.getConversations()) {
            ConversationContext conversationContext = ConversationUtil
                    .begin(conversationName);
            conversationContext.put(conversationName, model);
        }
    }
View Full Code Here

Examples of com.google.code.rees.scope.conversation.context.ConversationContext

   * @param adapter
   * @param maxIdleTimeMillis
   * @return
   */
  public static ConversationContext begin(String name, ConversationAdapter adapter, long maxIdleTimeMillis) {
    ConversationContext context = adapter.beginConversation(name, maxIdleTimeMillis);
    String id = context.getId();
    adapter.getViewContext().put(name, id);
    adapter.getRequestContext().put(name, id);
    return context;
  }
View Full Code Here

Examples of com.google.code.rees.scope.conversation.context.ConversationContext

           
            if (LOG.isDebugEnabled()) {
                LOG.debug("Beginning new " + conversationName+ " with max idle time of " + maxIdleTime / 1000 + " seconds for action " + actionId);
            }
           
            ConversationContext newConversationContext = ConversationUtil.begin(conversationName, conversationAdapter, maxIdleTime);
            conversationId = newConversationContext.getId();
            conversationAdapter.addPostProcessor(this, conversationConfig, conversationId);
           
        }
    }
View Full Code Here

Examples of com.google.code.rees.scope.conversation.context.ConversationContext

   *
   * @param name
   * @return a new {@link ConversationContext}
   */
  public static ConversationContext begin(String name, ConversationAdapter adapter) {
    ConversationContext context = adapter.beginConversation(name);
    String id = context.getId();
    adapter.getViewContext().put(name, id);
    adapter.getRequestContext().put(name, id);
    return context;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.