[jbossseam-issues] [JBoss JIRA] Closed: (JBSEAM-111) Check for duplicate component name on registration
Gavin King (JIRA)
jira-events at jboss.com
Tue Nov 21 04:22:47 EST 2006
[ http://jira.jboss.com/jira/browse/JBSEAM-111?page=all ]
Gavin King closed JBSEAM-111.
-----------------------------
> Check for duplicate component name on registration
> --------------------------------------------------
>
> Key: JBSEAM-111
> URL: http://jira.jboss.com/jira/browse/JBSEAM-111
> Project: JBoss Seam
> Issue Type: Patch
> Components: Core
> Affects Versions: 1.0 beta 1
> Reporter: Jye Tucker
> Assigned To: Thomas Heute
> Priority: Trivial
> Fix For: 1.1.0.BETA1
>
>
> Issues a warning when you try to register a component with a name that has previously been registered. Also wrapped addComponent methods and moved the ".component" suffix to a static variable.
> Index: Initialization.java
> ===================================================================
> RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/init/Initialization.java,v
> retrieving revision 1.23
> diff -u -r1.23 Initialization.java
> --- Initialization.java 28 Nov 2005 14:09:13 -0000 1.23
> +++ Initialization.java 4 Dec 2005 13:17:50 -0000
> @@ -44,6 +44,8 @@
> */
> public class Initialization
> {
> + public static final String COMPONENT_SUFFIX = ".component";
> +
> private static final Logger log = Logger.getLogger(Seam.class);
>
> private Map<String, String> properties = new HashMap<String, String>();
> @@ -160,15 +162,30 @@
>
> }
>
> - protected void addComponent(String name, Class clazz, Context context)
> - {
> - context.set( name + ".component", new Component(clazz, name) );
> + protected void addComponent(String name, Class clazz, Context context) {
> + if (isComponentRegistered(name, context)) {
> + log.warn("Component name '" + name + "' has been previously registered. May experience unexpected behaviour");
> + }
> + context.set(name + COMPONENT_SUFFIX, new Component(clazz, name));
> + }
> +
> + protected void addComponent(Class clazz, Context context) {
> + addComponent(Seam.getComponentName(clazz), clazz, context);
> + }
> +
> + /**
> + *
> + * @param name The name of the component
> + * @param context The context to inspect
> + * @return True if a component with the specified name exists in context
> + */
> + protected boolean isComponentRegistered(String name, Context context) {
> + if (context.get(name + COMPONENT_SUFFIX) != null) {
> + return true;
> + }
> + return false;
> }
>
> - protected void addComponent(Class clazz, Context context)
> - {
> - context.set( Seam.getComponentName(clazz) + ".component", new Component(clazz) );
> - }
>
> public boolean isScannerEnabled()
> {
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the seam-issues
mailing list