bloritsch 2002/12/12 11:39:57
Modified: fortress/src/java/org/apache/excalibur/fortress/role
RoleEntry.java RoleManager.java
Log:
make changes to the RoleEntry and RoleManager
Revision Changes Path
1.2 +55 -4
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/role/RoleEntry.java
Index: RoleEntry.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/role/RoleEntry.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RoleEntry.java 10 Nov 2002 16:16:43 -0000 1.1
+++ RoleEntry.java 12 Dec 2002 19:39:57 -0000 1.2
@@ -8,48 +8,99 @@
package org.apache.excalibur.fortress.role;
/**
+ * Keeps track of the relationship of all the associated meta data for a
+ * component type. It records the role, short name, component class, and
+ * the handler class used to manage it. The short name is included strictly
+ * to enable "self-healing" configuration files.
*
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
* @version $Revision$ $Date$
*/
public class RoleEntry
{
+ private final String m_shortName;
private final String m_role;
private final Class m_componentClass;
private final Class m_handlerClass;
+ /**
+ * Create a <code>RoleEntry</code> with all the associated information.
+ * All arguments must be supplied.
+ *
+ * @param role Role name for this component type
+ * @param shortname Short name for this component type
+ * @param componentClass <code>Class</code> to instantiate the
+ * component type
+ * @param handlerClass <code>Class</code> to instantiate the
+ * component handler
+ *
+ * @throws <code>IllegalArgumentException</code> if any argument is
+ * <code>null</code>.
+ */
public RoleEntry( final String role,
+ final String shortName,
final Class componentClass,
final Class handlerClass )
{
if( null == role )
{
- throw new NullPointerException( "role" );
+ throw new IllegalArgumentException( "\"role\" cannot be null." );
+ }
+ if( null == shortName )
+ {
+ throw new IllegalArgumentException( "\"shortname\" cannot be null." );
}
if( null == componentClass )
{
- throw new NullPointerException( "componentClass" );
+ throw new IllegalArgumentException( "\"componentClass\" cannot be
null." );
}
if( null == handlerClass )
{
- throw new NullPointerException( "handlerClass" );
+ throw new IllegalArgumentException( "\"handlerClass\" cannot be null."
);
}
m_role = role;
+ m_shortName = shortName;
m_componentClass = componentClass;
m_handlerClass = handlerClass;
}
+ /**
+ * Get the role name for the component type.
+ *
+ * @return the role name
+ */
public String getRole()
{
return m_role;
}
+
+ /**
+ * Get the short name for the component type. This is used in
+ * "self-healing" configuration files.
+ *
+ * @return the short name
+ */
+ public String getShortname()
+ {
+ return m_shortName;
+ }
+ /**
+ * Get the <code>Class</code> for the component type.
+ *
+ * @return the <code>Class</code>
+ */
public Class getComponentClass()
{
return m_componentClass;
}
+ /**
+ * Get the <code>Class</code> for the component type's {@link ComponentHandler}.
+ *
+ * @return the <code>Class</code>
+ */
public Class getHandlerClass()
{
return m_handlerClass;
1.5 +26 -3
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/role/RoleManager.java
Index: RoleManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/role/RoleManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RoleManager.java 11 Nov 2002 00:10:01 -0000 1.4
+++ RoleManager.java 12 Dec 2002 19:39:57 -0000 1.5
@@ -51,8 +51,10 @@
/**
* RoleManager Interface, use this to specify the Components and how they
- * correspond to easy shorthand names. The RoleManager assumes a flat
- * relationship of shorthand names to classes, and classes to roles.
+ * correspond to easy shorthand names. The RoleManager assumes a one to one
+ * relationship of shorthand names to classes, and a flat relationship of
+ * classes to roles. Any one role can have multiple classes associated with
+ * it.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
@@ -61,9 +63,30 @@
*/
public interface RoleManager
{
+ /**
+ * Convenience constant to make lookup of the RoleManager easer.
+ */
String ROLE = RoleManager.class.getName();
+ /**
+ * Get a <code>RoleEntry</code> for a short name. The short name is an
+ * alias for a component type.
+ *
+ * @param shortname The shorthand name for the component type.
+ *
+ * @return the proper {@link RoleEntry}
+ */
RoleEntry getRoleForShortName( String shortname );
+ /**
+ * Get a <code>RoleEntry</code> for a component type. This facilitates
+ * self-healing configuration files where the container reads the
+ * configuration and translates all <code><component/></code>
+ * entries to use the short hand name for readability.
+ *
+ * @param classname The component type name
+ *
+ * @return the proper {@link RoleEntry}
+ */
RoleEntry getRoleForClassname( String classname );
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>