Package br.gov.frameworkdemoiselle.context

Examples of br.gov.frameworkdemoiselle.context.SessionContext


    Collections.sort(processors);
    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();
      }
View Full Code Here


  private void activateContexts(Class<?> managedType) {
   
    RequestContext requestContext = Beans.getReference(RequestContext.class);
    ViewContext viewContext = Beans.getReference(ViewContext.class);
    SessionContext sessionContext = Beans.getReference(SessionContext.class);
    ConversationContext conversationContext = Beans.getReference(ConversationContext.class);
   
    if (!requestContext.isActive()){
      logger.debug(bundle.getString("management-debug-starting-custom-context",
          requestContext.getClass().getCanonicalName(), managedType.getCanonicalName()));
     
      requestContext.activate();
    }
   
    if (!viewContext.isActive()){
      logger.debug(bundle.getString("management-debug-starting-custom-context",
          viewContext.getClass().getCanonicalName(), managedType.getCanonicalName()));
     
      viewContext.activate();
    }

    if (!sessionContext.isActive()){
      logger.debug(bundle.getString("management-debug-starting-custom-context",
          sessionContext.getClass().getCanonicalName(), managedType.getCanonicalName()));
     
      sessionContext.activate();
    }
   
    if (!conversationContext.isActive()){
      logger.debug(bundle.getString("management-debug-starting-custom-context",
          conversationContext.getClass().getCanonicalName(), managedType.getCanonicalName()));
View Full Code Here

  }

  private void deactivateContexts(Class<?> managedType) {
    RequestContext requestContext = Beans.getReference(RequestContext.class);
    ViewContext viewContext = Beans.getReference(ViewContext.class);
    SessionContext sessionContext = Beans.getReference(SessionContext.class);
    ConversationContext conversationContext = Beans.getReference(ConversationContext.class);
   
    if (requestContext.isActive()){
      logger.debug(bundle.getString("management-debug-stoping-custom-context",
          requestContext.getClass().getCanonicalName(), managedType.getCanonicalName()));
     
      requestContext.deactivate();
    }
   
    if (!viewContext.isActive()){
      logger.debug(bundle.getString("management-debug-stoping-custom-context",
          viewContext.getClass().getCanonicalName(), managedType.getCanonicalName()));
     
      viewContext.deactivate();
    }

    if (!sessionContext.isActive()){
      logger.debug(bundle.getString("management-debug-stoping-custom-context",
          sessionContext.getClass().getCanonicalName(), managedType.getCanonicalName()));
     
      sessionContext.deactivate();
    }
   
    if (!conversationContext.isActive()){
      logger.debug(bundle.getString("management-debug-starting-custom-context",
          conversationContext.getClass().getCanonicalName(), managedType.getCanonicalName()));
View Full Code Here

    return deployment;
  }

  @Before
  public void activeContext() {
    SessionContext sessionContext = Beans.getReference(SessionContext.class);
    sessionContext.activate();

    securityContext.login();
  }
View Full Code Here

  @After
  public void deactiveContext() {
    securityContext.logout();

    SessionContext ctx = Beans.getReference(SessionContext.class);
    ctx.deactivate();
  }
View Full Code Here

    return deployment;
  }

  @Before
  public void activeContext() {
    SessionContext sessionContext = Beans.getReference(SessionContext.class);
    sessionContext.activate();
   
    securityContext.login();
  }
View Full Code Here

  @After
  public void deactiveContext() {
    securityContext.logout();
   
    SessionContext ctx = Beans.getReference(SessionContext.class);
    ctx.deactivate();
  }
View Full Code Here

  }
 
  private void startContexts(){
    if (!registered){
      RequestContext requestContext = Beans.getReference(RequestContext.class);
      SessionContext sessionContext = Beans.getReference(SessionContext.class);
      ViewContext viewContext = Beans.getReference(ViewContext.class);
      ConversationContext conversationContext = Beans.getReference(ConversationContext.class);
     
      if (requestContext!=null){
        startedContextHere.put("request", requestContext.activate());
      }
     
      if (sessionContext!=null){
        startedContextHere.put("session", sessionContext.activate());
      }
     
     
      if (conversationContext!=null){
        startedContextHere.put("conversation", conversationContext.activate());
View Full Code Here

  }
 
  private void stopContexts(){
    if (registered){
      RequestContext requestContext = Beans.getReference(RequestContext.class);
      SessionContext sessionContext = Beans.getReference(SessionContext.class);
      ViewContext viewContext = Beans.getReference(ViewContext.class);
      ConversationContext conversationContext = Beans.getReference(ConversationContext.class);
     
      if (requestContext!=null && Boolean.TRUE.equals(startedContextHere.get("request"))){
        requestContext.deactivate();
      }
     
      if (sessionContext!=null && Boolean.TRUE.equals(startedContextHere.get("session"))){
        sessionContext.deactivate();
      }
     
      if (conversationContext!=null && Boolean.TRUE.equals(startedContextHere.get("conversation"))){
        conversationContext.deactivate();
      }
View Full Code Here

    return deployment;
  }

  @Before
  public void activeContext() {
    SessionContext ctx = Beans.getReference(SessionContext.class);
    ctx.activate();
  }
View Full Code Here

TOP

Related Classes of br.gov.frameworkdemoiselle.context.SessionContext

Copyright © 2018 www.massapicom. 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.