1 22 package org.jboss.kernel.plugins.deployment.xml; 23 24 import javax.xml.namespace.NamespaceContext ; 25 import javax.xml.namespace.QName ; 26 27 import org.jboss.beans.metadata.plugins.AbstractInstallMetaData; 28 import org.jboss.dependency.spi.ControllerState; 29 import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler; 30 import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding; 31 import org.xml.sax.Attributes ; 32 33 39 public class InstallHandler extends DefaultElementHandler 40 { 41 42 public static final InstallHandler HANDLER = new InstallHandler(); 43 44 public Object startElement(Object parent, QName name, ElementBinding element) 45 { 46 return new AbstractInstallMetaData(); 47 } 48 49 public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx) 50 { 51 AbstractInstallMetaData install = (AbstractInstallMetaData) o; 52 for (int i = 0; i < attrs.getLength(); ++i) 53 { 54 String localName = attrs.getLocalName(i); 55 if ("bean".equals(localName)) 56 install.setBean(attrs.getValue(i)); 57 else if ("method".equals(localName)) 58 install.setMethodName(attrs.getValue(i)); 59 else if ("state".equals(localName)) 60 install.setDependentState(new ControllerState(attrs.getValue(i))); 61 } 62 } 63 64 public Object endElement(Object o, QName qName, ElementBinding element) 65 { 66 AbstractInstallMetaData install = (AbstractInstallMetaData) o; 67 if (install.getMethodName() == null) 68 throw new IllegalArgumentException ("Install/uninstall should have method attribute."); 69 return install; 70 } 71 } 72 | Popular Tags |