Ejemplo n.º 1
0
 static {
   final Map<String, Element> map = new HashMap<String, Element>();
   for (Element element : values()) {
     final String name = element.getLocalName();
     if (name != null) map.put(name, element);
   }
   MAP = map;
 }
Ejemplo n.º 2
0
  public static PortComponentRef parse(XMLStreamReader reader) throws XMLStreamException {
    PortComponentRef portComponentRef = new PortComponentRef();

    // 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:
          {
            portComponentRef.setId(value);
            break;
          }
        default:
          throw unexpectedAttribute(reader, i);
      }
    }

    // Handle elements
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
      final Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case SERVICE_ENDPOINT_INTERFACE:
          portComponentRef.setServiceEndpointInterface(getElementText(reader));
          break;
        case ENABLE_MTOM:
          portComponentRef.setEnableMtom(Boolean.valueOf(getElementText(reader)));
          break;
        case MTOM_THRESHOLD:
          portComponentRef.setMtomThreshold(Integer.valueOf(getElementText(reader)));
          break;
        case ADDRESSING:
          portComponentRef.setAddressing(AddressingParser.parse(reader));
          break;
        case RESPECT_BINDING:
          portComponentRef.setRespectBinding(RespectBindingParser.parse(reader));
          break;
        case PORT_COMPONENT_LINK:
          portComponentRef.setPortComponentLink(getElementText(reader));
          break;
        default:
          throw unexpectedElement(reader);
      }
    }

    return portComponentRef;
  }
  public static PersistenceContextReferenceMetaData parse(
      XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException {
    PersistenceContextReferenceMetaData pcReference = new PersistenceContextReferenceMetaData();

    // Handle attributes
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
      final String value = reader.getAttributeValue(i);
      if (attributeHasNamespace(reader, i)) {
        continue;
      }
      final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case ID:
          {
            pcReference.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, propertyReplacer)) {
        if (pcReference.getDescriptions() == null) {
          pcReference.setDescriptions(descriptions);
        }
        continue;
      }
      if (ResourceInjectionMetaDataParser.parse(reader, pcReference, propertyReplacer)) {
        continue;
      }
      final Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case PERSISTENCE_CONTEXT_REF_NAME:
          pcReference.setPersistenceContextRefName(getElementText(reader, propertyReplacer));
          break;
        case PERSISTENCE_CONTEXT_TYPE:
          pcReference.setPersistenceContextType(
              PersistenceContextTypeDescription.valueOf(
                  propertyReplacer.replaceProperties(
                      getElementText(reader, propertyReplacer).toUpperCase())));
          break;
        case PERSISTENCE_CONTEXT_SYNCHRONIZATION:
          pcReference.setPersistenceContextSynchronization(
              PersistenceContextSynchronizationType.valueOf(
                  getElementText(reader, propertyReplacer)));
          break;
        case PERSISTENCE_UNIT_NAME:
          pcReference.setPersistenceUnitName(getElementText(reader, propertyReplacer));
          break;
        case PERSISTENCE_PROPERTY:
          PropertiesMetaData properties = pcReference.getProperties();
          if (properties == null) {
            properties = new PropertiesMetaData();
            pcReference.setProperties(properties);
          }
          properties.add(PropertyMetaDataParser.parse(reader, propertyReplacer));
          break;
        default:
          throw unexpectedElement(reader);
      }
    }

    return pcReference;
  }