/** * Build a configuration object using an URI * @param uri a <code>String</code> value * @return a <code>Configuration</code> object * @throws SAXException if a parsing error occurs * @throws IOException if an I/O error occurs * @throws ConfigurationException if an error occurs */ public Configuration build( final String uri ) throws SAXException, IOException, ConfigurationException { return build( new InputSource( uri ) ); }
/** * Build a configuration object using an InputStream. * @param inputStream an <code>InputStream</code> value * @return a <code>Configuration</code> object * @throws SAXException if a parsing error occurs * @throws IOException if an I/O error occurs * @throws ConfigurationException if an error occurs */ public Configuration build( final InputStream inputStream ) throws SAXException, IOException, ConfigurationException { return build( new InputSource( inputStream ) ); }
/** * Build a configuration object using an InputStream; * supplying a systemId to make messages about all * kinds of errors more meaningfull. * @param inputStream an <code>InputStream</code> value * @param systemId the systemId to set on the intermediate sax * inputSource * @return a <code>Configuration</code> object * @throws SAXException if a parsing error occurs * @throws IOException if an I/O error occurs * @throws ConfigurationException if an error occurs */ public Configuration build( final InputStream inputStream, final String systemId ) throws SAXException, IOException, ConfigurationException { final InputSource inputSource = new InputSource( inputStream ); inputSource.setSystemId( systemId ); return build( inputSource ); }
private Configuration loadConfiguration( InputStream is ) throws Exception { DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); return builder.build( is ); }
/** The Constant FOP_CONFIG. */ private static final String FOP_CONFIG = "pdf.fop.cfg.xml"; fopFactory = FopFactory.newInstance(); // for image base URL String serverPath = request.getSession().getServletContext().getRealPath("/"); //disable strict validatetion fopFactory.setStrictValidation(false); fopFactory.setBaseURL(serverPath); // for fonts base URL fopFactory.getFontManager().setFontBaseURL(serverPath); // read custom font setting StreamSource configSrc = new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream(PDFComponentFactory.FOP_CONFIG)); DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder(); Configuration cfg = cfgBuilder.build(configSrc.getInputStream()); fopFactory.setUserConfig(cfg);
DefaultConfigurationBuilder defaultConfigurationBuilder = new DefaultConfigurationBuilder(); builder.setConfiguration(defaultConfigurationBuilder.build("config/pdf/fop.xconf"));
/** * Loads the Instrument Manager state from the specified stream. * * @param is Stream to read the instrument manager's state from. * @param location The location of the stream. Used to improve the * usefulness of any exceptions thrown. * * @throws Exception if there are any problems loading the state. */ private void loadStateFromStream( InputStream is, String location ) throws Exception { // Ride on top of the Configuration classes to load the state. DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); Configuration stateConfig; if ( location == null ) { stateConfig = builder.build( is ); } else { stateConfig = builder.build( is, location ); } loadStateFromConfiguration( stateConfig ); }
/** * Creates a Configuration object from data read from an InputStream. * * @param is InputStream from which the Configuration is created. * * @return Configuration created from the InputStream * * @throws Exception If the configuration could not be processed. */ private static Configuration readConfigurationFromStream( InputStream is ) throws Exception { if( is == null ) { return null; } else { DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); Configuration config = builder.build( is ); return config; } }
public static void printToPdf(List<Pager> pagers, PixelPaper pixelPaper, OutputStream outputStream) throws Exception { printToPdf(pagers, pixelPaper, outputStream, new DefaultConfigurationBuilder().build("./config/fop-configuration.xml")); }
protected void convertSitemap(String sitemapLocation) throws Exception { if (this.logger.isDebugEnabled()) { this.logger.debug("Reading sitemap from " + sitemapLocation); } final Resource root = this.resolver.getResource(getUrl(sitemapLocation, null)); if (this.logger.isDebugEnabled()) { this.logger.debug("Resolved sitemap: " + root.getURL()); } final DefaultConfigurationBuilder b = new DefaultConfigurationBuilder(true); final Configuration config = b.build(getInputSource(root)); // validate sitemap.xmap if (!"sitemap".equals(config.getName())) { throw new ConfigurationException("Invalid sitemap\n" + config); } final Configuration completeConfig = SitemapHelper.createSitemapConfiguration(config); if (completeConfig != null) { convert(completeConfig, null, getUrl(root)); } }
protected void convert(String relativePath) throws Exception { if (this.logger.isDebugEnabled()) { this.logger.debug("Reading Avalon configuration from " + relativePath); } Resource root = this.resolver.getResource(getUrl(relativePath, null)); final DefaultConfigurationBuilder b = new DefaultConfigurationBuilder(true); final Configuration config = b.build(this.getInputSource(root)); // validate cocoon.xconf if (!"cocoon".equals(config.getName())) { throw new ConfigurationException("Invalid configuration file\n" + config); } if (this.logger.isDebugEnabled()) { this.logger.debug("Configuration version: " + config.getAttribute("version")); } if (!Constants.CONF_VERSION.equals(config.getAttribute("version"))) { throw new ConfigurationException("Invalid configuration schema version. Must be '" + Constants.CONF_VERSION + "'."); } convert(config, null, getUrl(root)); }
public void initialize() throws BeanCreationException { Source source = null; try { source = sourceResolver.resolveURI(CONFIG_LOCATION); DefaultConfigurationBuilder configurationBuilder = new DefaultConfigurationBuilder(); Configuration conf = configurationBuilder.build(source.getInputStream()); setupInstructions(conf); } catch (Exception e) { if (e instanceof BeanCreationException) throw (BeanCreationException) e; else throw new BeanCreationException("unable to parse template instructions configuration", e); } finally { if (source != null) sourceResolver.release(source); } } }
try { DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(true); includeConfig = builder.build(src.getInputStream(), uri); } catch (Exception e) { throw new ConfigurationException("Cannot load '" + uri + "' at " + includeStatement.getLocation(), e);
try { is = CryptoStreamFactory.getDecryptingInputStream(is, isEncrypted); result = builder.build(is); this.setContainerConfiguration(result); } catch (Exception e) {
result = builder.build( is ); this.setContainerConfiguration( result );
/** * Load a configuration file either from a file or using the class loader. * * @param location the location of the file * @param isEncrypted is the configuration encrypted * @return The loaded configuration * @throws Exception Something went wrong */ private Configuration loadConfiguration(String location, String isEncrypted) throws Exception { Configuration result = null; InputStreamLocator locator = this.createInputStreamLocator(); InputStream is = locator.locate(location); DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); if (is != null) { try { is = this.getDecryptingInputStream(is, isEncrypted); result = builder.build(is); } catch (Exception e) { String msg = "Unable to parse the following file : " + location; this.getLogger().error(msg, e); throw e; } finally { safeClose(is); } } return result; }
result = builder.build( is );
/** * Initializes the ComponentLocator * * @param testconf The configuration file is passed as a <code>InputStream</code> * * A common way to supply a InputStream is to overwrite the initialize() method * in the sub class, do there whatever is needed to get the right InputStream object * supplying a conformant xtest configuartion and pass it to this initialize method. * the mentioned initialize method is also the place to set a different logging priority * to the member variable m_logPriority. */ protected final void prepare( final InputStream testconf ) throws Exception { getLogger().debug( "ExcaliburTestCase.initialize" ); final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); final Configuration conf = builder.build( testconf ); String annotation = conf.getChild( "annotation" ).getValue( null ); if( ( null != annotation ) && !( "".equals( annotation ) ) ) { m_logger.info( annotation ); } Context context = setupContext( conf.getChild( "context" ) ); setupManagers( conf.getChild( "components" ), conf.getChild( "roles" ), conf.getChild( "logkit" ), context ); manager = m_manager; setCurrentLogger( "prepare" ); }
return configBuilder.build( src.getInputStream(), src.getURI() );
Configuration configuration = builder.build(is); is.close(); is = null;