Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / org.gvsig.arcims / src / org / gvsig / remoteclient / arcims / ArcImsProtocolHandlerFactory.java @ 32367

History | View | Annotate | Download (2.39 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 Prodevelop S.L. main development
26
 * http://www.prodevelop.es
27
 */
28

    
29
package org.gvsig.remoteclient.arcims;
30

    
31
import java.io.IOException;
32
import java.net.ConnectException;
33

    
34
import org.gvsig.remoteclient.arcims.utils.ServiceInfoTags;
35

    
36
/**
37
 * Factory to create a proper handler based on the service type (ImageServer of
38
 * FeatureServer)
39
 * 
40
 */
41
public class ArcImsProtocolHandlerFactory {
42
        /**
43
         * Stablishes the type of Handler according with the service type that will
44
         * communicate with the server and returns a convenient ProtocolHandler
45
         * 
46
         * @param servicetype
47
         * @return instance of a client that is able to communicate with the host
48
         */
49
        public static ArcImsProtocolHandler negotiate(String servicetype)
50
                        throws ConnectException, IOException {
51
                ArcImsProtocolHandler handler = createVersionDriver(servicetype);
52
                return handler;
53
        }
54

    
55
        /**
56
         * It creates an instance of a ArcImsProtocolHandler class.
57
         * 
58
         * @param type
59
         *            of the driver to be created
60
         * @return ArcImsDriver
61
         */
62
        private static ArcImsProtocolHandler createVersionDriver(String type) {
63
                try {
64
                        Class driver = null;
65

    
66
                        if (type.equals(ServiceInfoTags.vIMAGESERVICE)) {
67
                                driver = Class
68
                                                .forName("org.gvsig.remoteclient.arcims.ArcImsProtImageHandler");
69
                        } else {
70
                                driver = Class
71
                                                .forName("org.gvsig.remoteclient.arcims.ArcImsProtFeatureHandler");
72
                        }
73

    
74
                        return (ArcImsProtocolHandler) driver.newInstance();
75
                } catch (Exception e) {
76
                        e.printStackTrace();
77
                        return null;
78
                }
79
        }
80
}