org.jboss.weld.context.ApplicationContext.invalidate()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中org.jboss.weld.context.ApplicationContext.invalidate()方法的一些代码示例,展示了ApplicationContext.invalidate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationContext.invalidate()方法的具体详情如下:
包路径:org.jboss.weld.context.ApplicationContext
类名称:ApplicationContext
方法名:invalidate

ApplicationContext.invalidate介绍

[英]Invalidate the context, causing all bean instances to be destroyed.
[中]使上下文无效,导致所有bean实例被销毁。

代码示例

代码示例来源:origin: org.apache.deltaspike.cdictrl/deltaspike-cdictrl-weld

/**
 * Weld Application context is active from container start to its shutdown
 * This method merely clears out all ApplicationScoped beans BUT the context
 * will still be active which may result in immediate re-creation of some beans.
 */
private void stopApplicationScope()
{
  // Welds ApplicationContext gets cleaned at shutdown.
  // Weld App context should be always active
  if (applicationContext.isActive())
  {
    // destroys the bean instances, but the context stays active
    applicationContext.invalidate();
  }
}

代码示例来源:origin: apache/deltaspike

/**
 * Weld Application context is active from container start to its shutdown
 * This method merely clears out all ApplicationScoped beans BUT the context
 * will still be active which may result in immediate re-creation of some beans.
 */
private void stopApplicationScope()
{
  // Welds ApplicationContext gets cleaned at shutdown.
  // Weld App context should be always active
  if (applicationContext.isActive())
  {
    // destroys the bean instances, but the context stays active
    applicationContext.invalidate();
  }
}

代码示例来源:origin: org.jboss.weld/weld-porting-package

public void destroyContext(Context context) {
  if (context instanceof ManagedContext) {
    ManagedContext managedContext = (ManagedContext) context;
    managedContext.invalidate();
    managedContext.deactivate();
    managedContext.activate();
  } else if (context instanceof ApplicationContext) {
    ((ApplicationContext) context).invalidate();
  } else {
    throw new UnsupportedOperationException();
  }
}

代码示例来源:origin: org.jboss.weld/weld-porting-package-tck11

public void destroyContext(Context context) {
    context = ForwardingContext.unwrap(context);
    if (context instanceof ManagedContext) {
      ManagedContext managedContext = (ManagedContext) context;
      managedContext.invalidate();
      managedContext.deactivate();
      managedContext.activate();
    } else if (context instanceof ApplicationContext) {
      ((ApplicationContext) context).invalidate();
    } else {
      throw new UnsupportedOperationException();
    }
  }
}

代码示例来源:origin: org.jboss.weld/weld-porting-package-tck10

public void destroyContext(Context context) {
  context = ForwardingContext.unwrap(context);
  if (context instanceof ManagedContext) {
    ManagedContext managedContext = (ManagedContext) context;
    managedContext.invalidate();
    managedContext.deactivate();
    managedContext.activate();
  } else if (context instanceof ApplicationContext) {
    ((ApplicationContext) context).invalidate();
  } else {
    throw new UnsupportedOperationException();
  }
}

代码示例来源:origin: weld/core

public void destroyContext(Context context) {
    context = ForwardingContext.unwrap(context);
    if (context instanceof ManagedContext) {
      ManagedContext managedContext = (ManagedContext) context;
      managedContext.invalidate();
      managedContext.deactivate();
      managedContext.activate();
    } else if (context instanceof ApplicationContext) {
      ((ApplicationContext) context).invalidate();
    } else {
      throw new UnsupportedOperationException();
    }
  }
}

代码示例来源:origin: org.jboss.weld/weld-porting-package-tck

public void destroyContext(Context context) {
    context = ForwardingContext.unwrap(context);
    if (context instanceof ManagedContext) {
      ManagedContext managedContext = (ManagedContext) context;
      managedContext.invalidate();
      managedContext.deactivate();
      managedContext.activate();
    } else if (context instanceof ApplicationContext) {
      ((ApplicationContext) context).invalidate();
    } else {
      throw new UnsupportedOperationException();
    }
  }
}

代码示例来源:origin: weld/core

public void shutdown() {
  try {
    // The container must destroy all contexts.
    // For non-web modules, fire @BeforeDestroyed event
    fireEventForNonWebModules(Object.class, ContextEvent.APPLICATION_BEFORE_DESTROYED, BeforeDestroyed.Literal.APPLICATION);
    deploymentManager.instance().select(ApplicationContext.class).get().invalidate();
    deploymentManager.instance().select(SingletonContext.class).get().invalidate();
  } finally {
    // fire @Destroyed(ApplicationScope.class) for non-web modules
    fireEventForNonWebModules(Object.class, ContextEvent.APPLICATION_DESTROYED, Destroyed.Literal.APPLICATION);
    try {
      // Finally, the container must fire an event of type BeforeShutdown.
      BeforeShutdownImpl.fire(deploymentManager);
    } finally {
      Container container = Container.instance(contextId);
      container.setState(ContainerState.SHUTDOWN);
      container.cleanup();
    }
  }
}

代码示例来源:origin: weld/core

public void shutdown() {
  try {
    // The container must destroy all contexts.
    // For non-web modules, fire @BeforeDestroyed event
    fireEventForNonWebModules(Object.class, ContextEvent.APPLICATION_BEFORE_DESTROYED, BeforeDestroyed.Literal.APPLICATION);
    deploymentManager.instance().select(ApplicationContext.class).get().invalidate();
    deploymentManager.instance().select(SingletonContext.class).get().invalidate();
  } finally {
    // fire @Destroyed(ApplicationScope.class) for non-web modules
    fireEventForNonWebModules(Object.class, ContextEvent.APPLICATION_DESTROYED, Destroyed.Literal.APPLICATION);
    try {
      // Finally, the container must fire an event of type BeforeShutdown.
      BeforeShutdownImpl.fire(deploymentManager);
    } finally {
      Container container = Container.instance(contextId);
      container.setState(ContainerState.SHUTDOWN);
      container.cleanup();
    }
  }
}

代码示例来源:origin: weld/core

public void shutdown() {
  try {
    // The container must destroy all contexts.
    // For non-web modules, fire @BeforeDestroyed event
    fireEventForNonWebModules(Object.class, ContextEvent.APPLICATION_BEFORE_DESTROYED, BeforeDestroyed.Literal.APPLICATION);
    deploymentManager.instance().select(ApplicationContext.class).get().invalidate();
    deploymentManager.instance().select(SingletonContext.class).get().invalidate();
  } finally {
    // fire @Destroyed(ApplicationScope.class) for non-web modules
    fireEventForNonWebModules(Object.class, ContextEvent.APPLICATION_DESTROYED, Destroyed.Literal.APPLICATION);
    try {
      // Finally, the container must fire an event of type BeforeShutdown.
      BeforeShutdownImpl.fire(deploymentManager);
    } finally {
      Container container = Container.instance(contextId);
      container.setState(ContainerState.SHUTDOWN);
      container.cleanup();
    }
  }
}

代码示例来源:origin: org.jboss.weld.se/weld-se-shaded

public void shutdown() {
  try {
    // The container must destroy all contexts.
    // For non-web modules, fire @BeforeDestroyed event
    fireEventForNonWebModules(Object.class, ContextEvent.APPLICATION_BEFORE_DESTROYED, BeforeDestroyed.Literal.APPLICATION);
    deploymentManager.instance().select(ApplicationContext.class).get().invalidate();
    deploymentManager.instance().select(SingletonContext.class).get().invalidate();
  } finally {
    // fire @Destroyed(ApplicationScope.class) for non-web modules
    fireEventForNonWebModules(Object.class, ContextEvent.APPLICATION_DESTROYED, Destroyed.Literal.APPLICATION);
    try {
      // Finally, the container must fire an event of type BeforeShutdown.
      BeforeShutdownImpl.fire(deploymentManager);
    } finally {
      Container container = Container.instance(contextId);
      container.setState(ContainerState.SHUTDOWN);
      container.cleanup();
    }
  }
}

代码示例来源:origin: org.jboss.weld.servlet/weld-servlet-shaded

public void shutdown() {
  try {
    // The container must destroy all contexts.
    // For non-web modules, fire @BeforeDestroyed event
    fireEventForNonWebModules(Object.class, ContextEvent.APPLICATION_BEFORE_DESTROYED, BeforeDestroyed.Literal.APPLICATION);
    deploymentManager.instance().select(ApplicationContext.class).get().invalidate();
    deploymentManager.instance().select(SingletonContext.class).get().invalidate();
  } finally {
    // fire @Destroyed(ApplicationScope.class) for non-web modules
    fireEventForNonWebModules(Object.class, ContextEvent.APPLICATION_DESTROYED, Destroyed.Literal.APPLICATION);
    try {
      // Finally, the container must fire an event of type BeforeShutdown.
      BeforeShutdownImpl.fire(deploymentManager);
    } finally {
      Container container = Container.instance(contextId);
      container.setState(ContainerState.SHUTDOWN);
      container.cleanup();
    }
  }
}

代码示例来源:origin: org.jboss.weld.se/weld-se

public void shutdown() {
  try {
    deploymentManager.instance().select(ApplicationContext.class).get().invalidate();
    deploymentManager.instance().select(SingletonContext.class).get().invalidate();

相关文章

ApplicationContext类方法