[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: enums, generics and other animals

adrian@jboss.org do-not-reply at jboss.com
Fri Mar 7 11:53:52 EST 2008


"alesj" wrote : 
  | How do you use this with attributes?
  | 

JBossXB will do it automatically.

1) attribute qName="urn:jboss:deployer-beans:2.0:option"
2) type qName="urn:jboss:deployer-beans:2.0:optionType"
3) convert to an object according to the config on that TypeBinding i.e. the ValueAdapter

But looking again, the problem is that we aren't using the AttributeBinding callback for
these, we're looking at the attributes directly which are just strings. :-(

See DefaultElementHandler


  | 
  |    // Don't override this
  |    public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
  |    {
  |       if(attrsHandler != null)
  |       {
  |          attrsHandler.attributes(o, elementName, element.getType(), attrs, nsCtx);
  |       }
  |    }
  | 
  |    // Set an attribute handler on the constructor
  |    public DefaultElementHandler(AttributesHandler attrsHandler)
  |    {
  |       this.attrsHandler = attrsHandler;
  |    }
  | 

i.e. 

  | 
  | public class MyAttributeHandler extends AttributeHander
  | {
  |    public void attribute(QName elemName,
  |                                   QName attrName,
  |                                   AttributeBinding binding,
  |                                   Object owner,
  |                                   Object value)
  |     {
  |        AbstractInjectionValueMetaData injection = (AbstractInjectionValueMetaData) owner;   
  | 
  |         String localName = attrName.getLocalPart();
  |          ...
  |          else if ("type".equals(localName))
  |             injection.setInjectionType((AutowireType) value)
  |    }
  | }
  | 

But I'm not sure it is worth doing all this work, since these classes are going away soon.

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

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



More information about the jboss-dev-forums mailing list