Revision 32367 branches/v2_0_0_prep/libraries/org.gvsig.arcims/src/org/gvsig/remoteclient/arcims/ArcImsProtocolHandlerFactory.java

View differences:

ArcImsProtocolHandlerFactory.java
28 28

  
29 29
package org.gvsig.remoteclient.arcims;
30 30

  
31
import org.gvsig.remoteclient.arcims.utils.ServiceInfoTags;
32

  
33 31
import java.io.IOException;
34

  
35 32
import java.net.ConnectException;
36 33

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

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

  
56
    /**
57
     * It creates an instance of a ArcImsProtocolHandler class.
58
     *
59
     * @param type of the driver to be created
60
     * @return ArcImsDriver
61
     */
62
    private static ArcImsProtocolHandler createVersionDriver(String type) {
63
        try {
64
            Class driver;
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 65

  
66
            //           version = version.replace('.', '_');
67
            //           driver = Class.forName("org.gvsig.remoteClient.arcims.arcims_"+version+".ArcImsProtocolHandler" + version);
68
            if (type.equals(ServiceInfoTags.vIMAGESERVICE)) {
69
                driver = Class.forName(
70
                        "org.gvsig.remoteclient.arcims.ArcImsProtImageHandler");
71
            } else {
72
                driver = Class.forName(
73
                        "org.gvsig.remoteClient.arcims.ArcImsProtFeatureHandler");
74
            }
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
			}
75 73

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

  
80
            //throw new Exception("ArcImsDriverFactory. Unknown driver version " + e);
81
            return null;
82
        }
83
    }
74
			return (ArcImsProtocolHandler) driver.newInstance();
75
		} catch (Exception e) {
76
			e.printStackTrace();
77
			return null;
78
		}
79
	}
84 80
}

Also available in: Unified diff