* @author Remy Maucherat
*/
public class EJBReferenceMetaDataParser extends MetaDataElementParser {
public static EJBReferenceMetaData parse(XMLStreamReader reader) throws XMLStreamException {
EJBReferenceMetaData ejbReference = new EJBReferenceMetaData();
// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i ++) {
final String value = reader.getAttributeValue(i);
if (reader.getAttributeNamespace(i) != null) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
ejbReference.setId(value);
break;
}
default: throw unexpectedAttribute(reader, i);
}
}
DescriptionsImpl descriptions = new DescriptionsImpl();
// Handle elements
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
if (DescriptionsMetaDataParser.parse(reader, descriptions)) {
if (ejbReference.getDescriptions() == null) {
ejbReference.setDescriptions(descriptions);
}
continue;
}
if (ResourceInjectionMetaDataParser.parse(reader, ejbReference)) {
continue;
}
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case EJB_REF_NAME:
ejbReference.setEjbRefName(reader.getElementText());
break;
case EJB_REF_TYPE:
ejbReference.setEjbRefType(EJBReferenceType.valueOf(reader.getElementText()));
break;
case HOME:
ejbReference.setHome(reader.getElementText());
break;
case REMOTE:
ejbReference.setRemote(reader.getElementText());
break;
case EJB_LINK:
ejbReference.setLink(reader.getElementText());
break;
default: throw unexpectedElement(reader);
}
}