本文整理了Java中org.apache.avalon.framework.configuration.Configuration.getName()
方法的一些代码示例,展示了Configuration.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getName()
方法的具体详情如下:
包路径:org.apache.avalon.framework.configuration.Configuration
类名称:Configuration
方法名:getName
[英]Return the name of the node.
[中]返回节点的名称。
代码示例来源:origin: org.apache.excalibur.component/excalibur-component
/**
* Return this selector's configuration name or a default name if no such
* configuration was provided. This accounts for the case when a static
* component instance has been added through
* <code>addComponentInstance</code> with no associated configuration
*/
private String getName()
{
if( null != m_configuration &&
!m_configuration.getName().equals( "" ) )
{
return m_configuration.getName();
}
return DEFAULT_NAME;
}
}
代码示例来源: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.avalon.framework/avalon-framework-impl
/**
* Test to see if two Configuration's can be considered the same. Name, value, attributes
* and children are test. The <b>order</b> of children is not taken into consideration
* for equality.
*
* @param c1 Configuration to test
* @param c2 Configuration to test
* @return true if the configurations can be considered equals
*/
public static boolean equals( final Configuration c1, final Configuration c2 )
{
return c1.getName().equals( c2.getName() ) && areValuesEqual( c1, c2 ) &&
areAttributesEqual( c1, c2 ) && areChildrenEqual( c1, c2 );
}
代码示例来源:origin: org.apache.avalon.framework/avalon-framework-impl
public MutableConfiguration[] getMutableChildren( final String name ) throws ConfigurationException
{
if( null == m_children )
{
return new MutableConfiguration[ 0 ];
}
else
{
final ArrayList children = new ArrayList();
final int size = m_children.size();
for( int i = 0; i < size; i++ )
{
final Configuration configuration = (Configuration)m_children.get( i );
if( name.equals( configuration.getName() ) )
{
children.add( toMutable( configuration ) );
}
}
return (MutableConfiguration[])children.toArray( new MutableConfiguration[ 0 ] );
}
}
代码示例来源: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
protected void parseConfiguration(final Configuration configuration,
String contextURI,
Set loadedURIs)
throws ConfigurationException {
final Configuration[] configurations = configuration.getChildren();
for( int i = 0; i < configurations.length; i++ ) {
final Configuration componentConfig = configurations[i];
final String componentName = componentConfig.getName();
if ("include".equals(componentName)) {
handleInclude(contextURI, loadedURIs, componentConfig);
} else if ("include-beans".equals(componentName)) {
// we ignore include-beans if this is a child context as this has already been
// processed by the sitemap element
if (this.isRootContext) {
handleBeanInclude(contextURI, componentConfig);
}
// we ignore include-properties if this is a child context
} else if (this.isRootContext || !"include-properties".equals(componentName)) {
// Component declaration, add it to list
componentConfigs.add(componentConfig);
}
}
}
代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl
/**
* @see org.apache.cocoon.components.treeprocessor.TreeBuilder#createNodeBuilder(org.apache.avalon.framework.configuration.Configuration)
*/
public ProcessingNodeBuilder createNodeBuilder(Configuration config) throws Exception {
// FIXME : check namespace
String nodeName = config.getName();
if (getLogger().isDebugEnabled()) {
getLogger().debug("Creating node builder for " + nodeName);
}
ProcessingNodeBuilder builder;
builder = (ProcessingNodeBuilder) this.itsBuilders.getBuilder(nodeName);
builder.setBuilder(this);
if (builder instanceof LinkedProcessingNodeBuilder) {
this.linkedBuilders.add(builder);
}
return builder;
}
代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl
/**
* compatibility with 2.1.x - check for global variables in sitemap
* TODO - This will be removed in later versions!
*/
protected static Properties getGlobalSitemapVariables(Configuration sitemap)
throws ConfigurationException {
Properties variables = null;
final Configuration varConfig = sitemap.getChild("pipelines").getChild("component-configurations").getChild("global-variables", false);
if ( varConfig != null ) {
Deprecation.logger.warn("The 'component-configurations' section in the sitemap is deprecated. Please check for alternatives.");
variables = new Properties();
final Configuration[] variableElements = varConfig.getChildren();
for(int v=0; v<variableElements.length; v++) {
variables.setProperty(variableElements[v].getName(), variableElements[v].getValue());
}
}
return variables;
}
代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl
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));
}
}
代码示例来源: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.cocoon/cocoon-sitemap-impl
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));
}
代码示例来源:origin: org.apache.fulcrum/fulcrum-factory
@Override
public void configure(Configuration conf) throws ConfigurationException
{
final Configuration[] loaders = conf.getChildren(CLASS_LOADER);
if (loaders != null)
{
loaderNames = new String[loaders.length];
for (int i = 0; i < loaders.length; i++)
{
loaderNames[i] = loaders[i].getValue();
}
}
final Configuration factories = conf.getChild(OBJECT_FACTORY, false);
if (factories != null)
{
// Store the factory to the table as a string and
// instantiate it by using the service when needed.
Configuration[] nameVal = factories.getChildren();
for (Configuration entry : nameVal)
objectFactoryClasses.put(entry.getName(), entry.getValue());
}
}
代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl
/**
* Configures the database access helper.
*
* Takes all elements nested in component declaration and stores
* them as key-value pairs in <code>settings</code>. Nested
* configuration option are not catered for. This way global
* configuration options can be used.
*
* For nested configurations override this function.
* */
public void configure(Configuration conf) throws ConfigurationException {
Configuration[] parameters = conf.getChildren();
this.settings = new HashMap(parameters.length);
for (int i = 0; i < parameters.length; i++) {
String key = parameters[i].getName();
String val = parameters[i].getValue("");
this.settings.put (key, val);
}
}
代码示例来源: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.logicalcobwebs/com.springsource.org.logicalcobwebs.proxool
/**
* Check that all top level elements are named proxool and hand them to
* {@link XMLConfigurator}.
* @param configuration the configuration handed over by the Avalon Framework.
* @throws ConfigurationException if the configuration fails.
*/
public void configure(Configuration configuration) throws ConfigurationException {
final XMLConfigurator xmlConfigurator = new XMLConfigurator();
this.closeOnDispose = configuration.getAttributeAsBoolean(CLOSE_ON_DISPOSE_ATTRIBUTE, true);
final Configuration[] children = configuration.getChildren();
for (int i = 0; i < children.length; ++i) {
if (!children[i].getName().equals(ProxoolConstants.PROXOOL)) {
throw new ConfigurationException("Found element named " + children[i].getName() + ". Only "
+ ProxoolConstants.PROXOOL + " top level elements are alowed.");
}
}
try {
xmlConfigurator.startDocument();
reportProperties(xmlConfigurator, configuration.getChildren());
xmlConfigurator.endDocument();
} catch (SAXException e) {
throw new ConfigurationException("", e);
}
}
代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl
/**
* Configures the Action.
*
* Takes the children from the <code>Configuration</code> and stores them
* them as key (configuration name) and value (configuration value)
* in <code>settings</code>.
* <br/>
* This automates parsing of flat string-only configurations.
* For nested configurations, override this function in your action.
*/
public void configure(Configuration conf) throws ConfigurationException {
Configuration[] parameters = conf.getChildren();
this.settings = new HashMap(parameters.length);
for (int i = 0; i < parameters.length; i++) {
String key = parameters[i].getName();
String val = parameters[i].getValue(null);
this.settings.put(key, val);
}
}
}
代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl
/**
* Configures the module.
*
* <p>Takes all elements nested in component declaration and stores
* them as key-value pairs in <code>settings</code>. Nested
* configuration option are not catered for. This way global
* configuration options can be used.</p>
*
* <p>For nested configurations override this function.</p>
*/
public void configure(Configuration conf) throws ConfigurationException {
Configuration[] parameters = conf.getChildren();
// Ideally here should be length * 1.333(3) but simple +1 will do for lengths up to 3
this.settings = new HashMap(parameters.length + 1);
for (int i = 0; i < parameters.length; i++) {
String key = parameters[i].getName();
String val = parameters[i].getValue("");
this.settings.put(key, val);
}
}
代码示例来源:origin: com.cloudhopper.proxool/proxool
/**
* Check that all top level elements are named proxool and hand them to
* {@link XMLConfigurator}.
* @param configuration the configuration handed over by the Avalon Framework.
* @throws ConfigurationException if the configuration fails.
*/
public void configure(Configuration configuration) throws ConfigurationException {
final XMLConfigurator xmlConfigurator = new XMLConfigurator();
this.closeOnDispose = configuration.getAttributeAsBoolean(CLOSE_ON_DISPOSE_ATTRIBUTE, true);
final Configuration[] children = configuration.getChildren();
for (int i = 0; i < children.length; ++i) {
if (!children[i].getName().equals(ProxoolConstants.PROXOOL)) {
throw new ConfigurationException("Found element named " + children[i].getName() + ". Only "
+ ProxoolConstants.PROXOOL + " top level elements are alowed.");
}
}
try {
xmlConfigurator.startDocument();
reportProperties(xmlConfigurator, configuration.getChildren());
xmlConfigurator.endDocument();
} catch (SAXException e) {
throw new ConfigurationException("", e);
}
}
代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl
for (int i = 0; i < childrenConfig.length; i++) {
Configuration childConfig = childrenConfig[i];
String name = childConfig.getName();
代码示例来源:origin: org.apache.excalibur.containerkit/excalibur-logger
private MessageBuilder getMessageBuilder( final Configuration configuration )
throws ConfigurationException
{
final String messageType = configuration.getAttribute( "type", "object" );
if( "text".equals( messageType ) )
{
final Configuration[] propertyConf =
configuration.getChild( "property", true ).getChildren();
final Configuration formatterConf = configuration.getChild( "format" );
final PropertyInfo[] properties = new PropertyInfo[ propertyConf.length ];
for( int i = 0; i < properties.length; i++ )
{
final String name = propertyConf[ i ].getValue();
final int type = PropertyType.getTypeIdFor( propertyConf[ i ].getName() );
final String aux = propertyConf[ i ].getAttribute( "aux", null );
properties[ i ] = new PropertyInfo( name, type, aux );
}
final Formatter formatter = getFormatter( formatterConf );
return new TextMessageBuilder( properties, formatter );
}
return new ObjectMessageBuilder();
}
内容来源于网络,如有侵权,请联系作者删除!