class JdbcDriversJaxrsService {

    @GET
    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    public List<JdbcDriverInfo> getJdbcDrivers() {
        List<JdbcDriverInfo> jdbcDriverInfos = new ArrayList<JdbcDriverInfo>(jdbcConnectionMap.size());
        final Set<String> registeredDriverClassNames = new HashSet<String>(jdbcDriverService.getRegisteredDriverClassNames());

        for (Map.Entry<String, Map<String, Object>> entry : jdbcConnectionMap.entrySet()) {
            JdbcDriverInfo info = new JdbcDriverInfo().setName(entry.getKey());
            jdbcDriverInfos.add(info);
            final Map<String, Object> value = entry.getValue();
            final String jdbcDriverClass = (String) value.get("jdbcDriverClass");
            final String isDefault = (String) value.get("default");
            info.setAvailable(jdbcDriverService.isRegistered(jdbcDriverClass))
                    .setJdbcDriverClass(jdbcDriverClass)
                    .setDefault(isDefault != null ? Boolean.valueOf(isDefault) : null)
                    .setJdbcUrl((String) value.get("jdbcUrl")).setLabel((String) value.get("label"))
                    .setAllowSpacesInDbName("true".equals(value.get("allowSpacesInDbName")));
            // XML configuration assures cast safety
            @SuppressWarnings("unchecked")
            final Map<String, String> defaultValues = (Map<String, String>) value.get("defaultValues");
            if (defaultValues != null) {
                List<ClientProperty> defaultProperties = new ArrayList<ClientProperty>(defaultValues.size());
                info.setDefaultValues(defaultProperties);
                for (String currentProperty : defaultValues.keySet()) {
                    defaultProperties.add(new ClientProperty(currentProperty, defaultValues.get(currentProperty)));
                }
            }
            registeredDriverClassNames.remove(jdbcDriverClass);
        }
        if (!registeredDriverClassNames.isEmpty()) {
            for (String currentClass : registeredDriverClassNames) {
                jdbcDriverInfos.add(new JdbcDriverInfo().setName(currentClass).setJdbcDriverClass(currentClass).setLabel(currentClass));
            }
        }
        return jdbcDriverInfos;
    }

}