Project

General

Profile

1
/**
2
 *  '$RCSfile$'
3
 *  Copyright: 2000 Regents of the University of California and the
4
 *              National Center for Ecological Analysis and Synthesis
5
 *
6
 *   '$Author: jones $'
7
 *     '$Date: 2003-08-08 16:16:24 -0700 (Fri, 08 Aug 2003) $'
8
 * '$Revision: 1780 $'
9
 *
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation; either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 */
24

    
25
package edu.ucsb.nceas.metacat.client;
26

    
27
import java.io.Reader;
28

    
29
/**
30
 *  This class is a factory which allows the caller to create an instance of
31
 *  a Metacat object for accessing a metacat server.
32
 */
33
public class MetacatFactory
34
{
35
    private static final String metacatClientClass = 
36
         "edu.ucsb.nceas.metacat.client.MetacatClient";
37

    
38
    /**
39
     *  Create a new instance of a Metacat object of raccessing a server.
40
     *
41
     *  @param metacatUrl the url location of the metacat server
42
     *  @throws MetacatInaccessibleException when the metacat server can not
43
     *                    be reached
44
     */
45
    public static Metacat createMetacatConnection(String metacatUrl) 
46
           throws MetacatInaccessibleException
47
    {
48
        Metacat m = null;
49
        try {
50
            Class c = Class.forName(metacatClientClass);
51
            m = (Metacat)c.newInstance();
52
        } catch (InstantiationException e) {
53
            throw new MetacatInaccessibleException(e.getMessage());
54
        } catch (IllegalAccessException e) {
55
            throw new MetacatInaccessibleException(e.getMessage());
56
        } catch (ClassNotFoundException e) {
57
            throw new MetacatInaccessibleException(e.getMessage());
58
        }
59

    
60
        m.setMetacatUrl(metacatUrl);
61

    
62
        return m;
63
    }
64
}
(5-5/6)