Java Code Examples for org.springframework.context.support.AbstractApplicationContext#getBeansOfType()

The following examples show how to use org.springframework.context.support.AbstractApplicationContext#getBeansOfType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PublicNetworkTest.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
@AfterClass
public static void globalTearDown() throws Exception {
    s_lockMaster.cleanupForServer(s_msId);
    JmxUtil.unregisterMBean("Locks", "Locks");
    s_lockMaster = null;

    AbstractApplicationContext ctx = (AbstractApplicationContext)ComponentContext.getApplicationContext();
    Map<String, ComponentLifecycle> lifecycleComponents = ctx.getBeansOfType(ComponentLifecycle.class);
    for (ComponentLifecycle bean : lifecycleComponents.values()) {
        bean.stop();
    }
    ctx.close();

    s_logger.info("destroying mysql server instance running at port <" + s_mysqlServerPort + ">");
    TestDbSetup.destroy(s_mysqlServerPort, null);
}
 
Example 2
Source File: NetworkProviderTest.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
@AfterClass
public static void globalTearDown() throws Exception {
    s_lockMaster.cleanupForServer(s_msId);
    JmxUtil.unregisterMBean("Locks", "Locks");
    s_lockMaster = null;

    AbstractApplicationContext ctx = (AbstractApplicationContext)ComponentContext.getApplicationContext();
    Map<String, ComponentLifecycle> lifecycleComponents = ctx.getBeansOfType(ComponentLifecycle.class);
    for (ComponentLifecycle bean : lifecycleComponents.values()) {
        bean.stop();
    }
    ctx.close();

    s_logger.info("destroying mysql server instance running at port <" + s_mysqlSrverPort + ">");
    TestDbSetup.destroy(s_mysqlSrverPort, null);
}
 
Example 3
Source File: SpringBeanContext.java    From ob1k with Apache License 2.0 4 votes vote down vote up
public <T> Map<String, T> getBeans(final String ctxName, final Class<T> type) {
  final AbstractApplicationContext context = contexts.get(ctxName);
  Objects.requireNonNull(context, "Context not found for name '" + ctxName + "'");
  return context.getBeansOfType(type);
}