日期:2014-05-16 浏览次数:21081 次
public void init() throws FileSystemException { // Set the replicator and temporary file store (use the same component) final DefaultFileReplicator replicator = createDefaultFileReplicator(); setReplicator(new PrivilegedFileReplicator(replicator)); setTemporaryFileStore(replicator); /* replaced by findClassLoader if (classLoader == null) { // Use default classloader classLoader = getClass().getClassLoader(); } */ if (configUri == null) { // Use default config final URL url = getClass().getResource(CONFIG_RESOURCE); if (url == null) { throw new FileSystemException("vfs.impl/find-config-file.error", CONFIG_RESOURCE); } configUri = url; } // Configure configure(configUri); // Configure Plugins configurePlugins(); // Initialise super-class super.init(); }
private static final String CONFIG_RESOURCE = "providers.xml"; private URL configUri;
InputStream configStream = null; try { // Load up the config // TODO - validate final DocumentBuilder builder = createDocumentBuilder(); configStream = configUri.openStream(); final Element config = builder.parse(configStream).getDocumentElement(); configure(config); } catch (final Exception e) { throw new FileSystemException("vfs.impl/load-config.error", configUri.toString(), e); }
private void configure(final Element config) throws FileSystemException { // Add the providers final NodeList providers = config.getElementsByTagName("provider"); final int count = providers.getLength(); for (int i = 0; i < count; i++) { final Element provider = (Element) providers.item(i); addProvider(provider, false); } // Add the operation providers final NodeList operationProviders = config.getElementsByTagName("operationProvider"); for (int i = 0; i < operationProviders.getLength(); i++) { final Element operationProvider = (Element) operationProviders.item(i); addOperationProvider(operationProvider); } // Add the default provider final NodeList defProviders = config.getElementsByTagName("default-provider"); if (defProviders.getLength() > 0) { final Element provider = (Element) defProviders.item(0); addProvider(provider, true); } // Add the mime-type maps final NodeList mimeTypes = config.getElementsByTagName("mime-type-map"); for (int i = 0; i < mimeTypes.getLength(); i++) { final Element map = (Element) mimeTypes.item(i); addMimeTypeMap(map); } // Add the extension maps final NodeList extensions = config.getElem