[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Does ScopeKey need to maintain a sorted (in ScopeLevel.l

smarlow@redhat.com do-not-reply at jboss.com
Wed Aug 12 10:16:29 EDT 2009


"adrian at jboss.org" wrote : 
  | 2) The other is as I mention above. Use the ScopeKey as the builder class
  | and retrieve a more optimizated key for internal use within the MDR.
  | 
  | e.g. something like:
  | 
  |   | public class ScopeKey
  |   | {
  |   |    ...
  |   | 
  |   |    Object getOptimzedKey() {} // Key for use at runtime
  |   | }
  |   | 
  | 
  | In fact (1) and (2) are just variations on the same theme, with (2) potentially
  | being more optimal.
  | 

I'm trying to do (2) as follows.


  | public class ScopeKey
  | {
  |    ...
  | 
  |    /**
  |     * The returned ScopeKey is immutable and optimized for use at runtime.
  |     * @return Optimized immutable ScopeKey
  |     */
  |    public ScopeKey getOptimizedKey()
  |    {
  |       return new UnmodifiableScopeKey(this);
  |    }
  | 
  | }
  | 

Where UnmodifiableScopeKey is similar to the code that I previously posted.  

There is a dependency between UnmodifiableScopeKey + ScopeKey that needs to be manually maintained but maybe I could test for that in a UnmodifiableScopeKey unit test.  UnmodifiableScopeKey extends ScopeKey and overides all of the public ScopeKey methods.

The (work in progress) UnmodifiableScopeKey source is here http://pastebin.com/m5d484e25

Does UnmodifiableScopeKey work for everyone?  I assume this  will work as the optimizedKey.


View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4249231#4249231

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4249231



More information about the jboss-dev-forums mailing list