001: /*
002: * $Id: AbstractRetrieveMailConnector.java 10961 2008-02-22 19:01:02Z dfeist $
003: * --------------------------------------------------------------------------------------
004: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
005: *
006: * The software in this package is published under the terms of the CPAL v1.0
007: * license, a copy of which has been included with this distribution in the
008: * LICENSE.txt file.
009: */
010:
011: package org.mule.transport.email;
012:
013: import org.mule.api.endpoint.InboundEndpoint;
014: import org.mule.api.service.Service;
015: import org.mule.api.transport.MessageReceiver;
016:
017: /**
018: * Support for connecting to and receiving email from a mailbox (the exact protocol depends on
019: * the subclass).
020: */
021: public abstract class AbstractRetrieveMailConnector extends
022: AbstractMailConnector {
023: public static final int DEFAULT_CHECK_FREQUENCY = 60000;
024:
025: /**
026: * Holds the time in milliseconds that the endpoint should wait before checking a
027: * mailbox
028: */
029: private volatile long checkFrequency = DEFAULT_CHECK_FREQUENCY;
030:
031: /**
032: * Holds a path where messages should be backed up to (auto-generated if empty)
033: */
034: private volatile String backupFolder = null;
035:
036: /**
037: * Should we save backups to backupFolder?
038: */
039: private boolean backupEnabled = false;
040:
041: /**
042: * Once a message has been read, should it be deleted
043: */
044: private volatile boolean deleteReadMessages = true;
045:
046: protected AbstractRetrieveMailConnector(int defaultPort) {
047: super (defaultPort, MAILBOX);
048: }
049:
050: /**
051: * @return the milliseconds between checking the folder for messages
052: */
053: public long getCheckFrequency() {
054: return checkFrequency;
055: }
056:
057: public void setCheckFrequency(long l) {
058: if (l < 1) {
059: l = DEFAULT_CHECK_FREQUENCY;
060: }
061: checkFrequency = l;
062: }
063:
064: /**
065: * @return a relative or absolute path to a directory on the file system
066: */
067: public String getBackupFolder() {
068: return backupFolder;
069: }
070:
071: public void setBackupFolder(String string) {
072: backupFolder = string;
073: }
074:
075: /*
076: * (non-Javadoc)
077: *
078: * @see org.mule.transport.UMOConnector#registerListener(javax.jms.MessageListener,
079: * java.lang.String)
080: */
081: public MessageReceiver createReceiver(Service service,
082: InboundEndpoint endpoint) throws Exception {
083: Object[] args = { new Long(checkFrequency),
084: Boolean.valueOf(isBackupEnabled()), backupFolder };
085: return serviceDescriptor.createMessageReceiver(this , service,
086: endpoint, args);
087: }
088:
089: public boolean isDeleteReadMessages() {
090: return deleteReadMessages;
091: }
092:
093: public void setDeleteReadMessages(boolean deleteReadMessages) {
094: this .deleteReadMessages = deleteReadMessages;
095: }
096:
097: public boolean isBackupEnabled() {
098: return backupEnabled;
099: }
100:
101: public void setBackupEnabled(boolean backupEnabled) {
102: this.backupEnabled = backupEnabled;
103: }
104:
105: }
|