KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > nutch > net > UrlNormalizerFactory


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 UrlNormalizer from "urlnormalizer.class" config property. */
10 public class UrlNormalizerFactory {
11   private static final Logger LOG =
12     LogFormatter.getLogger("net.nutch.net.UrlNormalizerFactory");
13
14   private static final String JavaDoc URLNORMALIZER_CLASS =
15     NutchConf.get("urlnormalizer.class");
16
17   private UrlNormalizerFactory() {} // no public ctor
18

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