package com.postx.james.store;

import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;

import org.apache.james.core.MailImpl;
import org.apache.james.services.SpoolRepository;
import org.apache.mailet.Mail;

import java.util.ConcurrentModificationException;
import java.util.HashSet;
import java.util.Iterator;

public class NullSpool
    extends AbstractLogEnabled
    implements Component, Configurable, Composable, Initializable, SpoolRepository {

    public void configure(Configuration conf) throws ConfigurationException {
    }

    public void compose( final ComponentManager componentManager )
            throws ComponentException {
    }

    public void initialize()
            throws Exception {
    }

    public boolean unlock(String key) {
        return true;
    }

    public boolean lock(String key) {
        return true;
    }

    public void store(MailImpl mc) {
    }

    public MailImpl retrieve(String key) {
        return null;
    }

    public void remove(MailImpl mail) {
    }

    public void remove(String key) {
    }

    public Iterator list() {
        final HashSet clone = new HashSet();
        return clone.iterator();
    }

    public synchronized String accept() {
        while (true) {
            try {
                wait();
            }
            catch (Exception ex) {
            }
        }
    }

    public synchronized String accept(long delay) {
        while (true) {
            try {
                wait(delay);
            }
            catch (Exception ex) {
            }
        }
    }
}
