private ConfigurationResourceProvider createResourceProvider( DefaultStorageFinder cacheDirFinder) throws ConfigurationException { return new XMLFileResourceProvider( CONFIGURATION_FILE_NAME, (org.springframework.web.context.WebApplicationContext) appContext, cacheDirFinder); }
@Override public void backup() throws IOException { backUpConfig(findOrCreateConfFile()); }
public String getLocation() throws IOException { File f = findConfigFile(); try { return f.getCanonicalPath(); } catch (IOException ex) { log.error("Could not canonize config path", ex); return f.getPath(); } }
@Override public OutputStream out() throws IOException { return new FileOutputStream(findOrCreateConfFile()); }
/** * Constructor that will look for {@code geowebcache.xml} at the directory defined by {@code * storageDirFinder} * * @param appCtx use to lookup {@link XMLConfigurationProvider} extenions, may be {@code null} * @param storageDirFinder * @throws ConfigurationException */ public XMLFileResourceProvider( final String configFileName, final WebApplicationContext appCtx, final DefaultStorageFinder storageDirFinder) throws ConfigurationException { this(configFileName, appCtx, getConfigDirVar(appCtx), storageDirFinder); }
@Override public InputStream in() throws IOException { if (failNextRead) { failNextRead = false; throw new IOException("Test failure on read"); } return super.in(); }
@Override public OutputStream out() throws IOException { if (failNextWrite) { failNextWrite = false; throw new IOException("Test failure on write"); } return super.out(); } };
@Override public boolean hasInput() { try { return findOrCreateConfFile().exists(); } catch (IOException e) { return false; } }
/** * Constructor that will look for {@code geowebcache.xml} at the directory defined by {@code * storageDirFinder} * * @param appCtx use to lookup {@link XMLConfigurationProvider} extenions, may be {@code null} * @param storageDirFinder * @throws ConfigurationException */ public XMLFileResourceProvider( final String configFileName, final ApplicationContextProvider appCtx, final DefaultStorageFinder storageDirFinder) throws ConfigurationException { this( configFileName, appCtx, getConfigDirVar(appCtx.getApplicationContext()), storageDirFinder); }
/** * @param storageFinder used to get the location of the cache directory * @param contextProvider used to look up registered instances of {@link ExpirationPolicy} and * to aid in determining the location of the {@code geowebcache-diskquota.xml} configuration * file * @param tld used only to validate the presence of a layer at {@link #loadConfig()} and ignore * the layer quota definition if the {@link TileLayer} does not exist * @throws IOException */ public ConfigLoader( final DefaultStorageFinder storageFinder, final ApplicationContextProvider contextProvider, final TileLayerDispatcher tld) throws ConfigurationException { this( new XMLFileResourceProvider( CONFIGURATION_FILE_NAME, contextProvider, null, storageFinder), storageFinder, tld); }
@Override public InputStream in() throws IOException { return new FileInputStream(findOrCreateConfFile()); }
private File findOrCreateConfFile() throws IOException { File xmlFile = findConfigFile();
/** * Constructor that will look for {@code geowebcache.xml} at the directory defined by {@code * storageDirFinder} * * @param appCtx use to lookup {@link XMLConfigurationProvider} extenions, may be {@code null} * @param storageDirFinder * @throws ConfigurationException */ public XMLConfiguration( final ApplicationContextProvider appCtx, final DefaultStorageFinder storageDirFinder) throws ConfigurationException { this( appCtx, new XMLFileResourceProvider( DEFAULT_CONFIGURATION_FILE_NAME, appCtx, storageDirFinder)); resourceProvider.setTemplate("/" + DEFAULT_CONFIGURATION_FILE_NAME); }
/** * File System based Constructor * * @param appCtx use to lookup {@link XMLConfigurationProvider} extensions, may be {@code null} * @param configFileDirectory * @param storageDirFinder * @throws ConfigurationException */ public XMLConfiguration( final ApplicationContextProvider appCtx, final String configFileDirectory, final DefaultStorageFinder storageDirFinder) throws ConfigurationException { this( appCtx, new XMLFileResourceProvider( DEFAULT_CONFIGURATION_FILE_NAME, appCtx, configFileDirectory, storageDirFinder)); resourceProvider.setTemplate("/" + DEFAULT_CONFIGURATION_FILE_NAME); }
protected ServerConfiguration getConfig() throws Exception { if (configFile == null) { // create a temp XML config configDir = temp.getRoot(); configFile = temp.newFile(XMLConfiguration.DEFAULT_CONFIGURATION_FILE_NAME); // copy the example XML to the temp config file URL source = XMLConfiguration.class.getResource("geowebcache_190.xml"); FileUtils.copyURLToFile(source, configFile); } // initialize the config with an XMLFileResourceProvider that uses the temp config file gridSetBroker = new GridSetBroker(true, true); ConfigurationResourceProvider configProvider = new XMLFileResourceProvider( XMLConfiguration.DEFAULT_CONFIGURATION_FILE_NAME, (WebApplicationContext) null, configDir.getAbsolutePath(), null); config = new XMLConfiguration(null, configProvider); ((XMLConfiguration) config).setGridSetBroker(gridSetBroker); config.afterPropertiesSet(); return config; } }