/** * Overriden superclass method. Creates a single application context containing all the service * beans * * @throws PlatformException */ protected void loadServiceContexts() throws PlatformException { // locate and load the individual service bean XML files using the common batch beans context as // parent File[] serviceBeansFiles = FileLocator.findFiles(ServiceFrameworkConstants.SPRING_SERVICES_CONFIG); List<String> fileNamesList = new LinkedList<String>(); for (File serviceBeansFile : serviceBeansFiles) { // dont load the individual service context, just register an empty context for display // purposes GenericApplicationContext nonRefreshedServiceContext = new GenericApplicationContext(); XmlBeanDefinitionReader beanDefReader = new XmlBeanDefinitionReader(nonRefreshedServiceContext); // add the "file:" prefix to file names to explicitly state that it is on the file system and // not a classpath resource beanDefReader.loadBeanDefinitions( ServiceConfigInfo.FILE_PREFIX + serviceBeansFile.getAbsolutePath()); ServiceConfigInfo nonInitedServiceConfigInfo = new ServiceConfigInfo(serviceBeansFile, null, nonRefreshedServiceContext); super.registerServiceContext(nonInitedServiceConfigInfo); // add the "file:" prefix to file names to get around strange behavior of // FileSystemXmlApplicationContext that converts absolute path to relative path fileNamesList.add(ServiceConfigInfo.FILE_PREFIX + serviceBeansFile.getAbsolutePath()); } this.servicesContext = new FileSystemXmlApplicationContext( (String[]) fileNamesList.toArray(new String[0]), SpringServicesContainer.getCommonServiceBeansContext()); super.registerServiceContext( new ServiceConfigInfo( new File(ServiceFrameworkConstants.SPRING_SERVICES_CONFIG), null, this.servicesContext)); }
/** * Overriden superclass method. Calls super.init() and also initializes the MuleContext * * @see SpringServicesContainer#init() */ public void init() throws PlatformException { super.init(); LinkedList<String> fileNamesList = new LinkedList<String>(); // add the common Mule beans file fileNamesList.add(SedaFrameworkConstants.COMMON_MULE_CONFIG); // add the Mule configurations containing Mule service definitions File[] serviceBeansFiles = FileLocator.findFiles(SedaFrameworkConstants.MULE_CONFIG); for (File serviceBeansFile : serviceBeansFiles) { fileNamesList.add(serviceBeansFile.getAbsolutePath()); } String[] muleConfigPaths = (String[]) fileNamesList.toArray(new String[0]); try { SpringXmlConfigurationBuilder springConfigBuilder = new SpringXmlConfigurationBuilder(muleConfigPaths); springConfigBuilder.setUseDefaultConfigResource( false); // turn off using the default config resource as we have a custom config defined // in SedaFrameworkConstants.COMMON_MULE_CONFIG springConfigBuilder.setParentContext(this.servicesContext); this.muleContext = new DefaultMuleContextFactory().createMuleContext(springConfigBuilder); this.muleContext.start(); } catch (Exception e) { LOGGER.error("Fatal error loading Mule configurations : " + e.getMessage(), e); throw new PlatformException("Fatal error loading Mule configurations : " + e.getMessage(), e); } }
/** * Interface method implementation. Creates and loads a Spring ApplicationContext for each * property specified in {@link #getAllProperties()} * * @see org.trpr.platform.runtime.spi.bootstrapext.BootstrapExtension#init() */ public void init() { // Iterate through the properties to get ApplicationContext name and the corresponding file name for (String key : this.getAllProperties().keySet()) { String fileName = this.getAllProperties().get(key); try { File springBeansFile = FileLocator.findUniqueFile(fileName); // add the "file:" prefix to file names to get around strange behavior of // FileSystemXmlApplicationContext that converts // absolute path to relative path // Set the commons beans context as the parent of all application contexts created through // this ApplicationContextFactory AbstractApplicationContext appContext = new FileSystemXmlApplicationContext( new String[] {FILE_PREFIX + springBeansFile.getAbsolutePath()}, getCommonBeansContext()); ApplicationContextFactory.appContextMap.put(key.toLowerCase(), appContext); } catch (Exception e) { // blanket catch for all checked and unchecked exceptions LOGGER.error( "Error loading ApplicationContext. [Name][Path] : [" + key + "][" + fileName + "].Error is : " + e.getMessage(), e); this.bootstrapOutcome = BootstrapExtension.VETO_BOOTSTRAP; return; } } }