[jboss-user] [JBoss Microcontainer] - How to avoid canonical conversion of AbstractInjectionValueMetaData's value?

Ales Justin do-not-reply at jboss.com
Fri Apr 9 11:45:35 EDT 2010


Ales Justin [http://community.jboss.org/people/alesj] replied to the discussion

"How to avoid canonical conversion of AbstractInjectionValueMetaData's value?"

To view the discussion, visit: http://community.jboss.org/message/536607#536607

--------------------------------------------------------------
> I was just wondering how you were able to register non-canonicalized named bean.
Asked too soon. :-)
The name is un-touched, but we do add an alias if it looks like ObjectName.

/**
    * Set the aliases<p>
    * 
    * Aliases in this list only take effect if they are set before installation on the controller
    * 
    * @param aliases the aliases
    */
   public void setAliases(Set<Object> aliases)
   {
      // WARNING: This code is hack for backwards compatiblity
      
      // Here we fixup the aliases to map JMX like ObjectNames to their canonical form
      // I've made it a protected method needsAnAlias so others can subclass and
      // change the rules (including not doing this at all)
      // NOTE: This method should be invoked from all constructors
      if (aliases == null)
      {
         // There are no explicit aliases so just see whether the name is an ObjectName.
         Object alias = needsAnAlias(name);
         // No alias required
         if (alias == null)
            this.aliases = null;
         else
            // Add a single alias with canonical name
            this.aliases = Collections.singleton(alias);
      }
      else
      {
         // Always clone the aliases passed it
         this.aliases = new HashSet<Object>();
         // Check the main name
         Object alias = needsAnAlias(name);
         if (alias != null)
            this.aliases.add(alias);
         // Check the aliases
         for (Object passedAlias : aliases)
         {
            this.aliases.add(passedAlias);
            alias = needsAnAlias(passedAlias);
            if (alias != null)
               this.aliases.add(alias);
         }
      }
   }


So, your injection should be able to match it no matter which form (canonical or not) you use,
since it should always be able to hit canonicalized, either from actual name or its alias.

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

Reply to this message by going to Community
[http://community.jboss.org/message/536607#536607]

Start a new discussion in JBoss Microcontainer at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2114]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100409/17120461/attachment.html 


More information about the jboss-user mailing list