public EnumProperty(Class<E> e, JAXBContextImpl context) throws JAXBException {
    _enum = e;
    _typeName = JAXBUtil.getXmlSchemaDatatype(_enum, context);

    try {
      XmlEnum xmlEnum = _enum.getAnnotation(XmlEnum.class);
      _base = xmlEnum.value();
      _baseName = JAXBUtil.getXmlSchemaDatatype(_base, context);

      // XXX check that base is an XML simple type

      Field[] fields = _enum.getFields();

      for (int i = 0; i < fields.length; i++) {
        Field f = fields[i];

        // We only care about actual enum fields
        if (!fields[i].isEnumConstant()) continue;

        XmlEnumValue xmlEnumValue = f.getAnnotation(XmlEnumValue.class);
        E value = Enum.valueOf(_enum, f.getName());

        if (xmlEnumValue != null) {
          _valueMap.put(xmlEnumValue.value(), value);
          _nameMap.put(value, xmlEnumValue.value());
        } else {
          _valueMap.put(f.getName(), value);
          _nameMap.put(value, f.getName());
        }
      }
    } catch (Exception ex) {
      throw new JAXBException(L.l("Error while introspecting enum {0}", e.getName()), ex);
    }
  }
  public void generateSchema(XMLStreamWriter out) throws XMLStreamException {
    out.writeStartElement("xsd", "simpleType", XML_SCHEMA_NS);
    out.writeAttribute("name", JAXBUtil.qNameToString(_typeName));

    out.writeStartElement("xsd", "restriction", XML_SCHEMA_NS);
    out.writeAttribute("base", JAXBUtil.qNameToString(_baseName));

    for (String name : _nameMap.values()) {
      out.writeEmptyElement("xsd", "enumeration", XML_SCHEMA_NS);
      out.writeAttribute("value", name);
    }

    out.writeEndElement(); // restriction
    out.writeEndElement(); // simpleType
  }
  public void init() throws ServletException {
    super.init();

    try {
      Class cl = _service.getClass();

      if (cl.isAnnotationPresent(WebService.class)) {
        WebService webService = (WebService) cl.getAnnotation(WebService.class);

        String endpoint = webService.endpointInterface();

        if (endpoint != null && !"".equals(endpoint))
          cl = CauchoSystem.loadClass(webService.endpointInterface());
      }

      ArrayList<Class> jaxbClasses = _jaxbClasses;

      for (Method method : cl.getMethods()) {
        if (method.getDeclaringClass().equals(Object.class)) continue;

        int modifiers = method.getModifiers();

        // Allow abstract for interfaces
        if (Modifier.isStatic(modifiers)
            || Modifier.isFinal(modifiers)
            || !Modifier.isPublic(modifiers)) continue;

        if (_context == null) JAXBUtil.introspectMethod(method, jaxbClasses);
      }

      if (_context != null) {
      } else if (_jaxbPackages != null) {
        _context = JAXBContext.newInstance(_jaxbPackages);
      } else {
        Class[] classes = jaxbClasses.toArray(new Class[jaxbClasses.size()]);
        _context = JAXBContext.newInstance(classes);
      }

      _marshaller = _context.createMarshaller();
      _marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      _unmarshaller = _context.createUnmarshaller();
    } catch (Exception e) {
      throw new ServletException(e);
    }
  }