Package org.jboss.kernel.plugins.deployment.xml

Source Code of org.jboss.kernel.plugins.deployment.xml.InjectionHandler

/*
*
*/

package org.jboss.kernel.plugins.deployment.xml;

import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;

import org.jboss.beans.metadata.plugins.InjectionType;
import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
import org.jboss.dependency.spi.ControllerState;
import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
import org.xml.sax.Attributes;

/**
* DependencyHandler.
*
* @author <a href="adrian@jboss.com">Adrian Brock</a>
* @version $Revision: 43106 $
*/
public class InjectionHandler extends DefaultElementHandler
{
   /** The handler */
   public static final InjectionHandler HANDLER = new InjectionHandler();

   public Object startElement(Object parent, QName name, ElementBinding element)
   {
      AbstractInjectionValueMetaData vmd = new AbstractInjectionValueMetaData();
      if (parent instanceof AbstractPropertyMetaData)
      {
         AbstractPropertyMetaData x = (AbstractPropertyMetaData) parent;
         vmd.setPropertyMetaData(x);
      }
      return vmd;
   }

   public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
   {
      AbstractInjectionValueMetaData injection = (AbstractInjectionValueMetaData) o;
      for (int i = 0; i < attrs.getLength(); ++i)
      {
         String localName = attrs.getLocalName(i);
         if ("bean".equals(localName))
            injection.setValue(attrs.getValue(i));
         else if ("property".equals(localName))
            injection.setProperty(attrs.getValue(i));
         else if ("state".equals(localName))
            injection.setDependentState(new ControllerState(attrs.getValue(i)));
         else if ("whenRequired".equals(localName))
            injection.setWhenRequiredState(new ControllerState(attrs.getValue(i)));
         else if ("type".equals(localName))
            injection.setInjectionType(new InjectionType(attrs.getValue(i)));
      }
   }

}
TOP

Related Classes of org.jboss.kernel.plugins.deployment.xml.InjectionHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.