org.apache.avalon.framework.configuration.Configuration.getLocation()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.apache.avalon.framework.configuration.Configuration.getLocation()方法的一些代码示例,展示了Configuration.getLocation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getLocation()方法的具体详情如下:
包路径:org.apache.avalon.framework.configuration.Configuration
类名称:Configuration
方法名:getLocation

Configuration.getLocation介绍

[英]Return a string describing location of Configuration. Location can be different for different mediums (ie "file:line" for normal XML files or "table:primary-key" for DB based configurations);
[中]返回描述配置位置的字符串。不同介质的位置可能不同(即普通XML文件的“文件:行”或基于数据库的配置的“表:主键”);

代码示例

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

public String getLocation() {
  return this.configuration.getLocation();
}

代码示例来源:origin: org.apache.avalon.framework/avalon-framework-api

public String getMessage()
  {
    StringBuffer message = new StringBuffer(super.getMessage());

    if (null != m_config)
    {
      message.append(" @");
      message.append(m_config.getLocation());
    }

    return message.toString();
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

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;
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

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;
  }
};

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

/**
   * 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);
    }
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

/**
 * @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);
    }
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

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;
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

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);
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

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);
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-linkrewriter-impl

/**
 * 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();
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

/**
 * 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;
}

代码示例来源:origin: org.apache.avalon.framework/avalon-framework-impl

/**
 * 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 );
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

/**
 * 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;
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

label = SitemapLanguage.LAST_POS_LABEL;
} else {
  String msg = "Bad value for 'from-position' at " + config.getLocation();
  throw new ConfigurationException(msg);

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

+ config.getLocation());
  config.getLocation());

代码示例来源:origin: com.whirlycott/whirlycache

/**
* 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());
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

} else {
  String msg = "Unknown element " + name + " in action-set at " + childConfig.getLocation();
  throw new ConfigurationException(msg);

代码示例来源:origin: org.apache.excalibur.containerkit/excalibur-logger

/**
 * 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 );
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

config.getLocation());

代码示例来源:origin: org.apache.excalibur.containerkit/excalibur-logger

+ "' at " + configs[ i ].getLocation() );

相关文章