1 4 5 package org.jboss.kernel.plugins.deployment.xml; 6 7 import javax.xml.namespace.NamespaceContext ; 8 import javax.xml.namespace.QName ; 9 10 import org.jboss.beans.metadata.plugins.InjectionType; 11 import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData; 12 import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData; 13 import org.jboss.dependency.spi.ControllerState; 14 import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler; 15 import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding; 16 import org.xml.sax.Attributes ; 17 18 24 public class InjectionHandler extends DefaultElementHandler 25 { 26 27 public static final InjectionHandler HANDLER = new InjectionHandler(); 28 29 public Object startElement(Object parent, QName name, ElementBinding element) 30 { 31 AbstractInjectionValueMetaData vmd = new AbstractInjectionValueMetaData(); 32 if (parent instanceof AbstractPropertyMetaData) 33 { 34 AbstractPropertyMetaData x = (AbstractPropertyMetaData) parent; 35 vmd.setPropertyMetaData(x); 36 } 37 return vmd; 38 } 39 40 public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx) 41 { 42 AbstractInjectionValueMetaData injection = (AbstractInjectionValueMetaData) o; 43 for (int i = 0; i < attrs.getLength(); ++i) 44 { 45 String localName = attrs.getLocalName(i); 46 if ("bean".equals(localName)) 47 injection.setValue(attrs.getValue(i)); 48 else if ("property".equals(localName)) 49 injection.setProperty(attrs.getValue(i)); 50 else if ("state".equals(localName)) 51 injection.setDependentState(new ControllerState(attrs.getValue(i))); 52 else if ("whenRequired".equals(localName)) 53 injection.setWhenRequiredState(new ControllerState(attrs.getValue(i))); 54 else if ("type".equals(localName)) 55 injection.setInjectionType(new InjectionType(attrs.getValue(i))); 56 } 57 } 58 59 } 60 | Popular Tags |