AbstractDemandMetaData demand = (AbstractDemandMetaData) o;
for (int i = 0; i < attrs.getLength(); ++i)
{
String localName = attrs.getLocalName(i);
if ("state".equals(localName))
demand.setWhenRequired(new ControllerState(attrs.getValue(i)));
}
}
public Object endElement(Object o, QName qName, ElementBinding element)
{
AbstractDemandMetaData x = (AbstractDemandMetaData) o;
String name = (String) x.getDemand();
if (name == null || name.trim().length() == 0)
throw new IllegalArgumentException("Null or empty demand.");
return o;
}
});
// demand can take a value
demandType.setSimpleType(new CharactersHandler()
{
public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
{
return value;
}
public void setValue(QName qname, ElementBinding element, Object owner, Object value)
{
AbstractDemandMetaData demand = (AbstractDemandMetaData) owner;
demand.setDemand(value);
}
});
// supply binding
TypeBinding supplyType = schemaBinding.getType(supplyTypeQName);
supplyType.setHandler(new DefaultElementHandler()
{
public Object startElement(Object parent, QName name, ElementBinding element)
{
return new AbstractSupplyMetaData();
}
public Object endElement(Object o, QName qName, ElementBinding element)
{
AbstractSupplyMetaData x = (AbstractSupplyMetaData) o;
String name = (String) x.getSupply();
if (name == null || name.trim().length() == 0)
throw new IllegalArgumentException("Null or empty supply.");
return o;
}
});
// supply can take a value
supplyType.setSimpleType(new CharactersHandler()
{
public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
{
return value;
}
public void setValue(QName qName, ElementBinding element, Object owner, Object value)
{
AbstractSupplyMetaData supply = (AbstractSupplyMetaData) owner;
supply.setSupply(value);
}
});
// dependency binding
TypeBinding dependencyType = schemaBinding.getType(dependencyTypeQName);
dependencyType.setHandler(new DefaultElementHandler()
{
public Object startElement(Object parent, QName name, ElementBinding element)
{
return new AbstractDependencyValueMetaData();
}
public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
{
AbstractDependencyValueMetaData dependency = (AbstractDependencyValueMetaData) o;
for (int i = 0; i < attrs.getLength(); ++i)
{
String localName = attrs.getLocalName(i);
if ("bean".equals(localName))
dependency.setValue(attrs.getValue(i));
else if ("property".equals(localName))
dependency.setProperty(attrs.getValue(i));
else if ("state".equals(localName))
dependency.setDependentState(new ControllerState(attrs.getValue(i)));
}
}
public Object endElement(Object o, QName qName, ElementBinding element)
{