public void generate() {
    try {
      writer.writeStartDocument();
      writer.writeCharacters("\n");
      writeBlueprint();
      for (Bean bean : context.getBeans()) {
        writeBeanStart(bean);
        bean.writeProperties(this);
        writer.writeEndElement();
        writer.writeCharacters("\n");
      }

      writeServiceRefs();
      new OsgiServiceProviderWriter(writer).write(context.getBeans());

      writer.writeEndElement();
      writer.writeCharacters("\n");
      writer.writeEndDocument();
      writer.writeCharacters("\n");
      writer.close();
    } catch (XMLStreamException e) {
      throw new RuntimeException(e.getMessage(), e);
    }
  }
 private void writeServiceRefs() throws XMLStreamException {
   for (OsgiServiceBean serviceBean : context.getServiceRefs()) {
     writeServiceRef(serviceBean);
   }
 }