class RundeckServlet extends HttpServlet {

    @VisibleForTesting
    void writeRundeckResourceModelXmlTo(PrintWriter writer) {
        final List<ProcessInstance> processes = processEngine.getRuntimeService()
            .createProcessInstanceQuery().list();

        Project project = new Project();
        for (ProcessInstance instance : processes) {
            final Pool pool = (Pool) processEngine.getRuntimeService()
                .getVariable(instance.getId(), CoreProcessVariables.POOL);
            if (pool == null) {
                continue; /* skip - this process is not a provisionr process */
            }

            final String businessKey = (String) processEngine.getRuntimeService()
                .getVariable(instance.getId(), CoreProcessVariables.POOL_BUSINESS_KEY);
            if (!Objects.equal(instance.getBusinessKey(), businessKey)) {
                continue; /* ignore - this is a process started by the main pool management process */
            }

            @SuppressWarnings("unchecked")
            List<Machine> machines = (List<Machine>) processEngine.getRuntimeService()
                .getVariable(instance.getId(), CoreProcessVariables.MACHINES);
            if (machines == null) {
                continue;   /* the list of machines is not yet available */
            }

            project.setNodes(transformMachinesToRundeckNodes(businessKey, pool, machines));
        }

        try {
            marshaller.marshal(project, writer);

        } catch (JAXBException e) {
            throw Throwables.propagate(e);
        }
    }

    public  RundeckServlet(ProcessEngine processEngine);

}