View Javadoc

1   /*
2       Copyright (C) 2004 PjEr
3       
4       This program is free software; you can redistribute it and/or modify
5       it under the terms of the GNU General Public License as published by
6       the Free Software Foundation; either version 2 of the License, or
7       (at your option) any later version.
8       
9       This program is distributed in the hope that it will be useful,
10      but WITHOUT ANY WARRANTY; without even the implied warranty of
11      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12      GNU General Public License for more details.
13      
14      You should have received a copy of the GNU General Public License
15      along with this program; if not, write to the Free Software
16      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18  package ca.pjer.cm.module.discovery.defaultimpl;
19  
20  import ca.pjer.cm.api.discovery.DiscoveryService;
21  import ca.pjer.cm.api.discovery.DiscoveryServiceSystemException;
22  import ca.pjer.cm.api.discovery.DiscoveryServiceException;
23  
24  import java.util.Enumeration;
25  import java.io.IOException;
26  
27  import org.apache.commons.logging.LogFactory;
28  import org.apache.commons.logging.Log;
29  
30  /***
31   * <br />
32   * $Id: DiscoveryServiceImpl.java,v 1.1 2004/05/18 23:27:33 pjer Exp $<br />
33   * <br />
34   * $RCSfile: DiscoveryServiceImpl.java,v $<br />
35   * $Revision: 1.1 $<br />
36   * $Author: pjer $<br />
37   * $Date: 2004/05/18 23:27:33 $<br />
38   * 
39   * @TODO comment me.<br />
40   */
41  public class DiscoveryServiceImpl implements DiscoveryService {
42      private static final Log log = LogFactory.getLog(DiscoveryServiceImpl.class);
43      private static final ClassLoader CLASS_LOADER = Thread.currentThread().getContextClassLoader();
44  
45      public Enumeration discover(String name) throws DiscoveryServiceSystemException, DiscoveryServiceException {
46          Enumeration enumeration = null;
47          try {
48              enumeration = CLASS_LOADER.getResources(name);
49          } catch (IOException e) {
50              String s = "Could not discover [name:" + name + "] : " + e.getMessage();
51              log.error(s);
52              throw new DiscoveryServiceException(s, e);
53          }
54          return enumeration;
55      }
56  }