KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > nutch > net > URLFilterFactory


1 /* Copyright (c) 2003 The Nutch Organization. All rights reserved. */
2 /* Use subject to the conditions in http://www.nutch.org/LICENSE.txt. */
3
4 package net.nutch.net;
5
6 import net.nutch.util.*;
7 import java.util.logging.*;
8
9 /** Factory to create a URLFilter from "urlfilter.class" config property. */
10 public class URLFilterFactory {
11   private static final Logger LOG =
12     LogFormatter.getLogger("net.nutch.net.URLFilterFactory");
13
14   private static final String JavaDoc URLFILTER_CLASS =
15     NutchConf.get("urlfilter.class");
16
17   private URLFilterFactory() {} // no public ctor
18

19   private static URLFilter filter;
20
21   /** Return the default URLFilter implementation. */
22   public static URLFilter getFilter() {
23
24     if (filter == null) {
25       try {
26         LOG.info("Using URL filter: " + URLFILTER_CLASS);
27         Class JavaDoc filterClass = Class.forName(URLFILTER_CLASS);
28         filter = (URLFilter)filterClass.newInstance();
29       } catch (Exception JavaDoc e) {
30         throw new RuntimeException JavaDoc("Couldn't create "+URLFILTER_CLASS, e);
31       }
32     }
33
34     return filter;
35
36   }
37
38 }
39
Popular Tags