Mercurial > dive4elements > gnv-client
comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/Datasource.java @ 129:110e3ac1b7d2
Library Dependencies Added to pom.xml-File
Import of SDE-Datasources
geo-backend/trunk@5 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Wed, 02 Sep 2009 09:07:03 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
128:9b3f5a067c29 | 129:110e3ac1b7d2 |
---|---|
1 /* Copyright (C) 2007 con terra GmbH (http://www.conterra.de) | |
2 * All rights reserved | |
3 * | |
4 * $Id: Datasource.java,v 1.4 2008/01/30 12:38:34 blume Exp $ | |
5 * | |
6 * created by: drewnak | |
7 * created at : 21.11.2007 | |
8 * created at : 14:25:50 | |
9 * | |
10 * modified by: $Author: blume $ | |
11 * modified at: $Date: 2008/01/30 12:38:34 $ | |
12 */ | |
13 package de.intevation.gnv.geobackend.sde.datasources; | |
14 | |
15 import java.util.Map; | |
16 | |
17 import de.intevation.gnv.geobackend.sde.datasources.exception.DatasourceException; | |
18 | |
19 /** | |
20 * Abstract class for handling different datasources. | |
21 * This method provides a static method for creating dataosurce objects. | |
22 * | |
23 * @author drewnak | |
24 */ | |
25 public abstract class Datasource { | |
26 | |
27 protected Map mParameters; | |
28 | |
29 protected String mName; | |
30 | |
31 | |
32 /** | |
33 * Triggers the creation of a dataosurce object. Following the guidelines, the parameters for creating this datasource are delivered by the configuration file. | |
34 * | |
35 * @param pName a name for the datasource. | |
36 * @param pClassname The name of the class extending this abstract datasource class. Used to create a new instance. | |
37 * @param pParams a Map of Parameters needed for the initialization of the datasource. | |
38 * @return a datasourceobject | |
39 * @throws DatasourceException if the class could not be found or the initialization of the datasource fails. | |
40 */ | |
41 public static final Datasource create(String pName, String pClassname, | |
42 Map pParams) throws DatasourceException { | |
43 Class lDatasourceClass; | |
44 try { | |
45 lDatasourceClass = Class.forName(pClassname); | |
46 } catch (ClassNotFoundException e) { | |
47 throw new DatasourceException("Could not load class " + pClassname); | |
48 } | |
49 Datasource lNewInstance; | |
50 try { | |
51 lNewInstance = (Datasource) lDatasourceClass.newInstance(); | |
52 } catch (Exception e) { | |
53 throw new DatasourceException("Could not create instance of " + pClassname, e); | |
54 } | |
55 lNewInstance.init(pName, pParams); | |
56 | |
57 return lNewInstance; | |
58 } | |
59 | |
60 /** | |
61 * An abstract method for the initialization of a datasource instance. | |
62 * Of course, only the concrete implementation knwos about the ncessary parameters for the initialization. | |
63 * | |
64 * @param pName a name for the datasource. | |
65 * @param pParams a Map of Parameters needed for the initialization of the datasource. | |
66 */ | |
67 protected abstract void init(String pName, Map pParams) throws DatasourceException; | |
68 | |
69 /** | |
70 * @return | |
71 */ | |
72 public String getName() { | |
73 return mName; | |
74 } | |
75 | |
76 | |
77 /** | |
78 * This method returns a datasourceconnection. | |
79 * Only the concrete implementation of the Datasource knwos about the DatasourceConnection-Implementation to return. | |
80 * | |
81 * @return a DatasourceConnection | |
82 */ | |
83 public abstract DatasourceConnection getConnection(); | |
84 | |
85 /** | |
86 * Returns a DatasourceConnection. This method is usualy called after an executed query. | |
87 * See: Some datasource implementations need to explicitly close an existing connection. | |
88 * | |
89 * @param pConnection the connection to be returned. | |
90 */ | |
91 public abstract void returnConnection(DatasourceConnection pConnection); | |
92 } |