KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > email > filters > AbstractMailFilter


1 /*
2  * $Id: AbstractMailFilter.java 4219 2006-12-09 10:15:14Z lajos $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.email.filters;
12
13 import javax.mail.Message JavaDoc;
14
15 import org.apache.commons.logging.Log;
16 import org.apache.commons.logging.LogFactory;
17 import org.mule.umo.UMOFilter;
18 import org.mule.umo.UMOMessage;
19
20 /**
21  * <code>AbstractMailFilter</code> is a base class for all javax.mail.Message
22  * filters.
23  */

24 public abstract class AbstractMailFilter implements UMOFilter
25 {
26     /**
27      * logger used by this class
28      */

29     protected transient Log logger = LogFactory.getLog(getClass());
30
31     public final boolean accept(UMOMessage message)
32     {
33         if (message == null)
34         {
35             return false;
36         }
37
38         Object JavaDoc object = message.getPayload();
39         if (object instanceof Message JavaDoc)
40         {
41             return accept((Message JavaDoc)object);
42         }
43         else
44         {
45             throw new IllegalArgumentException JavaDoc("The Mail filter does not understand: "
46                                                + object.getClass().getName());
47         }
48     }
49
50     public abstract boolean accept(Message JavaDoc message);
51 }
52
Popular Tags