[jboss-user] [JBoss Microcontainer Development] New message: "Re: ScopeInfo's MetaData handling looks inconsistent"

Ales Justin do-not-reply at jboss.com
Sun Feb 7 17:42:27 EST 2010


User development,

A new message was posted in the thread "ScopeInfo's MetaData handling looks inconsistent":

http://community.jboss.org/message/524656#524656

Author  : Ales Justin
Profile : http://community.jboss.org/people/alesj

Message:
--------------------------------------------------------------
I added this patch, which does lazy init on ControllerContext::getScopeInfo::getMetaData.
Or is keeping ControllerContext around bad aka too leaky?
 
This does remove the need for MDR::getMetaData call, which would otherwise initialize MDR.
 
Index: dependency/src/main/java/org/jboss/dependency/plugins/AbstractScopeInfo.java
===================================================================
--- dependency/src/main/java/org/jboss/dependency/plugins/AbstractScopeInfo.java    (revision 76911)
+++ dependency/src/main/java/org/jboss/dependency/plugins/AbstractScopeInfo.java    Sun Feb 07 23:37:34 CET 2010
@@ -64,7 +64,10 @@
 
    /** The added scopes */
    private CopyOnWriteArraySet<ScopeKey> addedScopes = new CopyOnWriteArraySet<ScopeKey>();
-   
+
+   /** The owning context */
+   private ControllerContext context;
+
    /**
     * Create a new AbstractScopeInfo.
     * 
@@ -110,13 +113,21 @@
    {
       if (repository == null)
          return null;
-      
+
-      return repository.getMetaData(getScope());
+      MetaData metaData = repository.getMetaData(getScope());
+      if (metaData == null)
+      {
+         initMetaDataRetrieval(repository, context);
+         metaData = repository.getMetaData(scopeKey);
-   }
+      }
+      return metaData;
+   }
 
    public void addMetaData(MutableMetaDataRepository repository, ControllerContext context)
    {
       this.repository = repository;
+      this.context = context;
+
       ScopeKey scope = getMutableScope();
       MetaDataRetrieval retrieval = repository.getMetaDataRetrieval(scope);
       MutableMetaDataLoader mutable;
@@ -130,7 +141,7 @@
       {
          mutable = getMutableMetaDataLoader(retrieval);
       }
-      
+
       if (mutable == null)
       {
          log.warn("MetaData context is not mutable: " + retrieval + " for " + context.toShortString());
@@ -176,8 +187,9 @@
          }
       }
       addedScopes.clear();
-      this.repository = null;
-      
+
+      this.context = null;
+      this.repository = null;
    }
 
    /**




--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/524656#524656




More information about the jboss-user mailing list