コード例 #1
0
    @SuppressWarnings("unused")
    public void methodOne(@Observes Object event) {
      Assert.assertNotNull(object);
      Assert.assertNull(object.get());

      object.set(new Object());
      methodOneWasCalled = true;
    }
コード例 #2
0
  public void createConversation(@Observes(precedence = -1) Before event, WeldManager manager) {
    if (!enableConversationScope) {
      return;
    }

    CDIConversationID id = conversationId.get();
    if (id == null) {
      id = new CDIConversationID(null); // when null creates a new empty conversation id.
    }

    BoundRequest request = new MutableBoundRequest(requestMap.get(), sessionMap.get());
    this.boundRequest.set(request);

    BoundConversationContext conversationContext =
        manager.instance().select(BoundConversationContext.class).get();
    conversationContext.associate(request);
    conversationContext.activate(id.getId());
  }
コード例 #3
0
  public void destroySession(@Observes BeforeUnDeploy event, WeldManager manager) {
    BoundSessionContext sessionContext = manager.instance().select(BoundSessionContext.class).get();

    CDISessionMap map = sessionMap.get();
    if (map != null) {
      try {
        sessionContext.invalidate();
        sessionContext.deactivate();
      } finally {
        sessionContext.dissociate(map);
      }
    }
  }
コード例 #4
0
  public void destroyRequest(@Observes After event, WeldManager manager) {
    BoundRequestContext requestContext = manager.instance().select(BoundRequestContext.class).get();

    CDIRequestMap map = requestMap.get();
    if (map != null) {
      try {
        requestContext.invalidate();
        requestContext.deactivate();
      } finally {
        requestContext.dissociate(map);
        map.clear();
      }
    }
  }
コード例 #5
0
  public void destroyConversation(@Observes(precedence = 1) After event, WeldManager manager) {
    if (!enableConversationScope) {
      return;
    }

    BoundConversationContext conversationContext =
        manager.instance().select(BoundConversationContext.class).get();
    if (!conversationContext.getCurrentConversation().isTransient()) {
      conversationId.set(
          new CDIConversationID(conversationContext.getCurrentConversation().getId()));
    } else {
      conversationId.set(new CDIConversationID(null));
    }

    BoundRequest request = boundRequest.get();

    try {
      conversationContext.invalidate();
      conversationContext.deactivate();
    } finally {
      conversationContext.dissociate(request);
    }
  }