You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by sg...@apache.org on 2005/03/01 11:46:41 UTC
cvs commit: jakarta-turbine-fulcrum/yaafi/src/java/org/apache/fulcrum/yaafi/framework/role RoleConfigurationParser.java RoleConfigurationParserImpl.java RoleEntry.java RoleEntryImpl.java
sgoeschl 2005/03/01 02:46:41
Added: yaafi/src/java/org/apache/fulcrum/yaafi/framework/role
RoleConfigurationParser.java
RoleConfigurationParserImpl.java RoleEntry.java
RoleEntryImpl.java
Log:
Synchronizing my development CVS with Fulrum
Revision Changes Path
1.1 jakarta-turbine-fulcrum/yaafi/src/java/org/apache/fulcrum/yaafi/framework/role/RoleConfigurationParser.java
Index: RoleConfigurationParser.java
===================================================================
package org.apache.fulcrum.yaafi.framework.role;
/*
* Copyright 2004 Apache Software Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
/**
* Parses the role configuration file of various Avalon containers.
*
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
public interface RoleConfigurationParser
{
/**
* Parses a role configuration file.
*
* @param roleConfiguration the role configuration file to parse
* @return the parsed RoleEntries
* @exception ConfigurationException parsing the configuration failesw
*/
public RoleEntry[] parse( Configuration roleConfiguration )
throws ConfigurationException;
}
1.1 jakarta-turbine-fulcrum/yaafi/src/java/org/apache/fulcrum/yaafi/framework/role/RoleConfigurationParserImpl.java
Index: RoleConfigurationParserImpl.java
===================================================================
package org.apache.fulcrum.yaafi.framework.role;
/*
* Copyright 2004 Apache Software Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.fulcrum.yaafi.framework.constant.AvalonFortressConstants;
import org.apache.fulcrum.yaafi.framework.constant.AvalonPhoenixConstants;
import org.apache.fulcrum.yaafi.framework.constant.AvalonYaafiConstants;
import org.apache.fulcrum.yaafi.framework.util.Validate;
/**
* Parses the role configuration file of various Avalon containers.
*
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
public class RoleConfigurationParserImpl
implements RoleConfigurationParser
{
/** The flavour of Avalon container */
private String containerFlavour;
/**
* Constructor
* @param containerFlavour The flavour of Avalon container
*/
public RoleConfigurationParserImpl( String containerFlavour )
{
Validate.notEmpty( containerFlavour, "containerFlavour" );
this.containerFlavour = containerFlavour;
}
/**
* Parses a role configuration file.
*
* @param roleConfiguration the role configuration file to parse
* @return the parsed RoleEntries
*/
public RoleEntry[] parse( Configuration roleConfiguration )
throws ConfigurationException
{
Validate.notNull( roleConfiguration, "roleConfiguration" );
if( AvalonYaafiConstants.AVALON_CONTAINER_YAAFI.equals(containerFlavour) )
{
return mapFromYaafi(roleConfiguration);
}
if( AvalonPhoenixConstants.AVALON_CONTAINER_PHOENIX.equals(containerFlavour) )
{
return mapFromPhoenix(roleConfiguration);
}
else if( AvalonFortressConstants.AVALON_CONTAINER_FORTESS.equals(containerFlavour) )
{
return mapFromFortress(roleConfiguration);
}
else
{
String msg = "Don't know the following container flavour : " + containerFlavour;
throw new IllegalArgumentException(msg);
}
}
/**
* Parses a YAAFI role configuration file.
*/
private RoleEntry[] mapFromYaafi( Configuration roleConfiguration )
throws ConfigurationException
{
String clazzName = null;
String name = null;
String shorthand = null;
boolean isEarlyInit = false;
String description = null;
String componentType = null;
String componentFlavour = null;
RoleEntry roleEntry = null;
Configuration[] list = roleConfiguration.getChildren( "role" );
RoleEntry[] result = new RoleEntry[list.length];
for( int i=0; i<list.length; i++ )
{
clazzName = list[i].getAttribute("default-class");
name = list[i].getAttribute("name",clazzName);
shorthand = list[i].getAttribute("shorthand",name);
isEarlyInit = list[i].getAttributeAsBoolean("early-init",true);
description = list[i].getAttribute("description",null);
componentType = list[i].getAttribute("component-type","avalon");
componentFlavour = list[i].getAttribute("component-flavour", AvalonYaafiConstants.AVALON_CONTAINER_YAAFI);
roleEntry = new RoleEntryImpl(
name,
clazzName,
shorthand,
isEarlyInit,
description,
componentType,
componentFlavour
);
result[i] = roleEntry;
}
return result;
}
private RoleEntry[] mapFromPhoenix( Configuration roleConfiguration )
throws ConfigurationException
{
throw new ConfigurationException("Not supported yet");
}
private RoleEntry[] mapFromFortress( Configuration roleConfiguration )
throws ConfigurationException
{
throw new ConfigurationException("Not supported yet");
}
}
1.1 jakarta-turbine-fulcrum/yaafi/src/java/org/apache/fulcrum/yaafi/framework/role/RoleEntry.java
Index: RoleEntry.java
===================================================================
/*
* Created on 21.02.2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.apache.fulcrum.yaafi.framework.role;
/**
* @author Sigi
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public interface RoleEntry
{
/**
* @return Returns the componentType.
*/
public abstract String getComponentType();
/**
* @return Returns the description.
*/
public abstract String getDescription();
/**
* @return Returns the implementationClazzName.
*/
public abstract String getImplementationClazzName();
/**
* @return Returns the isEarlyInit.
*/
public abstract boolean isEarlyInit();
/**
* @return Returns the name.
*/
public abstract String getName();
/**
* @return Returns the shorthand.
*/
public abstract String getShorthand();
/**
* @return Returns the componentFlavour.
*/
public abstract String getComponentFlavour();
}
1.1 jakarta-turbine-fulcrum/yaafi/src/java/org/apache/fulcrum/yaafi/framework/role/RoleEntryImpl.java
Index: RoleEntryImpl.java
===================================================================
package org.apache.fulcrum.yaafi.framework.role;
/*
* Copyright 2004 Apache Software Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Interface exposed by the ServiceContainerImpl
*
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
public class RoleEntryImpl implements RoleEntry
{
/** the name of the service component to be used for the service lookup */
private String name;
/** the name of the implementation class of the service component */
private String implementationClazzName;
/** the short name of the service component to lookup the configuration */
private String shorthand;
/** do we incarnate the instance of the service component during start-up? */
private boolean isEarlyInit;
/** a description for the service component if any */
private String description;
/** the type of service component, e.g. "avalon" */
private String componentType;
/** the type of service component if any, e.g. "merlin", "phoenix" or "fortress*/
private String componentFlavour;
/**
* YAAFI role entry
*
* @param name the name of the service component to be used for the service lookup
* @param defaultClass the name of the implementation class of the service component
* @param shorthand the short name of the service component
* @param earlyInit do we incarnate the instance of the service component during start-up?
* @param description a description for the service component if any
* @param componentType the type of service component
* @param componentFlavour the flavour of the gicen component type
*/
public RoleEntryImpl( String name,
String defaultClass,
String shorthand,
boolean earlyInit,
String description,
String componentType,
String componentFlavour )
{
this.name = name;
this.implementationClazzName = defaultClass;
this.shorthand = shorthand;
this.isEarlyInit = earlyInit;
this.description = description;
this.componentType = componentType;
this.componentFlavour = componentFlavour;
}
/**
* @return Returns the componentType.
*/
public String getComponentType()
{
return componentType;
}
/**
* @return Returns the description.
*/
public String getDescription()
{
return description;
}
/**
* @return Returns the implementationClazzName.
*/
public String getImplementationClazzName()
{
return implementationClazzName;
}
/**
* @return Returns the isEarlyInit.
*/
public boolean isEarlyInit()
{
return isEarlyInit;
}
/**
* @return Returns the name.
*/
public String getName()
{
return name;
}
/**
* @return Returns the shorthand.
*/
public String getShorthand()
{
return shorthand;
}
/**
* @return Returns the componentFlavour.
*/
public String getComponentFlavour()
{
return componentFlavour;
}
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
StringBuffer result = new StringBuffer();
final String newLine = System.getProperty("line.separator");
result.append(this.getClass().getName() + " Object {");
result.append(newLine);
result.append(this.getName());
result.append(";");
result.append(" class: ");
result.append(this.getImplementationClazzName());
result.append(";");
result.append(" componentType: ");
result.append(this.getComponentType());
result.append(";");
result.append(" componentFlavour: ");
result.append(this.getComponentFlavour());
result.append(";");
result.append(" shorthand: ");
result.append(this.getShorthand());
result.append(";");
result.append(" description: ");
result.append(this.getDescription());
result.append(";");
result.append("}");
return result.toString();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org