1 /* 2 * ************************************************************************************************************************************************************* 3 * 4 * SteelBlue: DCI User Interfaces 5 * http://tidalwave.it/projects/steelblue 6 * 7 * Copyright (C) 2015 - 2024 by Tidalwave s.a.s. (http://tidalwave.it) 8 * 9 * ************************************************************************************************************************************************************* 10 * 11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 12 * You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 17 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 18 * 19 * ************************************************************************************************************************************************************* 20 * 21 * git clone https://bitbucket.org/tidalwave/steelblue-src 22 * git clone https://github.com/tidalwave-it/steelblue-src 23 * 24 * ************************************************************************************************************************************************************* 25 */ 26 package it.tidalwave.ui.javafx; 27 28 import javax.annotation.Nonnull; 29 import java.util.ArrayList; 30 import java.util.Locale; 31 import org.springframework.context.ConfigurableApplicationContext; 32 import org.springframework.context.support.ClassPathXmlApplicationContext; 33 import org.slf4j.Logger; 34 import org.slf4j.LoggerFactory; 35 36 /*************************************************************************************************************************************************************** 37 * 38 * @author Fabrizio Giudici 39 * 40 **************************************************************************************************************************************************************/ 41 public class JavaFXSpringApplication extends AbstractJavaFXSpringApplication 42 { 43 // Don't use Slf4j and its static logger - give Main a chance to initialize things 44 private final Logger log = LoggerFactory.getLogger(JavaFXSpringApplication.class); 45 46 /*********************************************************************************************************************************************************** 47 * Creates the application context. 48 * 49 * @return the application context 50 **********************************************************************************************************************************************************/ 51 @Nonnull 52 protected ConfigurableApplicationContext createApplicationContext() 53 { 54 final var springConfigLocations = new ArrayList<String>(); 55 final var osName = System.getProperty("os.name", "").toLowerCase(Locale.getDefault()); 56 springConfigLocations.add("classpath*:/META-INF/*AutoBeans.xml"); 57 58 if (osName.contains("os x")) 59 { 60 springConfigLocations.add("classpath*:/META-INF/*AutoMacOSXBeans.xml"); 61 } 62 63 if (osName.contains("linux")) 64 { 65 springConfigLocations.add("classpath*:/META-INF/*AutoLinuxBeans.xml"); 66 } 67 68 if (osName.contains("windows")) 69 { 70 springConfigLocations.add("classpath*:/META-INF/*AutoWindowsBeans.xml"); 71 } 72 73 log.info("Loading Spring configuration from {} ...", springConfigLocations); 74 return new ClassPathXmlApplicationContext(springConfigLocations.toArray(new String[0])); 75 } 76 }