/*
* Created on Mar 31, 2003
*/
package net.sf.jportlet.portlet.descriptor;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.sf.jportlet.portlet.PortletException;
/**
* The <code>ApplicationDescriptor</code> describes the portlet application
*
* @author <a href="mailto:tchbansi@sourceforge.net">Herve Tchepannou</a>
*/
public class ApplicationDescriptor
{
//~ Static fields/initializers ---------------------------------------------
private static final Log __log = LogFactory.getLog( ApplicationDescriptor.class );
//~ Instance fields --------------------------------------------------------
private String _name;
/** Map of {@link PortletDescriptor indexed by their name */
private HashMap _portletDescriptors = new HashMap( );
/** Map of init-parameters. indexed by their name */
private HashMap _contextParameters = new HashMap( );
//~ Methods ----------------------------------------------------------------
public void addContextParameter( String name,
String value )
{
if ( __log.isDebugEnabled( ) )
{
__log.debug( "context-param:" + name + "=" + value );
}
_contextParameters.put( name, value );
}
public String getContextParameter( String name )
{
return ( String ) _contextParameters.get( name );
}
public Enumeration getContextParameterNames( )
{
return Collections.enumeration( _contextParameters.keySet( ) );
}
public void addPortletDescriptor( PortletDescriptor descriptor )
throws PortletException
{
String name = descriptor.getName( );
if ( __log.isDebugEnabled( ) )
{
__log.debug( "Adding Portlet. name=" + name );
}
if ( _portletDescriptors.put( name, descriptor ) != null )
{
throw new PortletException( "Duplicate portlet: " + name );
}
}
public String getName( )
{
return _name;
}
public Collection getPortletDescriptors( )
{
return _portletDescriptors.values( );
}
public PortletDescriptor getPortletDescriptor( String name )
{
return ( PortletDescriptor ) _portletDescriptors.get( name );
}
public void setName( String name )
{
_name = name;
}
}