class ListJavaMailResources implements AdminCommand {

    public void execute(AdminCommandContext context) {

        final ActionReport report = context.getActionReport();

        try {
            List<String> list = new ArrayList<String>();
            Collection<MailResource> mailResources =
                    domain.getResources().getResources(MailResource.class);
            for (MailResource mailResource : mailResources) {
                if(bindableResourcesHelper.resourceExists(mailResource.getJndiName(), targetOperand)){
                    list.add(mailResource.getJndiName());
                }
            }

            for (String jndiName : list) {
                final ActionReport.MessagePart part =
                        report.getTopMessagePart().addChild();
                part.setMessage(jndiName);
            }
            report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
        } catch (Exception e) {
            report.setMessage(localStrings.getLocalString(
                    "list.javamail.resources.failed",
                    "Unable to list mail resources") + " " +
                    e.getLocalizedMessage());
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setFailureCause(e);
        }
    }

}