Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AbstractXmppFilter |
|
| 1.3333333333333333;1.333 |
1 | /* | |
2 | * $Id: AbstractXmppFilter.java 7976 2007-08-21 14:26:13Z dirk.olmes $ | |
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 CPAL v1.0 | |
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.mule.umo.UMOFilter; | |
14 | import org.mule.umo.UMOMessage; | |
15 | ||
16 | import org.jivesoftware.smack.filter.PacketFilter; | |
17 | import org.jivesoftware.smack.packet.Packet; | |
18 | ||
19 | /** | |
20 | * <code>AbstractXmppFilter</code> is a filter adapter so that Smack Filters can be | |
21 | * configured as Mule filters. | |
22 | */ | |
23 | 0 | public abstract class AbstractXmppFilter implements UMOFilter, PacketFilter |
24 | { | |
25 | protected volatile PacketFilter delegate; | |
26 | ||
27 | public boolean accept(Packet packet) | |
28 | { | |
29 | 0 | if (delegate == null) |
30 | { | |
31 | 0 | delegate = createFilter(); |
32 | } | |
33 | ||
34 | 0 | return delegate.accept(packet); |
35 | } | |
36 | ||
37 | public boolean accept(UMOMessage message) | |
38 | { | |
39 | // If we have received a UMOMessage the filter has already been applied | |
40 | 0 | return true; |
41 | } | |
42 | ||
43 | protected abstract PacketFilter createFilter(); | |
44 | ||
45 | } |