List of usage examples for org.springframework.context ApplicationContext getEnvironment
Environment getEnvironment();
From source file:SpringInAction4Edition.MainApp.java
public static void main(String[] args) { ApplicationContext context = new AnnotationConfigApplicationContext(CDConfig.class); Environment env = context.getEnvironment(); System.err.println("environment : ime : " + env.getProperty("ime")); System.err.println("environment : prezime : " + env.getProperty("prezime")); KutijaCD cd_ovi = context.getBean(KutijaCD.class); CDPlayer cDPlayer = context.getBean(CDPlayer.class); cd_ovi.getCds().stream().forEach((cd) -> { cd.play();//from w w w . ja va 2 s . co m }); cDPlayer.getCd(); System.err.println("BEAN DEF NAMES : " + Arrays.toString(context.getBeanDefinitionNames())); }
From source file:com.garyclayburg.BootUp.java
public static void main(String[] args) { ApplicationContext ctx = SpringApplication.run(BootUp.class); log.info("active profiles: " + Arrays.toString(ctx.getEnvironment().getActiveProfiles())); log.info("Beans loaded by spring / spring boot"); String[] beanNames = ctx.getBeanDefinitionNames(); Arrays.sort(beanNames);/*w w w .j av a 2 s . com*/ for (String beanName : beanNames) { log.info(beanName); } log.info(""); log.info("Server is ready for e-business"); }
From source file:uk.org.iay.mdq.server.Application.java
/** * Main entry point; invokes the web server using Spring Boot. * /*from w ww . j av a2 s. co m*/ * @param args Command line arguments. */ public static void main(String[] args) { /* * Class logger. */ final Logger log = LoggerFactory.getLogger(EntitiesController.class); /* * Construct the application. */ final SpringApplication app = new SpringApplication(Application.class); /* * Customize the application. */ app.setShowBanner(false); /* * Start the application. */ final ApplicationContext ctx = app.run(args); final Environment env = ctx.getEnvironment(); for (String profile : env.getDefaultProfiles()) { log.debug("default profile: {}", profile); } for (String profile : env.getActiveProfiles()) { log.debug("active profile: {}", profile); } }
From source file:com.garyclayburg.BootVaadin.java
public static void main(String[] args) { log.info("running main with args: " + Arrays.toString(args)); ensureActiveProfile();/*from w w w. j a v a 2s .c om*/ ApplicationContext ctx = SpringApplication.run(BootUp.class, args); log.info("active profiles: " + Arrays.toString(ctx.getEnvironment().getActiveProfiles())); log.info("Beans loaded by spring / spring boot"); String[] beanNames = ctx.getBeanDefinitionNames(); Arrays.sort(beanNames); for (String beanName : beanNames) { log.info(beanName); } log.info(""); log.info("BootVaadin Server is ready for e-business"); }
From source file:org.carewebframework.api.spring.SpringUtil.java
/** * Returns a property value from the application context. * /* ww w .j a v a 2 s . c om*/ * @param name Property name. * @return Property value, or null if not found. */ public static String getProperty(String name) { ApplicationContext appContext = getRootAppContext(); if (appContext == null) { return null; } String value = appContext.getEnvironment().getProperty(name); if (value == null) { PropertySourcesPlaceholderConfigurer cfg = appContext .getBean(PropertySourcesPlaceholderConfigurer.class); PropertySource<?> ps = cfg.getAppliedPropertySources() .get(PropertySourcesPlaceholderConfigurer.LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME); value = ps == null ? null : (String) ps.getProperty(name); } return value; }
From source file:de.metas.ui.web.vaadin.VaadinClientApplication.java
/** * Returns <code>true</code> if the testing profile is active.<br> * Activate it by adding <code>spring.profiles.include=testing</code> to the application properties. * <p>// w w w .ja va 2 s . c om * Thx to http://stackoverflow.com/questions/9267799/how-do-you-get-current-active-default-environment-profile-programatically-in-spr * * @return */ public static boolean isTesting() { final ApplicationContext context = VaadinClientApplication.context; if (context == null) { return false; // guard against NPE } final Environment environment = context.getEnvironment(); if (environment == null) { return false; // guard against NPE } return environment.acceptsProfiles(PROFILE_NAME_TESTING); }
From source file:de.metas.ui.web.WebRestApiApplication.java
/** @return true if given profile is active */ public static boolean isProfileActive(final String profile) { final ApplicationContext context = Adempiere.getSpringApplicationContext(); if (context == null) { logger.warn("No application context found to determine if '{}' profile is active", profile); return true; }// w w w . j a v a 2 s . c om return context.getEnvironment().acceptsProfiles(profile); }
From source file:system.AppConfiguration.java
/** * Actor system Singleton per ApplicationContext for this application. *//* w w w . java 2 s . c o m*/ @Bean public ActorSystem actorSystem(ApplicationContext applicationContext) { Environment environment = applicationContext.getEnvironment(); final String name = environment.getProperty(ActorSystemProperties.NAME); final Config config = environment.getProperty(ActorSystemProperties.CONFIG, Config.class); ActorSystem system = ActorSystem.create(name, config); SpringExtProvider.get(system).initialize(applicationContext); return system; }
From source file:de.interseroh.report.webapp.SessionListener.java
@Override public void sessionCreated(HttpSessionEvent event) { ApplicationContext applicationContext = getApplicationContext(event); Environment env = applicationContext.getEnvironment(); String timeout = env.getProperty("session.timeout.interval"); if (timeout == null || timeout.equals("")) { // Default seconds 21600 == 6 hours timeout = DEFAULT_TIMEOUT_INTERVAL; }/*www .j av a2 s . c o m*/ event.getSession().setMaxInactiveInterval(Integer.parseInt(timeout)); if (logger.isDebugEnabled()) { logger.debug("Session created, timeout: " + timeout); } }
From source file:com.github.wnameless.spring.bulkapi.DefaultBulkApiService.java
/** * Creates a {@link DefaultBulkApiService}. * /*from w w w . j av a 2 s. c o m*/ * @param appCtx * the Spring {@link ApplicationContext} */ public DefaultBulkApiService(ApplicationContext appCtx) { this.appCtx = appCtx; env = appCtx.getEnvironment(); }