org.jboss.weld.context.ApplicationContext类的使用及代码示例

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

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

ApplicationContext介绍

[英]The built in application context, associated with ApplicationScoped. It is always active (not managed) and is backed by an application scoped singleton.

Weld comes with one Application context which can be injected using:

@ Inject ApplicationContext applicationContext;

[中]与已处理的应用程序关联的内置应用程序上下文。它始终处于活动状态(不受管理),并由应用程序范围的单例支持。
Weld附带一个应用程序上下文,可通过以下方式注入:

@ Inject ApplicationContext applicationContext;

代码示例

代码示例来源: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.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: br.com.caelum.vraptor/vraptor-test

void stopApplicationScope() {
    if (applicationContext.isActive()) {
        if (applicationContext instanceof AbstractSharedContext) {
            ((AbstractSharedContext) applicationContext).getBeanStore().clear();
        }
    }
}

代码示例来源: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: 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-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类方法