KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > remoting > network > filter > InvokerProtocolFilter


1 /***************************************
2  * *
3  * JBoss: The OpenSource J2EE WebOS *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  ***************************************/

9 package org.jboss.remoting.network.filter;
10
11 import org.jboss.remoting.InvokerLocator;
12 import org.jboss.remoting.ident.Identity;
13 import org.jboss.remoting.network.NetworkFilter;
14
15 /**
16  * InvokerProtocolFilter will examine the protocol of the InvokerLocators on the
17  * server and return true for the filter if the protocol matches our spec.
18  *
19  * @author <a HREF="mailto:jhaynie@vocalocity.net">Jeff Haynie</a>
20  * @version $Revision: 1.2 $
21  */

22 public class InvokerProtocolFilter implements NetworkFilter
23 {
24    static final long serialVersionUID = -4175168615629564295L;
25
26    private final String JavaDoc protocol;
27
28    public InvokerProtocolFilter(String JavaDoc protocol)
29    {
30       this.protocol = protocol;
31    }
32
33    /**
34     * called to apply a filter when selecting <tt>0..*</tt> servers on the network
35     *
36     * @param identity
37     * @param locators
38     * @return
39     */

40    public boolean filter(Identity identity, InvokerLocator locators[])
41    {
42       if(locators != null)
43       {
44          for(int c = 0; c < locators.length; c++)
45          {
46             // we found a transport that matches
47
if(locators[c].getProtocol().equalsIgnoreCase(protocol))
48             {
49                return true;
50             }
51          }
52       }
53       return false;
54    }
55 }
56
Popular Tags