KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > xmpp > filters > AbstractXmppFilter


1 /*
2  * $Id: AbstractXmppFilter.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.xmpp.filters;
12
13 import org.jivesoftware.smack.filter.PacketFilter;
14 import org.jivesoftware.smack.packet.Packet;
15 import org.mule.umo.UMOFilter;
16 import org.mule.umo.UMOMessage;
17
18 /**
19  * <code>AbstractXmppFilter</code> is a filter adapter so that Smack Filters can be
20  * configured as Mule filters.
21  */

22 public abstract class AbstractXmppFilter implements UMOFilter, PacketFilter
23 {
24     protected volatile PacketFilter delegate;
25
26     public boolean accept(Packet packet)
27     {
28         if (delegate == null)
29         {
30             delegate = createFilter();
31         }
32
33         return delegate.accept(packet);
34     }
35
36     public boolean accept(UMOMessage message)
37     {
38         // If we have received a UMOMessage the filter has already been applied
39
return true;
40     }
41
42     protected abstract PacketFilter createFilter();
43
44 }
45
Popular Tags