public String getLocation() { return this.configuration.getLocation(); }
public String getMessage() { StringBuffer message = new StringBuffer(super.getMessage()); if (null != m_config) { message.append(" @"); message.append(m_config.getLocation()); } return message.toString(); } }
protected boolean isParameter(Configuration config) throws ConfigurationException { final String name = config.getName(); if (name.equals("parameter")) { if (this.hasParameters()) { return true; } String msg = "Element '" + name + "' has no parameters at " + config.getLocation(); throw new ConfigurationException(msg); } return false; }
public Location getLocation(Object obj, String description) { if (obj instanceof Configuration) { Configuration config = (Configuration)obj; String locString = config.getLocation(); Location result = LocationUtils.parse(locString); if (LocationUtils.isKnown(result)) { // Add description StringBuffer desc = new StringBuffer().append('<'); // Unfortunately Configuration.getPrefix() is not public try { if (config.getNamespace().startsWith("http://apache.org/cocoon/sitemap/")) { desc.append("map:"); } } catch (ConfigurationException e) { // no namespace: ignore } desc.append(config.getName()).append('>'); return new LocationImpl(desc.toString(), result); } else { return result; } } // Try next finders. return null; } };
/** * Check if the namespace URI of the given configuraition is the same as the * one given by the builder. */ protected void checkNamespace(Configuration config) throws ConfigurationException { if (!this.treeBuilder.getNamespace().equals(config.getNamespace())) { String msg = "Invalid namespace '" + config.getNamespace() + "' at " + config.getLocation(); throw new ConfigurationException(msg); } } }
/** * @see Configurable#configure(Configuration) */ public void configure(final Configuration config) throws ConfigurationException { final Configuration[] instances = config.getChildren(); for (int i = 0; i < instances.length; i++) { final Configuration instance = instances[i]; final String name = instance.getAttribute("name").trim(); final String className = instance.getAttribute("builder").trim(); try { if (getLogger().isDebugEnabled()) { getLogger().debug("Adding builder (" + name + " = " + className + ")"); } final Class clazz = getClass().getClassLoader().loadClass(className); final BuilderInfo info = new BuilderInfo(); info.builderClass = clazz; info.configuration = instance; this.componentInfos.put(name, info); } catch (final ClassNotFoundException cnfe) { final String message = "Could not get class (" + className + ") for builder " + name + " at " + instance.getLocation(); throw new ConfigurationException(message, cnfe); } catch (final Exception e) { final String message = "Unexpected exception when setting up builder " + name + " at " + instance.getLocation(); throw new ConfigurationException(message, e); } } }
public ProcessingNode buildNode(Configuration config) throws Exception { CategoryNode node = new CategoryNode(null); this.treeBuilder.setupNode(node, config); // Get all children and associate them to their name Map category = new HashMap(); List children = buildChildNodesList(config); Iterator iter = children.iterator(); while(iter.hasNext()) { NamedProcessingNode child = (NamedProcessingNode)iter.next(); category.put(child.getName(), child); } node.setCategory(this.name, category); // Register node to allow lookup by other nodes if ( !this.treeBuilder.registerNode(PREFIX + this.name, node) ) { throw new ConfigurationException("Only one <map:" + this.name + "> is allowed in a sitemap. Another one is declared at " + config.getLocation()); } return node; }
protected Configuration getAndCreateConfiguration(Configuration config, String name) { if (config.getChild(name, false) == null) { final DefaultConfiguration newConfig = new DefaultConfiguration(name, config.getLocation()); ((DefaultConfiguration) config).addChild(newConfig); } return config.getChild(name, false); }
protected void setupNode(ContainerNode node, Configuration config)throws Exception { this.treeBuilder.setupNode(node, config); ProcessingNode[] children = buildChildNodes(config); if (children.length == 0) { String msg = "There must be at least one child at " + config.getLocation(); throw new ConfigurationException(msg); } node.setChildren(children); } }
/** * Get a generated Configuration with interpolated variable values. * @return The Configuration passed in the constructor, with {variable} * tokens in attributes and element bodies replaced with values (if * specified), or <code>null</code>. */ public Configuration getConfiguration() throws SAXException, ConfigurationException { if (this.conf == null) return null; InterpolatingConfigurationHandler handler = new InterpolatingConfigurationHandler(this.vars, this.conf.getLocation()); DefaultConfigurationSerializer ser = new DefaultConfigurationSerializer(); ser.serialize(handler, this.conf); return handler.getConfiguration(); }
/** * Create the <code>ProcessingNode</code>s for the children of a given node. * Child nodes are controlled to be actually allowed in this node. */ protected List buildChildNodesList(Configuration config) throws Exception { Configuration[] children = config.getChildren(); List result = new ArrayList(); for (int i = 0; i < children.length; i++) { Configuration child = children[i]; try { if (isChild(child)) { // OK : get a builder. ProcessingNodeBuilder childBuilder = this.treeBuilder.createNodeBuilder(child); result.add(childBuilder.buildNode(child)); } } catch(ConfigurationException ce) { throw ce; } catch(Exception e) { String msg = "Error while creating node '" + child.getName() + "' at " + child.getLocation(); throw new ConfigurationException(msg, e); } } return result; }
/** * Copy constructor, to create a clone of another configuration. * To modify children, use <code>getChild()</code>, * <code>removeChild()</code> and <code>addChild()</code>. * * @param config the <code>Configuration</code> to copy * @param deepCopy true will cause clones of the children to be added, * false will add the original instances and is thus * faster. * * @throws ConfigurationException if an error occurs when copying */ public DefaultConfiguration( Configuration config, boolean deepCopy ) throws ConfigurationException { this( config.getName(), config.getLocation(), config.getNamespace(), ( (config instanceof AbstractConfiguration) ? ((AbstractConfiguration)config).getPrefix() : "") ); addAll( config, deepCopy ); }
/** * Get the type for a statement : it returns the 'type' attribute if * present, and otherwhise the default type defined for this role in the * components declarations. * * @throws ConfigurationException * if the type could not be found. */ public String getTypeForStatement(Configuration statement, String role) throws ConfigurationException { // Get the component type for the statement String type = statement.getAttribute("type", null); if (type == null) { type = this.itsComponentInfo.getDefaultType(role); } if (type == null) { throw new ConfigurationException("No default type exists for 'map:" + statement.getName() + "' at " + statement.getLocation()); } final String beanName = role + '/' + type; if ( !this.itsContainer.containsBean(beanName) ) { throw new ConfigurationException("Type '" + type + "' does not exist for 'map:" + statement.getName() + "' at " + statement.getLocation()); } return type; }
label = SitemapLanguage.LAST_POS_LABEL; } else { String msg = "Bad value for 'from-position' at " + config.getLocation(); throw new ConfigurationException(msg);
+ config.getLocation()); config.getLocation());
/** * Configure the cache using a Configuration object. */ public void configure(final Configuration configuration) throws ConfigurationException { final Configuration backend = configuration.getChild(Constants.CONFIG_BACKEND); final Configuration policy = configuration.getChild(Constants.CONFIG_POLICY); cacheConfiguration = new CacheConfiguration(); cacheConfiguration.setName(configuration.getChild(Constants.CONFIG_NAME).getValue(toString())); cacheConfiguration.setBackend(backend.getValue()); cacheConfiguration.setMaxSize(configuration.getChild(Constants.CONFIG_MAXSIZE).getValueAsInteger()); cacheConfiguration.setPolicy(policy.getValue()); cacheConfiguration.setTunerSleepTime(configuration.getChild(Constants.CONFIG_TUNER_SLEEPTIME).getValueAsInteger()); managedCacheClass = loadManagedCacheClass(backend.getLocation()); cacheMaintenancePolicyClass = loadCacheMaintenancePolicyClass(policy.getLocation()); }
} else { String msg = "Unknown element " + name + " in action-set at " + childConfig.getLocation(); throw new ConfigurationException(msg);
/** * Create a LogTarget based on a Configuration */ public LogTarget createTarget( final Configuration configuration ) throws ConfigurationException { OutputStream stream; final Configuration streamConfig = configuration.getChild( "stream", false ); if( null == streamConfig ) { stream = System.err; } else { final String streamName = streamConfig.getValue(); try { stream = (OutputStream)m_context.get( streamName ); } catch( Exception e ) { throw new ConfigurationException( "Error resolving stream '" + streamName + "' at " + streamConfig.getLocation(), e ); } } final Configuration formatterConf = configuration.getChild( "format" ); final Formatter formatter = getFormatter( formatterConf ); return new StreamTarget( stream, formatter ); }
+ "' at " + configs[ i ].getLocation() );