List of usage examples for org.springframework.context.support AbstractApplicationContext getBeansOfType
@Override
public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type) throws BeansException
From source file:org.powertac.logtool.Logtool.java
/** * Sets up the logtool, delegates everything to a LogtoolCore instance. *///ww w . j a va 2s .c om public static void main(String[] args) { AbstractApplicationContext context = new ClassPathXmlApplicationContext("logtool.xml"); context.registerShutdownHook(); // find the LogtoolCore bean LogtoolCore lc = (LogtoolCore) context.getBeansOfType(LogtoolCore.class).values().toArray()[0]; lc.processCmdLine(args); // if we get here, it's time to exit System.exit(0); }
From source file:org.powertac.server.PowerTacServer.java
/** * Sets up the container, sets up logging, and starts the * CompetitionControl service.//ww w .j ava2 s . com * <p> * A simple script file can be used in lieu of a web interface to * configure and run games. Each line in the file must be in one of two * forms:<br/> * <code> bootstrap [--config boot-config]</code><br/> * <code> sim [--config sim-config] broker1 broker2 ...</code><br/> * where * <dl> * <dt><code>boot-config</code></dt> * <dd>is the optional name of a properties file that specifies the * bootstrap setup. If not provided, then the default * server.properties will be used.</dd> * <dt><code>sim-config</code></dt> * <dd>is the optional name of a properties file that specifies the * simulation setup. If not provided, then the default server.properties * file will be used. It is possible for the sim-config to be different * from the boot-config that produced the bootstrap data file used * in the sim, but many properties will be carried over from the * bootstrap session regardless of the contents of sim-config.</dd> * <dt><code>brokern</code></dt> * <dd>are the broker usernames of the brokers that will be logged in * before the simulation starts. They must attempt to log in after the * server starts.</dd> * </dl> * To use a configuration file, simply give the filename as a command-line * argument. * */ public static void main(String[] args) { AbstractApplicationContext context = new ClassPathXmlApplicationContext("powertac.xml"); context.registerShutdownHook(); // find the CompetitionControl and ServerProperties beans css = (CompetitionSetupService) context.getBeansOfType(CompetitionSetupService.class).values().toArray()[0]; css.processCmdLine(args); // if we get here, it's time to exit System.exit(0); }
From source file:com.linuxbox.enkive.Main.java
protected void runVersionCheck() throws Exception { final AbstractApplicationContext versionCheckingContext = new ClassPathXmlApplicationContext( VERSION_CHECK_CONFIG_FILES); try {//from w ww . j a va 2s. c o m Map<String, DbMigrationService> migrationServices = versionCheckingContext .getBeansOfType(DbMigrationService.class); if (migrationServices.isEmpty()) { final String message = "no version checking / migration services configured"; LOGGER.fatal(message); throw new Exception(message); } for (Entry<String, DbMigrationService> service : migrationServices.entrySet()) { service.getValue().isUpToDate(); } } finally { versionCheckingContext.close(); } }